From: LMH Date: Tue, 24 Jan 2012 20:32:05 +0000 (-1000) Subject: weakblock: ice-themed sprite/behavior added, fire bullets absorbed, iceflower no... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0e7aa8cb8f1e6808440369d501947a785624a652;p=supertux.git weakblock: ice-themed sprite/behavior added, fire bullets absorbed, iceflower no longer destroys, test level added (bug 819) --- diff --git a/data/images/objects/strawbox/straw.png b/data/images/objects/strawbox/straw.png deleted file mode 100644 index b8b5103f8..000000000 Binary files a/data/images/objects/strawbox/straw.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_01.png b/data/images/objects/strawbox/straw_01.png deleted file mode 100644 index 3068b38f8..000000000 Binary files a/data/images/objects/strawbox/straw_01.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_02.png b/data/images/objects/strawbox/straw_02.png deleted file mode 100644 index 8937527a3..000000000 Binary files a/data/images/objects/strawbox/straw_02.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_03.png b/data/images/objects/strawbox/straw_03.png deleted file mode 100644 index 7f2b5a43c..000000000 Binary files a/data/images/objects/strawbox/straw_03.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_04.png b/data/images/objects/strawbox/straw_04.png deleted file mode 100644 index a81a541c7..000000000 Binary files a/data/images/objects/strawbox/straw_04.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_05.png b/data/images/objects/strawbox/straw_05.png deleted file mode 100644 index d84f3bb5d..000000000 Binary files a/data/images/objects/strawbox/straw_05.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_06.png b/data/images/objects/strawbox/straw_06.png deleted file mode 100644 index 81f385ae6..000000000 Binary files a/data/images/objects/strawbox/straw_06.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_07.png b/data/images/objects/strawbox/straw_07.png deleted file mode 100644 index 4ec91e130..000000000 Binary files a/data/images/objects/strawbox/straw_07.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_08.png b/data/images/objects/strawbox/straw_08.png deleted file mode 100644 index dec5edf9d..000000000 Binary files a/data/images/objects/strawbox/straw_08.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_09.png b/data/images/objects/strawbox/straw_09.png deleted file mode 100644 index bc6af5e0b..000000000 Binary files a/data/images/objects/strawbox/straw_09.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_10.png b/data/images/objects/strawbox/straw_10.png deleted file mode 100644 index ec38f05c2..000000000 Binary files a/data/images/objects/strawbox/straw_10.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_11.png b/data/images/objects/strawbox/straw_11.png deleted file mode 100644 index d5b8e4801..000000000 Binary files a/data/images/objects/strawbox/straw_11.png and /dev/null differ diff --git a/data/images/objects/strawbox/straw_12.png b/data/images/objects/strawbox/straw_12.png deleted file mode 100644 index b0aa3f228..000000000 Binary files a/data/images/objects/strawbox/straw_12.png and /dev/null differ diff --git a/data/images/objects/strawbox/strawbox.sprite b/data/images/objects/strawbox/strawbox.sprite deleted file mode 100644 index 0cb15cd1c..000000000 --- a/data/images/objects/strawbox/strawbox.sprite +++ /dev/null @@ -1,29 +0,0 @@ -(supertux-sprite - (action - (name "normal") - (images - "straw.png" - ) - ) - (action - (name "burning") - (images - "straw_01.png" - "straw_02.png" - "straw_03.png" - "straw_04.png" - "straw_05.png" - "straw_06.png" - ) - ) - (action - (name "disintegrating") - (images - "straw_07.png" - "straw_08.png" - "straw_09.png" - "straw_10.png" - "straw_11.png" - ) - ) -) diff --git a/data/images/objects/weak_block/melt_01.png b/data/images/objects/weak_block/melt_01.png new file mode 100644 index 000000000..abcb86a8b Binary files /dev/null and b/data/images/objects/weak_block/melt_01.png differ diff --git a/data/images/objects/weak_block/melt_02.png b/data/images/objects/weak_block/melt_02.png new file mode 100644 index 000000000..bec8ba594 Binary files /dev/null and b/data/images/objects/weak_block/melt_02.png differ diff --git a/data/images/objects/weak_block/melt_03.png b/data/images/objects/weak_block/melt_03.png new file mode 100644 index 000000000..77034bb4f Binary files /dev/null and b/data/images/objects/weak_block/melt_03.png differ diff --git a/data/images/objects/weak_block/melt_04.png b/data/images/objects/weak_block/melt_04.png new file mode 100644 index 000000000..c890cb17e Binary files /dev/null and b/data/images/objects/weak_block/melt_04.png differ diff --git a/data/images/objects/weak_block/melt_05.png b/data/images/objects/weak_block/melt_05.png new file mode 100644 index 000000000..b5a956252 Binary files /dev/null and b/data/images/objects/weak_block/melt_05.png differ diff --git a/data/images/objects/weak_block/melt_06.png b/data/images/objects/weak_block/melt_06.png new file mode 100644 index 000000000..2af04b137 Binary files /dev/null and b/data/images/objects/weak_block/melt_06.png differ diff --git a/data/images/objects/weak_block/melt_07.png b/data/images/objects/weak_block/melt_07.png new file mode 100644 index 000000000..26eae96d9 Binary files /dev/null and b/data/images/objects/weak_block/melt_07.png differ diff --git a/data/images/objects/weak_block/melt_08.png b/data/images/objects/weak_block/melt_08.png new file mode 100644 index 000000000..b65f294bd Binary files /dev/null and b/data/images/objects/weak_block/melt_08.png differ diff --git a/data/images/objects/weak_block/melt_09.png b/data/images/objects/weak_block/melt_09.png new file mode 100644 index 000000000..233e8e2fe Binary files /dev/null and b/data/images/objects/weak_block/melt_09.png differ diff --git a/data/images/objects/weak_block/melt_10.png b/data/images/objects/weak_block/melt_10.png new file mode 100644 index 000000000..863b4045c Binary files /dev/null and b/data/images/objects/weak_block/melt_10.png differ diff --git a/data/images/objects/weak_block/melt_11.png b/data/images/objects/weak_block/melt_11.png new file mode 100644 index 000000000..c0f5d8fe3 Binary files /dev/null and b/data/images/objects/weak_block/melt_11.png differ diff --git a/data/images/objects/weak_block/meltbox.png b/data/images/objects/weak_block/meltbox.png new file mode 100644 index 000000000..a074a2372 Binary files /dev/null and b/data/images/objects/weak_block/meltbox.png differ diff --git a/data/images/objects/weak_block/meltbox.sprite b/data/images/objects/weak_block/meltbox.sprite new file mode 100644 index 000000000..a62c2ae70 --- /dev/null +++ b/data/images/objects/weak_block/meltbox.sprite @@ -0,0 +1,29 @@ +(supertux-sprite + (action + (name "normal") + (images + "meltbox.png" + ) + ) + (action + (name "burning") + (images + "melt_01.png" + "melt_02.png" + "melt_03.png" + "melt_04.png" + "melt_05.png" + ) + ) + (action + (name "disintegrating") + (images + "melt_06.png" + "melt_07.png" + "melt_08.png" + "melt_09.png" + "melt_10.png" + "melt_11.png" + ) + ) +) diff --git a/data/images/objects/weak_block/meltbox.xcf b/data/images/objects/weak_block/meltbox.xcf new file mode 100644 index 000000000..774390207 Binary files /dev/null and b/data/images/objects/weak_block/meltbox.xcf differ diff --git a/data/images/objects/weak_block/straw.png b/data/images/objects/weak_block/straw.png new file mode 100644 index 000000000..b8b5103f8 Binary files /dev/null and b/data/images/objects/weak_block/straw.png differ diff --git a/data/images/objects/weak_block/straw_01.png b/data/images/objects/weak_block/straw_01.png new file mode 100644 index 000000000..3068b38f8 Binary files /dev/null and b/data/images/objects/weak_block/straw_01.png differ diff --git a/data/images/objects/weak_block/straw_02.png b/data/images/objects/weak_block/straw_02.png new file mode 100644 index 000000000..8937527a3 Binary files /dev/null and b/data/images/objects/weak_block/straw_02.png differ diff --git a/data/images/objects/weak_block/straw_03.png b/data/images/objects/weak_block/straw_03.png new file mode 100644 index 000000000..7f2b5a43c Binary files /dev/null and b/data/images/objects/weak_block/straw_03.png differ diff --git a/data/images/objects/weak_block/straw_04.png b/data/images/objects/weak_block/straw_04.png new file mode 100644 index 000000000..a81a541c7 Binary files /dev/null and b/data/images/objects/weak_block/straw_04.png differ diff --git a/data/images/objects/weak_block/straw_05.png b/data/images/objects/weak_block/straw_05.png new file mode 100644 index 000000000..d84f3bb5d Binary files /dev/null and b/data/images/objects/weak_block/straw_05.png differ diff --git a/data/images/objects/weak_block/straw_06.png b/data/images/objects/weak_block/straw_06.png new file mode 100644 index 000000000..81f385ae6 Binary files /dev/null and b/data/images/objects/weak_block/straw_06.png differ diff --git a/data/images/objects/weak_block/straw_07.png b/data/images/objects/weak_block/straw_07.png new file mode 100644 index 000000000..4ec91e130 Binary files /dev/null and b/data/images/objects/weak_block/straw_07.png differ diff --git a/data/images/objects/weak_block/straw_08.png b/data/images/objects/weak_block/straw_08.png new file mode 100644 index 000000000..dec5edf9d Binary files /dev/null and b/data/images/objects/weak_block/straw_08.png differ diff --git a/data/images/objects/weak_block/straw_09.png b/data/images/objects/weak_block/straw_09.png new file mode 100644 index 000000000..bc6af5e0b Binary files /dev/null and b/data/images/objects/weak_block/straw_09.png differ diff --git a/data/images/objects/weak_block/straw_10.png b/data/images/objects/weak_block/straw_10.png new file mode 100644 index 000000000..ec38f05c2 Binary files /dev/null and b/data/images/objects/weak_block/straw_10.png differ diff --git a/data/images/objects/weak_block/straw_11.png b/data/images/objects/weak_block/straw_11.png new file mode 100644 index 000000000..d5b8e4801 Binary files /dev/null and b/data/images/objects/weak_block/straw_11.png differ diff --git a/data/images/objects/weak_block/straw_12.png b/data/images/objects/weak_block/straw_12.png new file mode 100644 index 000000000..b0aa3f228 Binary files /dev/null and b/data/images/objects/weak_block/straw_12.png differ diff --git a/data/images/objects/weak_block/strawbox.sprite b/data/images/objects/weak_block/strawbox.sprite new file mode 100644 index 000000000..0cb15cd1c --- /dev/null +++ b/data/images/objects/weak_block/strawbox.sprite @@ -0,0 +1,29 @@ +(supertux-sprite + (action + (name "normal") + (images + "straw.png" + ) + ) + (action + (name "burning") + (images + "straw_01.png" + "straw_02.png" + "straw_03.png" + "straw_04.png" + "straw_05.png" + "straw_06.png" + ) + ) + (action + (name "disintegrating") + (images + "straw_07.png" + "straw_08.png" + "straw_09.png" + "straw_10.png" + "straw_11.png" + ) + ) +) diff --git a/data/levels/test/weakblock.stl b/data/levels/test/weakblock.stl new file mode 100755 index 000000000..7c52d276a --- /dev/null +++ b/data/levels/test/weakblock.stl @@ -0,0 +1,141 @@ +(supertux-level + (version 2) + (name (_ "Weakblock Test")) + (author "LMH") + (license "GPL 2 / CC-by-sa 3.0" ) + (sector (name "main" ) + (ambient-light 1 1 1 ) + (camera (mode "normal" )) + + (spawnpoint (name "main" ) + (x 80 )(y 704 )) + + (tilemap (name "Interactive" ) + (z-pos 0 )(solid #t ) + (width 42 )(height 30 ) + (tiles ; 160 192 224 256 288 320 352 384 416 448 480 512 544 576 608 640 672 704 736 768 800 832 864 896 928 960 992 1024 1056 1088 1120 1152 1184 1216 1248 1280 1312 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 32 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 64 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 96 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 128 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 160 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 192 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 224 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 256 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 288 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 320 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 352 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 384 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 416 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 448 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 512 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 544 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 576 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 608 +0 0 0 0 140 0 140 0 0 102 0 102 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 640 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 672 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 704 +8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ; 736 +14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 ; 768 +11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 800 +11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 832 +11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 864 +11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 896 +11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 928 + )) + (weak_block + (linked #f ) + (x 480 )(y 736 )) + (weak_block + (linked #f ) + (x 512 )(y 736 )) + (weak_block + (linked #f ) + (x 544 )(y 736 )) + (weak_block + (linked #f ) + (x 576 )(y 736 )) + (weak_block + (linked #f ) + (x 608 )(y 736 )) + (weak_block + (linked #f ) + (x 640 )(y 736 )) + (weak_block + (linked #f ) + (x 672 )(y 736 )) + (weak_block + (x 480 )(y 672 )) + (weak_block + (x 512 )(y 672 )) + (weak_block + (x 544 )(y 672 )) + (weak_block + (x 576 )(y 672 )) + (weak_block + (x 608 )(y 672 )) + (weak_block + (x 640 )(y 672 )) + (weak_block + (x 672 )(y 672 )) + + (weak_block + (linked #f ) + (x 736 )(y 704 )) + (weak_block + (linked #f ) + (x 768 )(y 704 )) + (weak_block + (linked #f ) + (x 800 )(y 704 )) + (weak_block + (linked #f ) + (x 832 )(y 704 )) + (weak_block + (linked #f ) + (x 864 )(y 704 )) + (weak_block + (linked #f ) + (x 896 )(y 704 )) + (weak_block + (linked #f ) + (x 928 )(y 704 )) + (weak_block + (x 736 )(y 672 )) + (weak_block + (x 768 )(y 672 )) + (weak_block + (x 800 )(y 672 )) + (weak_block + (x 832 )(y 672 )) + (weak_block + (x 864 )(y 672 )) + (weak_block + (x 896 )(y 672 )) + (weak_block + (x 928 )(y 672 )) + + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 992 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1024 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1056 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1088 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1120 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1152 )(y 704 )) + (weak_block + (linked #t )(sprite "images/objects/weak_block/meltbox.sprite" ) + (x 1184 )(y 704 )) +)) diff --git a/src/object/weak_block.cpp b/src/object/weak_block.cpp index b9d10c525..78644d6a3 100644 --- a/src/object/weak_block.cpp +++ b/src/object/weak_block.cpp @@ -21,38 +21,80 @@ #include "object/explosion.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include "sprite/sprite.hpp" +#include "sprite/sprite_manager.hpp" +#include "util/reader.hpp" #include WeakBlock::WeakBlock(const Reader& lisp) - : MovingSprite(lisp, "images/objects/strawbox/strawbox.sprite", LAYER_TILES, COLGROUP_STATIC), state(STATE_NORMAL) +: MovingSprite(lisp, "images/objects/weak_block/strawbox.sprite", LAYER_TILES, COLGROUP_STATIC), state(STATE_NORMAL), +linked(true) { sprite->set_action("normal"); + //Check if this weakblock destroys adjacent weakblocks + if(lisp.get("linked", linked)){ + if(! linked){ + sprite_name = "images/objects/weak_block/meltbox.sprite"; + sprite = sprite_manager->create(sprite_name); + sprite->set_action("normal"); + } + } } HitResponse -WeakBlock::collision(GameObject& other, const CollisionHit& ) +WeakBlock::collision_bullet(Bullet& bullet, const CollisionHit& hit) { switch (state) { - + case STATE_NORMAL: - if (dynamic_cast(&other)) { + //Ensure only fire destroys weakblock + if(bullet.get_type() == FIRE_BONUS) { startBurning(); + bullet.remove_me(); } - if (dynamic_cast (&other)) { - startBurning(); + //Other bullets ricochet + else { + bullet.ricochet(*this, hit); } - break; - + break; + case STATE_BURNING: case STATE_DISINTEGRATING: break; - + default: log_debug << "unhandled state" << std::endl; break; - } + } + + return FORCE_MOVE; +} +HitResponse +WeakBlock::collision(GameObject& other, const CollisionHit& hit) +{ + switch (state) { + + case STATE_NORMAL: + if (Bullet* bullet = dynamic_cast (&other)) { + return collision_bullet(*bullet, hit); + } + //Explosions destroy weakblocks as well + if (dynamic_cast (&other)) { + startBurning(); + } + break; + + case STATE_BURNING: + case STATE_DISINTEGRATING: + break; + + default: + log_debug << "unhandled state" << std::endl; + break; + } + return FORCE_MOVE; } @@ -60,26 +102,26 @@ void WeakBlock::update(float ) { switch (state) { - - case STATE_NORMAL: - break; - - case STATE_BURNING: - if (sprite->animation_done()) { - state = STATE_DISINTEGRATING; - sprite->set_action("disintegrating", 1); - spreadHit(); - set_group(COLGROUP_DISABLED); - } - break; - - case STATE_DISINTEGRATING: - if (sprite->animation_done()) { - remove_me(); - return; - } - break; - + + case STATE_NORMAL: + break; + + case STATE_BURNING: + if (sprite->animation_done()) { + state = STATE_DISINTEGRATING; + sprite->set_action("disintegrating", 1); + spreadHit(); + set_group(COLGROUP_DISABLED); + } + break; + + case STATE_DISINTEGRATING: + if (sprite->animation_done()) { + remove_me(); + return; + } + break; + } } @@ -94,19 +136,22 @@ WeakBlock::startBurning() void WeakBlock::spreadHit() { - Sector* sector = Sector::current(); - if (!sector) { - log_debug << "no current sector" << std::endl; - return; - } - for(Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); ++i) { - WeakBlock* wb = dynamic_cast(*i); - if (!wb) continue; - if (wb == this) continue; - if (wb->state != STATE_NORMAL) continue; - float dx = fabsf(wb->get_pos().x - this->get_pos().x); - float dy = fabsf(wb->get_pos().y - this->get_pos().y); - if ((dx <= 32.5) && (dy <= 32.5)) wb->startBurning(); + //Destroy adjacent weakblocks if applicable + if(linked) { + Sector* sector = Sector::current(); + if (!sector) { + log_debug << "no current sector" << std::endl; + return; + } + for(Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); ++i) { + WeakBlock* wb = dynamic_cast(*i); + if (!wb) continue; + if (wb == this) continue; + if (wb->state != STATE_NORMAL) continue; + float dx = fabsf(wb->get_pos().x - this->get_pos().x); + float dy = fabsf(wb->get_pos().y - this->get_pos().y); + if ((dx <= 32.5) && (dy <= 32.5)) wb->startBurning(); + } } } diff --git a/src/object/weak_block.hpp b/src/object/weak_block.hpp index dedd0a969..133b71334 100644 --- a/src/object/weak_block.hpp +++ b/src/object/weak_block.hpp @@ -20,6 +20,8 @@ #include "object/moving_sprite.hpp" #include "supertux/physic.hpp" +#include "object/bullet.hpp" + /** * A block that can be destroyed by Bullet hits @@ -31,7 +33,7 @@ public: HitResponse collision(GameObject& other, const CollisionHit& hit); void update(float elapsed_time); - + protected: /** * called by self when hit by a bullet @@ -50,6 +52,10 @@ private: STATE_DISINTEGRATING /**< crumbling to dust, no longer solid */ }; State state; + + bool linked; + virtual HitResponse collision_bullet(Bullet& bullet, const CollisionHit& hit); + }; #endif