From ac84a8a6f3d5ce1eff3e2068f5518ce53c0c4ff4 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Sun, 9 May 2004 21:15:58 +0000 Subject: [PATCH] Instead of limitating the number of bullets, according to the ones in screen, do it in a time bases. This was asked in a comment on The Linux Game Tome and I already wanted to do this, since the day I made that hack, so here it goes. You can tune that time on the defines.h file, it is the BULLETS_TIMEOUT definition (in ms). There is a fire test level. SVN-Revision: 1059 --- src/defines.h | 2 +- src/world.cpp | 6 +++++- src/world.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/defines.h b/src/defines.h index 163f1bdd3..49c81ce91 100644 --- a/src/defines.h +++ b/src/defines.h @@ -69,7 +69,7 @@ enum DyingType { #define START_LIVES 4 -#define MAX_BULLETS 2 +#define BULLETS_TIMEOUT 500 #define YM_FOR_JUMP 6.0 #define WALK_ACCELERATION_X 0.03 diff --git a/src/world.cpp b/src/world.cpp index 3322b9fbf..924d456ed 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -56,6 +56,7 @@ World::World(const std::string& filename) apply_bonuses(); scrolling_timer.init(true); + bullets_timer.init(true); } World::World(const std::string& subset, int level_nr) @@ -77,6 +78,7 @@ World::World(const std::string& subset, int level_nr) apply_bonuses(); scrolling_timer.init(true); + bullets_timer.init(true); } void @@ -541,9 +543,11 @@ World::add_upgrade(float x, float y, Direction dir, UpgradeKind kind) void World::add_bullet(float x, float y, float xm, Direction dir) { - if(bullets.size() > MAX_BULLETS-1) + if(bullets_timer.check()) return; + bullets_timer.start(BULLETS_TIMEOUT); + Bullet new_bullet; new_bullet.init(x,y,xm,dir); bullets.push_back(new_bullet); diff --git a/src/world.h b/src/world.h index e62ce664d..58dccfc2d 100644 --- a/src/world.h +++ b/src/world.h @@ -58,6 +58,7 @@ public: std::vector floating_scores; std::vector upgrades; + Timer bullets_timer; std::vector bullets; typedef std::vector ParticleSystems; ParticleSystems particle_systems; -- 2.11.0