Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] (PR#15016) Re: Animated nukes
Home

[Freeciv-Dev] (PR#15016) Re: Animated nukes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15016) Re: Animated nukes
From: "Andreas Røsdal" <andrearo@xxxxxxxxxxxx>
Date: Wed, 28 Dec 2005 17:30:33 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15016 >

On Wed, 28 Dec 2005, Daniel Markstedt wrote:
> Lukas Toenne contributed a really nice looking nuke animation made with
> Blender about a year ago. It can easily be scaled for differently sized
> tilesets with great results.

Here's a patch putting Lukas' graphics to use. It adds animated
nukes to the isometric tilesets.

http://www.stud.ntnu.no/~andrearo/nuke1.png
http://www.stud.ntnu.no/~andrearo/nuke2.png

Apply patch to snv, and copy nuke1.png to amplio/nuke.png and nuke2.png to
isotrident/nuke.png.

Andreas R.
(sorry for spamming the mailing list with large files...)
diff -ruN -Xfreeciv/diff_ignore freeciv/client/mapview_common.c 
freeciv-nuke-anim/client/mapview_common.c
--- freeciv/client/mapview_common.c     2005-12-24 13:32:19.000000000 +0100
+++ freeciv-nuke-anim/client/mapview_common.c   2005-12-29 02:30:40.000000000 
+0100
@@ -1023,34 +1023,54 @@
 ****************************************************************************/
 void put_nuke_mushroom_pixmaps(struct tile *ptile)
 {
-  int canvas_x, canvas_y;
-  struct sprite *mysprite = get_nuke_explode_sprite(tileset);
+  static struct timer *anim_timer = NULL;
+  const struct sprite_vector *anim = get_nuke_explode_animation(tileset);
+  const int num_tiles_explode_nuke = sprite_vector_size(anim);
+  int canvas_x, canvas_y, i;
   int width, height;
 
+  if (!num_tiles_explode_nuke) {
+    return;
+  }
+
   /* We can't count on the return value of tile_to_canvas_pos since the
    * sprite may span multiple tiles. */
   (void) tile_to_canvas_pos(&canvas_x, &canvas_y, ptile);
-  get_sprite_dimensions(mysprite, &width, &height);
+  get_sprite_dimensions(*sprite_vector_get(anim, 0), &width, &height);
 
   canvas_x += (tileset_tile_width(tileset) - width) / 2;
   canvas_y += (tileset_tile_height(tileset) - height) / 2;
 
-  /* Make sure everything is flushed and synced before proceeding.  First
-   * we update everything to the store, but don't write this to screen.
-   * Then add the nuke graphic to the store.  Finally flush everything to
-   * the screen and wait 1 second. */
   unqueue_mapview_updates(FALSE);
+  canvas_copy(mapview.tmp_store, mapview.store,
+              canvas_x, canvas_y, canvas_x, canvas_y,
+              width, height);
+
+  for (i = 0; i < num_tiles_explode_nuke; i++) {
+    int w, h;
+    struct sprite *sprite = *sprite_vector_get(anim, i);
 
-  canvas_put_sprite_full(mapview.store, canvas_x, canvas_y, mysprite);
-  dirty_rect(canvas_x, canvas_y, width, height);
+    get_sprite_dimensions(sprite, &w, &h);
+    anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
 
-  flush_dirty();
-  redraw_selection_rectangle();
-  gui_flush();
+    canvas_copy(mapview.store, mapview.tmp_store,
+                canvas_x, canvas_y, canvas_x, canvas_y,
+                width, height);
+    canvas_put_sprite_full(mapview.store,
+                           canvas_x + width / 2 - w / 2,
+                           canvas_y + height / 2 - h / 2,
+                           sprite);
+    dirty_rect(canvas_x, canvas_y, width, height);
 
-  myusleep(1000000);
+    flush_dirty();
+    redraw_selection_rectangle();
+    gui_flush();
+
+    usleep_since_timer_start(anim_timer, 30000);
+  }
 
   update_map_canvas_visible();
+
 }
 
 /**************************************************************************
diff -ruN -Xfreeciv/diff_ignore freeciv/client/packhand.c 
freeciv-nuke-anim/client/packhand.c
--- freeciv/client/packhand.c   2005-12-24 13:32:19.000000000 +0100
+++ freeciv-nuke-anim/client/packhand.c 2005-12-29 02:35:54.000000000 +0100
@@ -267,7 +267,9 @@
 **************************************************************************/
 void handle_nuke_tile_info(int x, int y)
 {
-  put_nuke_mushroom_pixmaps(map_pos_to_tile(x, y));
+  if (do_combat_animation) {
+    put_nuke_mushroom_pixmaps(map_pos_to_tile(x, y));
+  }
 }
 
 /**************************************************************************
diff -ruN -Xfreeciv/diff_ignore freeciv/client/tilespec.c 
freeciv-nuke-anim/client/tilespec.c
--- freeciv/client/tilespec.c   2005-12-24 13:32:19.000000000 +0100
+++ freeciv-nuke-anim/client/tilespec.c 2005-12-28 16:36:09.000000000 +0100
@@ -173,7 +173,7 @@
   } road, rail;
   struct {
     struct sprite_vector unit;
-    struct sprite *nuke;
+    struct sprite_vector nuke;
   } explode;
   struct {
     struct sprite
@@ -2117,7 +2117,16 @@
     }
   }
 
-  SET_SPRITE(explode.nuke, "explode.nuke");
+  sprite_vector_init(&t->sprites.explode.nuke);
+  for (i = 0; ; i++) {
+    struct sprite *sprite;
+    my_snprintf(buffer, sizeof(buffer), "explode.nukeanim_%d", i);
+    sprite = load_sprite(t, buffer);
+    if (!sprite) {
+      break;
+    }
+    sprite_vector_append(&t->sprites.explode.nuke, &sprite);
+  }
 
   sprite_vector_init(&t->sprites.explode.unit);
   for (i = 0; ; i++) {
@@ -4531,13 +4540,12 @@
 }
 
 /****************************************************************************
-  Return a sprite contining the single nuke graphic.
-
-  TODO: This should be an animation like the unit explode animation.
+  Return a sprite_vector contining the animation sprites for a nuke.
 ****************************************************************************/
-struct sprite *get_nuke_explode_sprite(const struct tileset *t)
+const struct sprite_vector *get_nuke_explode_animation(const struct 
+                                                      tileset *t)
 {
-  return t->sprites.explode.nuke;
+  return &t->sprites.explode.nuke;
 }
 
 /**************************************************************************
diff -ruN -Xfreeciv/diff_ignore freeciv/client/tilespec.h 
freeciv-nuke-anim/client/tilespec.h
--- freeciv/client/tilespec.h   2005-12-24 13:32:19.000000000 +0100
+++ freeciv-nuke-anim/client/tilespec.h 2005-12-28 15:35:45.000000000 +0100
@@ -214,7 +214,8 @@
 struct sprite *get_treaty_thumb_sprite(const struct tileset *t, bool on_off);
 const struct sprite_vector *get_unit_explode_animation(const struct
                                                       tileset *t);
-struct sprite *get_nuke_explode_sprite(const struct tileset *t);
+const struct sprite_vector *get_nuke_explode_animation(const struct 
+                                                      tileset *t);
 struct sprite *get_cursor_sprite(const struct tileset *t,
                                 enum cursor_type cursor,
                                 int *hot_x, int *hot_y, int frame);
diff -ruN -Xfreeciv/diff_ignore freeciv/data/amplio/nuke.spec 
freeciv-nuke-anim/data/amplio/nuke.spec
--- freeciv/data/amplio/nuke.spec       2005-12-24 13:31:36.000000000 +0100
+++ freeciv-nuke-anim/data/amplio/nuke.spec     2005-12-28 16:37:51.000000000 
+0100
@@ -6,8 +6,7 @@
 [info]
 
 artists = "
-    Tatu Rissanen <tatu.rissanen@xxxxxx>
-    Jeff Mallatt <jjm@xxxxxxxxxxxx> (miscellaneous)
+    Lukas Toenne <lukas.toenne@xxxxxx>
 "
 
 [file]
@@ -15,12 +14,31 @@
 
 [grid_main]
 
-x_top_left = 0
-y_top_left = 0
-dx = 180
-dy = 176
-pixel_border = 0
+x_top_left = 1
+y_top_left = 1
+dx = 192
+dy = 180
+pixel_border = 1
 
 tiles = { "row", "column", "tag"
- 0, 0, "explode.nuke"
+ 0, 0, "explode.nukeanim_0"
+ 0, 1, "explode.nukeanim_1"
+ 0, 2, "explode.nukeanim_2"
+ 0, 3, "explode.nukeanim_3"
+ 0, 4, "explode.nukeanim_4"
+ 0, 5, "explode.nukeanim_5"
+ 0, 6, "explode.nukeanim_6"
+ 0, 7, "explode.nukeanim_7"
+ 0, 8, "explode.nukeanim_8"
+ 0, 9, "explode.nukeanim_9"
+ 1, 0, "explode.nukeanim_10"
+ 1, 1, "explode.nukeanim_11"
+ 1, 2, "explode.nukeanim_12"
+ 1, 3, "explode.nukeanim_13"
+ 1, 4, "explode.nukeanim_14"
+ 1, 5, "explode.nukeanim_15"
+ 1, 6, "explode.nukeanim_16"
+ 1, 7, "explode.nukeanim_17"
+ 1, 8, "explode.nukeanim_18"
+ 1, 9, "explode.nukeanim_19"
 }
diff -ruN -Xfreeciv/diff_ignore freeciv/data/isotrident/nuke.spec 
freeciv-nuke-anim/data/isotrident/nuke.spec
--- freeciv/data/isotrident/nuke.spec   2005-12-24 13:31:36.000000000 +0100
+++ freeciv-nuke-anim/data/isotrident/nuke.spec 2005-12-28 16:38:56.000000000 
+0100
@@ -6,8 +6,7 @@
 [info]
 
 artists = "
-    Tatu Rissanen <tatu.rissanen@xxxxxx>
-    Jeff Mallatt <jjm@xxxxxxxxxxxx> (miscellaneous)
+    Lukas Toenne <lukas.toenne@xxxxxx>
 "
 
 [file]
@@ -15,12 +14,31 @@
 
 [grid_main]
 
-x_top_left = 0
-y_top_left = 0
-dx = 90
-dy = 88
-pixel_border = 0
+x_top_left = 1
+y_top_left = 1
+dx = 128
+dy = 120
+pixel_border = 1
 
 tiles = { "row", "column", "tag"
- 0, 0, "explode.nuke"
+ 0, 0, "explode.nukeanim_0"
+ 0, 1, "explode.nukeanim_1"
+ 0, 2, "explode.nukeanim_2"
+ 0, 3, "explode.nukeanim_3"
+ 0, 4, "explode.nukeanim_4"
+ 0, 5, "explode.nukeanim_5"
+ 0, 6, "explode.nukeanim_6"
+ 0, 7, "explode.nukeanim_7"
+ 0, 8, "explode.nukeanim_8"
+ 0, 9, "explode.nukeanim_9"
+ 1, 0, "explode.nukeanim_10"
+ 1, 1, "explode.nukeanim_11"
+ 1, 2, "explode.nukeanim_12"
+ 1, 3, "explode.nukeanim_13"
+ 1, 4, "explode.nukeanim_14"
+ 1, 5, "explode.nukeanim_15"
+ 1, 6, "explode.nukeanim_16"
+ 1, 7, "explode.nukeanim_17"
+ 1, 8, "explode.nukeanim_18"
+ 1, 9, "explode.nukeanim_19"
 }

[Prev in Thread] Current Thread [Next in Thread]