Next time, please don't implement it, unless you do it properly.
SVN-Revision: 1705
void
Trampoline::draw(DrawingContext& context)
{
- img_trampoline[frame]->draw(context, Vector(base.x, base.y), LAYER_OBJECTS);
+ img_trampoline[frame]->draw(context, base, LAYER_OBJECTS);
frame = 0;
}
void
FlyingPlatform::draw(DrawingContext& context)
{
- img_flying_platform->draw(context, Vector(base.x, base.y), LAYER_OBJECTS);
+ img_flying_platform->draw(context, base, LAYER_OBJECTS);
}
void
}
}
+Sprite *img_smoke_cloud;
+
+SmokeCloud::SmokeCloud(const Vector& pos)
+ : position(pos)
+{
+ timer.start(250);
+}
+
+void
+SmokeCloud::action(float elapsed_time)
+{
+ position.y -= 2 * elapsed_time;
+
+ if(!timer.check())
+ remove_me();
+}
+
+void
+SmokeCloud::draw(DrawingContext& context)
+{
+ img_smoke_cloud->draw(context, position, LAYER_OBJECTS+1);
+}
+
void load_object_gfx()
{
char sprite_name[16];
}
img_flying_platform = sprite_manager->load("flying_platform");
+
+ img_smoke_cloud = sprite_manager->load("stomp");
}
unsigned int frame;
};
+extern Sprite *img_smoke_cloud;
+
+class SmokeCloud : public GameObject
+{
+public:
+ SmokeCloud(const Vector& pos);
+
+ virtual void action(float elapsed_time);
+ virtual void draw(DrawingContext& context);
+
+private:
+ Timer timer;
+ Vector position;
+};
+
void load_object_gfx();
#endif
#define TILES_FOR_BUTTJUMP 3
// animation times (in ms):
#define SHOOTING_TIME 320
-#define STOMP_TIME 250
// others stuff:
#define AUTOSCROLL_DEAD_INTERVAL 300
can_jump = true;
butt_jump = false;
- stomp_pos = Vector(0,0);
frame_main = 0;
frame_ = 0;
// Do butt jump
if (butt_jump && on_ground() && size == BIG)
{
-
+ // Add a smoke cloud
if (duck)
- stomp_pos = Vector(base.x - 32, base.y);
+ Sector::current()->add_smoke_cloud(Vector(base.x - 32, base.y));
else
- stomp_pos = Vector(base.x - 32, base.y + 32);
- stomp_timer.start(STOMP_TIME);
+ Sector::current()->add_smoke_cloud(Vector(base.x - 32, base.y + 32));
butt_jump = false;
sprite->grab_left->draw(context, pos, LAYER_OBJECTS + 1);
}
- // Draw stomp clouds when doing a butt jump
- if (stomp_timer.check())
- sprite->stomp->draw(context, stomp_pos, LAYER_OBJECTS + 1);
-
// Draw blinking star overlay
if (invincible_timer.started() &&
(invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3))
Sprite* grab_right;
Sprite* duck_right;
Sprite* duck_left;
- Sprite* stomp;
};
extern PlayerSprite smalltux;
Timer shooting_timer; // used to show the arm when Tux is shooting
Timer dying_timer;
Timer growing_timer;
- Timer stomp_timer;
Physic physic;
- Vector stomp_pos;
-
public:
Player();
virtual ~Player();
smalltux.skid_right = sprite_manager->load("smalltux-skid-right");
smalltux.grab_left = sprite_manager->load("smalltux-grab-left");
smalltux.grab_right = sprite_manager->load("smalltux-grab-right");
- smalltux.stomp = sprite_manager->load("stomp");
largetux.stand_left = sprite_manager->load("largetux-stand-left");
largetux.stand_right = sprite_manager->load("largetux-stand-right");
largetux.grab_right = sprite_manager->load("largetux-grab-right");
largetux.duck_left = sprite_manager->load("largetux-duck-left");
largetux.duck_right = sprite_manager->load("largetux-duck-right");
- largetux.stomp = sprite_manager->load("stomp");
firetux.stand_left = sprite_manager->load("firetux-stand-left");
firetux.stand_right = sprite_manager->load("firetux-stand-right");
firetux.grab_right = sprite_manager->load("firetux-grab-right");
firetux.duck_left = sprite_manager->load("firetux-duck-left");
firetux.duck_right = sprite_manager->load("firetux-duck-right");
- firetux.stomp = sprite_manager->load("stomp");
icetux.stand_left = sprite_manager->load("icetux-stand-left");
icetux.stand_right = sprite_manager->load("icetux-stand-right");
icetux.grab_right = sprite_manager->load("icetux-grab-right");
icetux.duck_left = sprite_manager->load("icetux-duck-left");
icetux.duck_right = sprite_manager->load("icetux-duck-right");
- icetux.stomp = sprite_manager->load("stomp");
-
/* Water: */
img_water = new Surface(datadir + "/images/shared/water.png", false);
std::remove(flying_platforms.begin(), flying_platforms.end(), flying_platform),
flying_platforms.end());
}
+ SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i);
+ if(smoke_cloud) {
+ smoke_clouds.erase(
+ std::remove(smoke_clouds.begin(), smoke_clouds.end(), smoke_cloud),
+ smoke_clouds.end());
+ }
delete *i;
i = gameobjects.erase(i);
= dynamic_cast<InteractiveObject*> (*i);
if(interactive_object)
interactive_objects.push_back(interactive_object);
+ SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i);
+ if(smoke_cloud)
+ smoke_clouds.push_back(smoke_cloud);
+
gameobjects.push_back(*i);
}
return true;
}
+bool
+Sector::add_smoke_cloud(const Vector& pos)
+{
+ add_object(new SmokeCloud(pos));
+ return true;
+}
+
/* Break a brick: */
bool
Sector::trybreakbrick(const Vector& pos, bool small)
class TileMap;
class Upgrade;
class Bullet;
+class SmokeCloud;
class BadGuy;
class Tile;
void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
bool add_bullet(const Vector& pos, float xm, Direction dir);
+ bool add_smoke_cloud(const Vector& pos);
/** Try to grab the coin at the given coordinates */
void trygrabdistro(const Vector& pos, int bounciness);
std::vector<Upgrade*> upgrades;
std::vector<Bullet*> bullets;
+ std::vector<SmokeCloud*> smoke_clouds;
public: // ugly
typedef std::vector<InteractiveObject*> InteractiveObjects;