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
(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")
(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)
--- /dev/null
+; 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 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 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 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 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 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(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 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 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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)
+ )
+ )
+)
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
void
BouncingSnowball::activate()
{
+ if (set_direction) {dir = initial_direction;}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
{
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);
protected:
bool collision_squished(Player& player);
+ bool set_direction;
+ Direction initial_direction;
};
#endif
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
//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()
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")
{}
}
--- /dev/null
+#include <config.h>
+
+#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;
+}
+
--- /dev/null
+#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
+
#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"
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) {
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");
}
{
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);