*/
virtual void save(lisp::Writer& writer);
+ /**
+ * True if this badguy can break bricks or open bonusblocks in his current form.
+ */
+ virtual bool can_break()
+ {
+ return false;
+ }
+
Vector get_start_position() const
{
return start_position;
BadGuy::active_update(elapsed_time);
}
+bool
+MrIceBlock::can_break(){
+ return ice_state == ICESTATE_KICKED;
+}
+
void
MrIceBlock::collision_solid(const CollisionHit& hit)
{
WalkingBadguy::collision_solid(hit);
break;
case ICESTATE_KICKED: {
-#if 0
- // TODO move these into bonusblock class
- BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object);
- if(bonusblock) {
- bonusblock->try_open();
- }
- Brick* brick = dynamic_cast<Brick*> (&object);
- if(brick) {
- brick->try_break();
- }
-#endif
if(hit.right && dir == RIGHT) {
dir = LEFT;
sound_manager->play("sounds/iceblock_bump.wav", get_pos());
void grab(MovingObject& object, const Vector& pos, Direction dir);
void ungrab(MovingObject& object, Direction dir);
+ bool can_break();
virtual MrIceBlock* clone() const { return new MrIceBlock(*this); }
kicked_delay_timer.start(0.05);
}
+bool
+Snail::can_break(){
+ return state == STATE_KICKED;
+}
void
Snail::active_update(float elapsed_time)
if(hit.left || hit.right) {
sound_manager->play("sounds/iceblock_bump.wav", get_pos());
-#if 0
- // TODO move this into BonusBlock code
- // open bonusblocks, crash bricks
- BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object);
- if(bonusblock) {
- bonusblock->try_open();
- }
- Brick* brick = dynamic_cast<Brick*> (&object);
- if(brick) {
- brick->try_break();
- }
-#endif
if( ( dir == LEFT && hit.left ) || ( dir == RIGHT && hit.right) ){
dir = (dir == LEFT) ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
+ bool can_break();
void active_update(float elapsed_time);
try_open();
}
+HitResponse
+BonusBlock::collision(GameObject& other, const CollisionHit& hit){
+ BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
+ if(badguy) {
+ // if( badguy->can_break() && (hit.left||hit.right||hit.bottom) ){ //TODO: find out why hit contains no information and fix it
+ if( badguy->can_break() && ( badguy->get_pos().y > get_pos().y ) ){
+ try_open();
+ }
+ }
+ return Block::collision(other, hit);
+}
+
void
BonusBlock::try_open()
{
try_break(true);
}
+HitResponse
+Brick::collision(GameObject& other, const CollisionHit& hit){
+ BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
+ if(badguy) {
+ // if( badguy->can_break() && (hit.left||hit.right||hit.bottom) ){ //TODO: find out why hit contains no information and fix it
+ if( badguy->can_break() && ( badguy->get_pos().y > get_pos().y ) ){
+ try_break(false);
+ }
+ }
+ return Block::collision(other, hit);
+}
+
void
Brick::try_break(bool playerhit)
{
BonusBlock(const Vector& pos, int data);
BonusBlock(const lisp::Lisp& lisp);
virtual ~BonusBlock();
+ HitResponse collision(GameObject& other, const CollisionHit& hit);
void try_open();
Brick(const Vector& pos, int data);
void try_break(bool playerhit = false);
+ HitResponse collision(GameObject& other, const CollisionHit& hit);
protected:
virtual void hit(Player& player);