From: Marek Moeckel Date: Sat, 17 Sep 2005 19:07:47 +0000 (+0000) Subject: kugelblitz electrifies water on contact - electrified water is baaaaaaad X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=43b2b952c4dd04d873d2fc92028ebeffdc22c05b;p=supertux.git kugelblitz electrifies water on contact - electrified water is baaaaaaad SVN-Revision: 2766 --- diff --git a/data/images/sprites.strf b/data/images/sprites.strf index 879e7c47a..fb396a4bf 100644 --- a/data/images/sprites.strf +++ b/data/images/sprites.strf @@ -1348,7 +1348,7 @@ (action (name "falling") (x-offset 0) - (y-offset ) + (y-offset 0) (images "creatures/kugelblitz/falling-0.png" "creatures/kugelblitz/falling-1.png" "creatures/kugelblitz/falling-2.png")) diff --git a/data/images/tiles.strf b/data/images/tiles.strf index c5a07aff7..dc87789af 100644 --- a/data/images/tiles.strf +++ b/data/images/tiles.strf @@ -1275,6 +1275,7 @@ "tiles/lava/lava1-4.png" ) (water #t) + (spike #t) (anim-fps 10) ) (tile @@ -1286,6 +1287,7 @@ "tiles/lava/lava2-4.png" ) (water #t) + (spike #t) (anim-fps 10) ) (tile @@ -5365,4 +5367,24 @@ ) (solid #t) ) + (tile + (id 1421) + (images + "tiles/water/electrified-0.png" + "tiles/water/electrified-1.png" + ) + (anim-fps 5) + (spike #t) + (water #t) + ) + (tile + (id 1422) + (images + "tiles/water/electrified_waves-0.png" + "tiles/water/electrified_waves-1.png" + ) + (anim-fps 5) + (spike #t) + (water #t) + ) ) diff --git a/data/images/tiles/water/electrified-0.png b/data/images/tiles/water/electrified-0.png new file mode 100644 index 000000000..a2eec75f5 Binary files /dev/null and b/data/images/tiles/water/electrified-0.png differ diff --git a/data/images/tiles/water/electrified-1.png b/data/images/tiles/water/electrified-1.png new file mode 100644 index 000000000..228eaa801 Binary files /dev/null and b/data/images/tiles/water/electrified-1.png differ diff --git a/data/images/tiles/water/electrified_waves-0.png b/data/images/tiles/water/electrified_waves-0.png new file mode 100644 index 000000000..62207e387 Binary files /dev/null and b/data/images/tiles/water/electrified_waves-0.png differ diff --git a/data/images/tiles/water/electrified_waves-1.png b/data/images/tiles/water/electrified_waves-1.png new file mode 100644 index 000000000..1744a14a1 Binary files /dev/null and b/data/images/tiles/water/electrified_waves-1.png differ diff --git a/data/levels/test/kugelblitz.stl b/data/levels/test/kugelblitz.stl index ba74f7d60..8b442fd8c 100644 --- a/data/levels/test/kugelblitz.stl +++ b/data/levels/test/kugelblitz.stl @@ -104,7 +104,7 @@ ) (poisonivy (x 800) (y 440)) (poisonivy (x 100) (y 438)) - (kugelblitz (x 519) (y 32)) + (kugelblitz (x 219) (y 32)) (kugelblitz (x 700) (y 32)) (kugelblitz (x 1100) (y 169)) ) diff --git a/data/levels/world2/dfk-level3.stl b/data/levels/world2/dfk-level3.stl index 2779035c9..d3c728666 100644 --- a/data/levels/world2/dfk-level3.stl +++ b/data/levels/world2/dfk-level3.stl @@ -4,8 +4,8 @@ (name (_ "Dark Forest Keep - The Black Tower")) (author "SuperTux Team") (sector - (name "main") - (music "darkforestkeep.ogg") + (name "main") + (music "darkforestkeep.ogg") (gravity 10.000000) (tilemap (layer "background") diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index f8303e04f..6c5824c9b 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -63,11 +63,31 @@ Kugelblitz::activate() HitResponse Kugelblitz::collision_solid(GameObject& , const CollisionHit& chit) { - //TODO: Explode when Tux is hit return hit(chit); } HitResponse +Kugelblitz::collision_player(Player& player, const CollisionHit& ) +{ + if(player.is_invincible()) { + explode(); + return ABORT_MOVE; + } + // hit from above? + if(player.get_movement().y - get_movement().y > 0 && player.get_bbox().p2.y < + (get_bbox().p1.y + get_bbox().p2.y) / 2) { + // if it's not is it possible to squish us, then this will hurt + if(!collision_squished(player)) + player.kill(Player::SHRINK); + explode(); + return FORCE_MOVE; + } + player.kill(Player::SHRINK); + explode(); + return FORCE_MOVE; +} + +HitResponse Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit) { //Let the Kugelblitz explode, too? @@ -104,13 +124,13 @@ Kugelblitz::hit(const CollisionHit& chit) void Kugelblitz::active_update(float elapsed_time) { - if (lifetime.check()) { - if (!dying) { - sprite->set_action("pop"); - lifetime.start(0.2); - dying = true; - } - else remove_me(); + if (electrify_timer.check()) { + Sector::current()->solids->change_all(1421,75); + Sector::current()->solids->change_all(1422,76); + explode(); + } + else if (lifetime.check()) { + explode(); } else { if (groundhit_pos_set) { @@ -123,6 +143,11 @@ Kugelblitz::active_update(float elapsed_time) } if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) { //HIT WATER + Sector::current()->solids->change_all(75,1421); + Sector::current()->solids->change_all(76,1422); + physic.set_velocity_x(0); + physic.set_velocity_y(0); + electrify_timer.start(1); } } BadGuy::active_update(elapsed_time); @@ -133,4 +158,15 @@ Kugelblitz::kill_fall() { } +void +Kugelblitz::explode() +{ + if (!dying) { + sprite->set_action("pop"); + lifetime.start(0.2); + dying = true; + } + else remove_me(); +} + IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz") diff --git a/src/badguy/kugelblitz.hpp b/src/badguy/kugelblitz.hpp index d63092207..5e591207b 100644 --- a/src/badguy/kugelblitz.hpp +++ b/src/badguy/kugelblitz.hpp @@ -29,12 +29,14 @@ public: Kugelblitz(const lisp::Lisp& reader); void activate(); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_player(Player& player, const CollisionHit& hit); void write(lisp::Writer& writer); void active_update(float); void kill_fall(); + void explode(); private: HitResponse hit(const CollisionHit& hit); @@ -43,6 +45,7 @@ private: bool dying; Timer movement_timer; Timer lifetime; + Timer electrify_timer; int direction; }; diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index d37ae5c32..8775418a6 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -281,4 +281,13 @@ TileMap::change_at(const Vector& pos, uint32_t newtile) change(int(pos.x)/32, int(pos.y)/32, newtile); } +void +TileMap::change_all(uint32_t oldtile, uint32_t newtile) +{ + for (size_t x = 0; x < get_width(); x++) + for (size_t y = 0; y < get_height(); y++) { + if (get_tile(x,y)->getID() == oldtile) change(x,y,newtile); + } +} + IMPLEMENT_FACTORY(TileMap, "tilemap"); diff --git a/src/object/tilemap.hpp b/src/object/tilemap.hpp index dcd74788d..e344fa097 100644 --- a/src/object/tilemap.hpp +++ b/src/object/tilemap.hpp @@ -79,6 +79,9 @@ public: void change_at(const Vector& pos, uint32_t newtile); + /// changes all tiles with the given ID + void change_all(uint32_t oldtile, uint32_t newtile); + TileManager* get_tilemanager() const { return tilemanager; diff --git a/src/sector.cpp b/src/sector.cpp index cb20718a8..5ff6b03ec 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -56,7 +56,6 @@ #include "object/bullet.hpp" #include "object/text_object.hpp" #include "badguy/jumpy.hpp" -#include "badguy/spike.hpp" #include "trigger/sequence_trigger.hpp" #include "player_status.hpp" #include "scripting/script_interpreter.hpp"