Update of /cvsroot/super-tux/supertux/src/object
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16564/src/object
Modified Files:
block.cpp coin.cpp coin.h
Log Message:
some cleanups in the sprite class, increased delta for collision response
Index: coin.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/coin.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- coin.cpp 23 Nov 2004 16:47:26 -0000 1.2
+++ coin.cpp 24 Nov 2004 23:10:07 -0000 1.3
@@ -5,7 +5,9 @@
#include "video/drawing_context.h"
#include "special/sprite_manager.h"
#include "player.h"
+#include "sector.h"
#include "scene.h"
+#include "gameobjs.h"
Coin::Coin(const Vector& pos)
{
@@ -30,6 +32,14 @@
sprite->draw(context, get_pos(), LAYER_TILES);
}
+void
+Coin::collect()
+{
+ Sector::current()->player->get_status().incCoins();
+ Sector::current()->add_object(new BouncyCoin(get_pos()));
+ remove_me();
+}
+
HitResponse
Coin::collision(GameObject& other, const CollisionHit& )
{
@@ -37,8 +47,7 @@
if(player == 0)
return ABORT_MOVE;
- player->get_status().incCoins();
- remove_me();
+ collect();
return ABORT_MOVE;
}
Index: block.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/block.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- block.cpp 24 Nov 2004 14:10:27 -0000 1.5
+++ block.cpp 24 Nov 2004 23:10:05 -0000 1.6
@@ -13,6 +13,8 @@
#include "flower.h"
#include "oneup.h"
#include "star.h"
+#include "badguy/badguy.h"
+#include "coin.h"
static const float BOUNCY_BRICK_MAX_OFFSET=8;
static const float BOUNCY_BRICK_SPEED=90;
@@ -35,8 +37,6 @@
HitResponse
Block::collision(GameObject& other, const CollisionHit& hitdata)
{
- // TODO kill badguys when bumping them...
-
Player* player = dynamic_cast<Player*> (&other);
if(player) {
// collided from below?
@@ -45,6 +45,17 @@
}
}
+ if(bouncing) {
+ BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
+ if(badguy) {
+ badguy->kill_fall();
+ }
+ Coin* coin = dynamic_cast<Coin*> (&other);
+ if(coin) {
+ coin->collect();
+ }
+ }
+
return FORCE_MOVE;
}
Index: coin.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/coin.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- coin.h 20 Nov 2004 22:14:40 -0000 1.1
+++ coin.h 24 Nov 2004 23:10:07 -0000 1.2
@@ -19,6 +19,8 @@
virtual void action(float elapsed_time);
virtual void draw(DrawingContext& context);
+ void collect();
+
private:
Sprite* sprite;
};
|