From: Marek Moeckel Date: Thu, 25 Nov 2004 11:16:03 +0000 (+0000) Subject: added badguy Nolok_01, as he may appear as the boss of world 1 (still very basic). X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;ds=inline;h=f1c7a49dd18ff59d0d32bd118044402ff35f66f5;p=supertux.git added badguy Nolok_01, as he may appear as the boss of world 1 (still very basic). added sprite "Dummyguy" which can be used for badguys that don't have sprites yet (i.e. nolok and dispenser). added new test level "noloktest.stl", moved dispenser and secretarea tests to that level. Bugs: Nolok can only be killed when he's jumping; no idea why, probably set the offsets wrong. Also, currently there's no limit on how many snowballs he can throw, so kill him quickly :-) This is the last thing I'll add before fixing all my other stuff. :-) SVN-Revision: 2184 --- diff --git a/data/images/shared/dummyguy-dead.png b/data/images/shared/dummyguy-dead.png new file mode 100644 index 000000000..97b8b31ed Binary files /dev/null and b/data/images/shared/dummyguy-dead.png differ diff --git a/data/images/shared/dummyguy-jump.png b/data/images/shared/dummyguy-jump.png new file mode 100644 index 000000000..8dfd3c978 Binary files /dev/null and b/data/images/shared/dummyguy-jump.png differ diff --git a/data/images/shared/dummyguy-stand.png b/data/images/shared/dummyguy-stand.png new file mode 100644 index 000000000..f9fad5617 Binary files /dev/null and b/data/images/shared/dummyguy-stand.png differ diff --git a/data/images/shared/dummyguy-throw.png b/data/images/shared/dummyguy-throw.png new file mode 100644 index 000000000..9db938380 Binary files /dev/null and b/data/images/shared/dummyguy-throw.png differ diff --git a/data/images/shared/dummyguy-walk-1.png b/data/images/shared/dummyguy-walk-1.png new file mode 100644 index 000000000..5a18bc50e Binary files /dev/null and b/data/images/shared/dummyguy-walk-1.png differ diff --git a/data/images/shared/dummyguy-walk-2.png b/data/images/shared/dummyguy-walk-2.png new file mode 100644 index 000000000..3ad44a49c Binary files /dev/null and b/data/images/shared/dummyguy-walk-2.png differ diff --git a/data/images/supertux.strf b/data/images/supertux.strf index c20e1799f..f689b0540 100644 --- a/data/images/supertux.strf +++ b/data/images/supertux.strf @@ -1107,7 +1107,48 @@ (x-offset 0) (y-offset 0) (images "shared/walkingtree-left-small-1.png"))) + + ; Dummyguy + (sprite (name "dummyguy") + (action + (name "left") + (x-offset 0) + (y-offset 32) + (images "shared/dummyguy-walk-1.png" + "shared/dummyguy-walk-2.png")) + + (action + (name "right") + (x-offset 0) + (y-offset 32) + (mirror-action "left")) + + (action + (name "stand") + (x-offset 0) + (y-offset 32) + (images "shared/dummyguy-stand.png")) + + (action + (name "throw") + (x-offset 0) + (y-offset 32) + (images "shared/dummyguy-throw.png")) + + (action + (name "jump") + (x-offset 0) + (y-offset 32) + (images "shared/dummyguy-jump.png")) + + (action + (name "dead") + (x-offset 0) + (y-offset 32) + (images "shared/dummyguy-dead.png"))) + + ;; Game elements follow (sprite (name "egg") diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index 842c3f634..cf8cdadef 100644 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -9,8 +9,6 @@ (gravity 10.000000) (background (image "arctis.jpg") (speed 0.5)) - (secretarea (x 400) (y 128) (message "You found a secret area!")) - (dispenser (x 500) (y 128) (badguy "bouncingsnowball") (cycle 2)) (spawn-points (name "main") (x 100) diff --git a/data/levels/test/noloktest.stl b/data/levels/test/noloktest.stl new file mode 100644 index 000000000..3d5ca7025 --- /dev/null +++ b/data/levels/test/noloktest.stl @@ -0,0 +1,83 @@ +; Level made using SuperTux's built-in Level Editor +(supertux-level + (version 2) + (name "Nolok Test") + (author "Marek") + (time 500) + (end-sequence-animation "none") + (sector + (name "main") + (gravity 10) + (background (image "forest1.jpg") + (speed 0.5)) + (music "Mortimers_chipdisko.mod") + (spawn-points (name "main") (x 100) (y 512)) + (nolok_01 (x 650) (y 512)) + (tilemap + (layer "background") + (solid #f) + (speed 1) + (width 25) + (height 19) + (tiles 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 68 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 68) + ) + (tilemap + (layer "foreground") + (solid #f) + (speed 1) + (width 25) + (height 19) + (tiles 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) + ) + (camera + (mode "normal") + (backscrolling #t) + ) + ) + (sector + (name "sector1") + (gravity 10) + (music "Mortimers_chipdisko.mod") + (background (image "forest1.jpg") + (speed 0.5)) + (spawn-points (name "main2") (x 100) (y 100)) + (secretarea (x 100) (y 100) (message "You found a secret area!")) + (dispenser (x 700) (y 500) (badguy "snowball") (cycle 2)) + (tilemap + (layer "background") + (solid #f) + (speed 1) + (width 25) + (height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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 21 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 22 20 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 23) + ) + (tilemap + (layer "foreground") + (solid #f) + (speed 1) + (width 25) + (height 19) + (tiles 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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ball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -11,14 +11,17 @@ BouncingSnowball::BouncingSnowball(LispReader& reader) reader.read_float("y", start_position.y); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("bouncingsnowball"); + set_direction = false; } -BouncingSnowball::BouncingSnowball(float pos_x, float pos_y) +BouncingSnowball::BouncingSnowball(float pos_x, float pos_y, Direction d) { start_position.x = pos_x; start_position.y = pos_y; bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("bouncingsnowball"); + set_direction = true; + initial_direction = d; } void @@ -35,6 +38,7 @@ BouncingSnowball::write(LispWriter& writer) void BouncingSnowball::activate() { + if (set_direction) {dir = initial_direction;} physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } diff --git a/src/badguy/bouncing_snowball.h b/src/badguy/bouncing_snowball.h index 7aea25dae..4bb4d862c 100644 --- a/src/badguy/bouncing_snowball.h +++ b/src/badguy/bouncing_snowball.h @@ -7,7 +7,7 @@ class BouncingSnowball : public BadGuy { public: BouncingSnowball(LispReader& reader); - BouncingSnowball(float pos_x, float pos_y); + BouncingSnowball(float pos_x, float pos_y, Direction d); void activate(); void write(LispWriter& writer); @@ -15,6 +15,8 @@ public: protected: bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; }; #endif diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 1f62e61fd..2975c1a89 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -13,7 +13,8 @@ Dispenser::Dispenser(LispReader& reader) reader.read_string("badguy", badguy); bbox.set_size(32, 32); //FIXME: Create dispenser sprite - sprite = sprite_manager->create("snowball"); + sprite = sprite_manager->create("dummyguy"); + sprite->set_action("stand"); } void @@ -69,6 +70,7 @@ Dispenser::collision_solid(GameObject& , const CollisionHit& hit) //TODO: Add launching velocity to badguys // Add more badguys and randomizer // Clean up stuff I copied without understanding what it does :) +// Stop dispensing when game is paused // Lots-O-Stuff (tm) void Dispenser::launch_badguy() @@ -78,7 +80,7 @@ Dispenser::launch_badguy() if (badguy == "snowball") Sector::current()->add_object(new SnowBall(get_pos().x-2, get_pos().y)); else if (badguy == "bouncingsnowball") - Sector::current()->add_object(new BouncingSnowball(get_pos().x-2, get_pos().y)); + Sector::current()->add_object(new BouncingSnowball(get_pos().x-2, get_pos().y, dir)); else if (badguy == "random") {} } diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp new file mode 100644 index 000000000..4bbc14e73 --- /dev/null +++ b/src/badguy/nolok_01.cpp @@ -0,0 +1,92 @@ +#include + +#include "nolok_01.h" +#include "badguy/bouncing_snowball.h" +#include "trigger/door.h" + +#define SHOOT_TIME 2.5 +#define IDLE_TIME 0.4 +#define JUMP_TIME 0.3 + +static const float WALKSPEED = 80; + +//TODO: Create sprite, give multiple hitpoints, limit max number of snowballs +// Can only be killed when jumping, no idea why +Nolok_01::Nolok_01(LispReader& reader) +{ + reader.read_float("x", start_position.x); + reader.read_float("y", start_position.y); + bbox.set_size(31.8, 31.8); + sprite = sprite_manager->create("dummyguy"); +} + +Nolok_01::Nolok_01(float pos_x, float pos_y) +{ + start_position.x = pos_x; + start_position.y = pos_y; + bbox.set_size(31.8, 31.8); + sprite = sprite_manager->create("dummyguy"); +} + +void +Nolok_01::write(LispWriter& writer) +{ + writer.start_list("nolok01"); + + writer.write_float("x", get_pos().x); + writer.write_float("y", get_pos().y); + + writer.end_list("nolok01"); +} + +void +Nolok_01::activate() +{ + physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); + sprite->set_action(dir == LEFT ? "left" : "right"); + action_timer.start(SHOOT_TIME, true); +} + +void +Nolok_01::active_action(float elapsed_time) +{ + movement = physic.get_movement(elapsed_time); + if (action_timer.check()) { + physic.set_velocity_y(700); + jump_timer.start(JUMP_TIME); + } + if (jump_timer.check()) { + sprite->set_action("throw"); + idle_timer.start(IDLE_TIME); + } + if (idle_timer.check()) { + Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT)); + Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT)); + physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); + sprite->set_action(dir == LEFT ? "left" : "right"); + } +} + +bool +Nolok_01::collision_squished(Player& player) +{ + sprite->set_action("dead"); + kill_squished(player); + Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2")); + return true; +} + +HitResponse +Nolok_01::collision_solid(GameObject& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.y) > .5) { // hit floor or roof? + //physic.set_velocity_y(0); + } else { // hit right or left + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + diff --git a/src/badguy/nolok_01.h b/src/badguy/nolok_01.h new file mode 100644 index 000000000..4049892db --- /dev/null +++ b/src/badguy/nolok_01.h @@ -0,0 +1,26 @@ +#ifndef __NOLOK01_H__ +#define __NOLOK01_H__ + +#include "badguy.h" +#include "timer.h" + +class Nolok_01 : public BadGuy +{ +public: + Nolok_01(LispReader& reader); + Nolok_01(float pos_x, float pos_y); + + void activate(); + void write(LispWriter& writer); + void active_action(float elapsed_time); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + Timer2 action_timer; + Timer2 idle_timer; + Timer2 jump_timer; +}; + +#endif + diff --git a/src/sector.cpp b/src/sector.cpp index 809b119b0..f5609fdae 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -55,6 +55,7 @@ #include "badguy/mrbomb.h" #include "badguy/dispenser.h" #include "badguy/spike.h" +#include "badguy/nolok_01.h" #include "trigger/door.h" #include "trigger/sequence_trigger.h" #include "trigger/secretarea_trigger.h" @@ -158,6 +159,8 @@ Sector::parse_object(const std::string& name, LispReader& reader) return new Dispenser(reader); } else if(name == "spike") { return new Spike(reader); + } else if(name == "nolok_01") { + return new Nolok_01(reader); } #if 0 else if(badguykind_from_string(name) != BAD_INVALID) { diff --git a/src/trigger/door.cpp b/src/trigger/door.cpp index 1d576aee3..43a4b291d 100644 --- a/src/trigger/door.cpp +++ b/src/trigger/door.cpp @@ -42,10 +42,12 @@ Door::Door(LispReader& reader) sprite = sprite_manager->create("door"); } -Door::Door(int x, int y) +Door::Door(int x, int y, std::string sector, std::string spawnpoint) { bbox.set_pos(Vector(x, y)); bbox.set_size(32, 64); + target_sector = sector; + target_spawnpoint = spawnpoint; sprite = sprite_manager->create("door"); } diff --git a/src/trigger/door.h b/src/trigger/door.h index 151773561..abcff6706 100644 --- a/src/trigger/door.h +++ b/src/trigger/door.h @@ -31,7 +31,7 @@ class Door : public TriggerBase, public Serializable { public: Door(LispReader& reader); - Door(int x, int y); + Door(int x, int y, std::string sector, std::string spawnpoint); virtual ~Door(); virtual void write(LispWriter& writer);