(spawnpoint (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))
+ (jumpy (x 500) (y 400))
(tilemap
(layer "background")
(solid #f)
BadGuy::BadGuy()
: sprite(0), dir(LEFT), state(STATE_INIT)
{
+ hitpoints = 1;
}
BadGuy::~BadGuy()
return ABORT_MOVE;
}
if(hit.normal.y > .9) {
+ //TODO: fix inaccuracy (tux sometimes dies even if badguy was hit)
+ // give badguys some invincible time (prevent them from being hit multiple times)
+ // use hitpoints also when hit by fireball or invincible tux
+ hitpoints--;
+ std::cout << "Hitpoints: " << hitpoints << std::endl;
if(collision_squished(player))
return ABORT_MOVE;
+ else if (hitpoints <= 0) {
+ player.kill(Player::SHRINK);
+ return FORCE_MOVE;
+ }
}
player.kill(Player::SHRINK);
return FORCE_MOVE;
#define WALK_TIME 2.5
#define SHOOT_TIME 0.4
#define JUMP_TIME 0.5
+#define INITIAL_HITPOINTS 3
static const float WALKSPEED = 90;
-//TODO: Create sprite, give multiple hitpoints, limit max number of snowballs
+//TODO: Create sprite, limit max number of snowballs
// Stop actions when pause button is hit (probably a general problem of timers)
Nolok_01::Nolok_01(const lisp::Lisp& reader)
{
void
Nolok_01::activate()
{
+ hitpoints = INITIAL_HITPOINTS;
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
action = WALKING;
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;
+ bool result = false;
+ player.bounce(*this);
+ if (hitpoints <= 0) {
+ sprite->set_action("dead");
+ kill_squished(player);
+ Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2"));
+ result = true;
+ }
+ return result;
}
HitResponse
return CONTINUE;
}
-IMPLEMENT_FACTORY(Nolok_01, "nolok01")
+IMPLEMENT_FACTORY(Nolok_01, "nolok_01")