#include "screen.h"
#define AUTOSCROLL_DEAD_INTERVAL 300
+// animation times (in ms):
+#define SHOOTING_TIME 320
Surface* tux_life;
safe_timer.init(true);
frame_timer.init(true);
kick_timer.init(true);
+ shooting_timer.init(true);
physic.reset();
}
/* Shoot! */
if (input.fire == DOWN && input.old_fire == UP && got_power != NONE_POWER)
{
- World::current()->add_bullet(Vector(base.x, base.y + (base.height/2)),
- physic.get_velocity_x(), dir);
+ if(World::current()->add_bullet(Vector(base.x, base.y + (base.height/2)),
+ physic.get_velocity_x(), dir))
+ shooting_timer.start(SHOOTING_TIME);
input.old_fire = DOWN;
}
if(layer == LAYER_OBJECTS + 1) {
// Draw arm overlay graphics when Tux is holding something
- if (holding_something && physic.get_velocity_y() == 0)
+ if ((holding_something && physic.get_velocity_y() == 0) || shooting_timer.check())
{
if (dir == RIGHT)
sprite->grab_right->draw(pos);
Timer safe_timer;
Timer frame_timer;
Timer kick_timer;
+ Timer shooting_timer; // used to show the arm when Tux is shooting
Physic physic;
public:
add_object(new Upgrade(displaymanager, pos, dir, kind));
}
-void
+bool
World::add_bullet(const Vector& pos, float xm, Direction dir)
{
if(tux->got_power == Player::FIRE_POWER)
{
if(bullets.size() > MAX_FIRE_BULLETS-1)
- return;
+ return false;
}
else if(tux->got_power == Player::ICE_POWER)
{
if(bullets.size() > MAX_ICE_BULLETS-1)
- return;
+ return false;
}
Bullet* new_bullet = 0;
add_object(new_bullet);
play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
+
+ return true;
}
void
BadGuy* add_bad_guy(float x, float y, BadGuyKind kind);
void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
- void add_bullet(const Vector& pos, float xm, Direction dir);
+ bool add_bullet(const Vector& pos, float xm, Direction dir);
/** Try to grab the coin at the given coordinates */
void trygrabdistro(float x, float y, int bounciness);