- implement wingling
- implement tree (really?)
- bring back stay on platform flag
- - make enemies bounce of upon each other again
- - make enemies fall again - ok
** implement ability to cary mriceblock (and other objects) around - delayed
for after big commit...
* smoke clouds are too fast
return collision_solid(other, hit);
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
- if(badguy)
+ if(badguy && badguy->state == STATE_ACTIVE)
return collision_badguy(*badguy, hit);
Player* player = dynamic_cast<Player*> (&other);
return ABORT_MOVE;
}
+HitResponse
+Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& )
+{
+ badguy.kill_fall();
+ return ABORT_MOVE;
+}
+
void
Bomb::active_action(float )
{
void write(lisp::Writer& writer);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
HitResponse collision_player(Player& player, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
void active_action(float elapsed_time);
void kill_fall();
return CONTINUE;
}
+HitResponse
+BouncingSnowball::collision_badguy(BadGuy& , const CollisionHit& hit)
+{
+ if(fabsf(hit.normal.x) > .8) { // left/right?
+ dir = dir == LEFT ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ } else if(hit.normal.y < -.8) { // grounf
+ physic.set_velocity_y(JUMPSPEED);
+ }
+
+ return CONTINUE;
+}
+
void activate();
void write(lisp::Writer& writer);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
protected:
bool collision_squished(Player& player);
}
HitResponse
-Jumpy::collision_solid(GameObject& , const CollisionHit& hit)
+Jumpy::collision_solid(GameObject& , const CollisionHit& chit)
+{
+ return hit(chit);
+}
+
+HitResponse
+Jumpy::collision_badguy(BadGuy& , const CollisionHit& chit)
+{
+ return hit(chit);
+}
+
+HitResponse
+Jumpy::hit(const CollisionHit& chit)
{
// hit floor?
- if(hit.normal.y < -.5) {
+ if(chit.normal.y < -.5) {
physic.set_velocity_y(JUMPSPEED);
- } else if(hit.normal.y < .5) { // bumped on roof
+ } else if(chit.normal.y < .5) { // bumped on roof
physic.set_velocity_y(0);
}
return CONTINUE;
}
-
public:
Jumpy(const lisp::Lisp& reader);
- virtual HitResponse collision_solid(GameObject& other,
- const CollisionHit& hit);
+ HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
- virtual void write(lisp::Writer& writer);
+ void write(lisp::Writer& writer);
+
+private:
+ HitResponse hit(const CollisionHit& hit);
};
#endif
return CONTINUE;
}
+HitResponse
+MrBomb::collision_badguy(BadGuy& , const CollisionHit& hit)
+{
+ if(fabsf(hit.normal.x) > .8) { // left or right
+ dir = dir == LEFT ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+
+ return CONTINUE;
+}
void activate();
void write(lisp::Writer& writer);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
protected:
bool collision_squished(Player& player);
#include <config.h>
#include "mriceblock.h"
+#include "object/block.h"
static const float WALKSPEED = 80;
static const float KICKSPEED = 500;
}
HitResponse
-MrIceBlock::collision_solid(GameObject& , const CollisionHit& hit)
+MrIceBlock::collision_solid(GameObject& object, const CollisionHit& hit)
{
if(fabsf(hit.normal.y) > .5) { // floor or roof
physic.set_velocity_y(0);
sprite->set_action(dir == LEFT ? "left" : "right");
physic.set_velocity_x(-physic.get_velocity_x());
break;
- case ICESTATE_KICKED:
+ case ICESTATE_KICKED: {
+ BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object);
+ if(bonusblock) {
+ bonusblock->try_open();
+ }
+ Brick* brick = dynamic_cast<Brick*> (&object);
+ if(brick) {
+ brick->try_break();
+ }
+
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
physic.set_velocity_x(-physic.get_velocity_x());
SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(),
Sector::current()->player->get_pos());
break;
+ }
case ICESTATE_FLAT:
physic.set_velocity_x(0);
break;
return CONTINUE;
}
+HitResponse
+MrIceBlock::collision_badguy(BadGuy& badguy, const CollisionHit& hit)
+{
+ switch(ice_state) {
+ case ICESTATE_NORMAL:
+ if(fabsf(hit.normal.x) > .8) {
+ dir = dir == LEFT ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+ return CONTINUE;
+ case ICESTATE_FLAT:
+ return FORCE_MOVE;
+ case ICESTATE_KICKED:
+ badguy.kill_fall();
+ return FORCE_MOVE;
+ default:
+ assert(false);
+ }
+
+ return ABORT_MOVE;
+}
+
bool
MrIceBlock::collision_squished(Player& player)
{
void activate();
void write(lisp::Writer& writer);
- HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_solid(GameObject& object, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
void active_action(float elapsed_time);
return CONTINUE;
}
+HitResponse
+SnowBall::collision_badguy(BadGuy& , const CollisionHit& hit)
+{
+ if(fabsf(hit.normal.x) > .8) { // left or right hit
+ dir = dir == LEFT ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+
+ return CONTINUE;
+}
+
void activate();
void write(lisp::Writer& writer);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
protected:
bool collision_squished(Player& player);
return CONTINUE;
}
+HitResponse
+Spiky::collision_badguy(BadGuy& , const CollisionHit& hit)
+{
+ if(fabsf(hit.normal.x) > .8) { // left or right
+ dir = dir == LEFT ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+
+ return CONTINUE;
+}
+
void activate();
void write(lisp::Writer& writer);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
};
#endif
}
void
-BonusBlock::hit(Player& player)
+BonusBlock::hit(Player& )
+{
+ try_open();
+}
+
+void
+BonusBlock::try_open()
{
if(sprite->get_action_name() == "empty") {
SoundManager::get()->play_sound(IDToSound(SND_BRICK));
}
Sector* sector = Sector::current();
+ Player& player = *(sector->player);
switch(data) {
case 1: // coin
Sector::current()->add_object(new BouncyCoin(get_pos()));
}
void
-Brick::hit(Player& player)
+Brick::hit(Player& )
+{
+ if(sprite->get_action_name() == "empty")
+ return;
+
+ try_break(true);
+}
+
+void
+Brick::try_break(bool playerhit)
{
if(sprite->get_action_name() == "empty")
return;
SoundManager::get()->play_sound(IDToSound(SND_BRICK));
Sector* sector = Sector::current();
+ Player& player = *(sector->player);
if(coin_counter > 0) {
sector->add_object(new BouncyCoin(get_pos()));
coin_counter--;
sprite->set_action("empty");
start_bounce();
} else if(breakable) {
- if(player.size == SMALL) {
+ if(playerhit && player.size == SMALL) {
start_bounce();
return;
}
public:
BonusBlock(const Vector& pos, int data);
+ void try_open();
+
protected:
virtual void hit(Player& player);
public:
Brick(const Vector& pos, int data);
+ void try_break(bool playerhit = false);
+
protected:
virtual void hit(Player& player);