{
pbad->base.width = 32;
pbad->base.height = 32;
- pbad->base.alive = YES;
pbad->mode = NORMAL;
pbad->dying = NO;
pbad->kind = kind;
void badguy_action(bad_guy_type* pbad)
{
- if (pbad->base.alive)
- {
if (pbad->seen)
{
if (pbad->kind == BAD_BSOD)
if (pbad->dying != FALLING)
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
- pbad->base.alive = NO;
-
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
+
/* Bump into things horizontally: */
if (!pbad->dying)
}
if (pbad->base.y > screen->h)
- pbad->base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
}
else if (pbad->kind == BAD_LAPTOP)
{
if (pbad->dying != FALLING)
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
- pbad->base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
/* Bump into things horizontally: */
/* Bump into things horizontally: */
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
- pbad->base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
if(physic_get_state(&pbad->physic) == -1)
{
else if (pbad->kind == -1)
{}
-
- }
-
/* Handle mode timer: */
if (pbad->mode == FLAT && pbad->mode != HELD)
{
/* Remove it if time's up: */
if(!timer_check(&pbad->timer))
- pbad->base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
}
/* Remove if it's far off the screen: */
if (pbad->base.x < scroll_x - OFFSCREEN_DISTANCE)
- pbad->base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
else /* !seen */
{
/* Once it's on screen, it's activated! */
void badguy_draw(bad_guy_type* pbad)
{
- if (pbad->base.alive &&
- pbad->base.x > scroll_x - 32 &&
+ if (pbad->base.x > scroll_x - 32 &&
pbad->base.x < scroll_x + screen->w)
{
if (pbad->kind == BAD_BSOD)
void collision_handler()
{
- int i,j;
+ unsigned int i,j;
/* CO_BULLET & CO_BADGUY check */
- for(i = 0; i < num_bullets; ++i)
+ for(i = 0; i < bullets.size(); ++i)
{
- if(bullets[i].base.alive)
- {
- for(j = 0; j < num_bad_guys; ++j)
+ for(j = 0; j < bad_guys.size(); ++j)
{
- if(bad_guys[j].dying == NO && bad_guys[j].base.alive)
+ if(bad_guys[j].dying == NO)
{
if(rectcollision(&bullets[i].base,&bad_guys[j].base) == YES)
{
}
}
}
- }
}
/* CO_BADGUY & CO_BADGUY check */
- for(i = 0; i < num_bad_guys; ++i)
+ for(i = 0; i < bad_guys.size(); ++i)
{
- if(bad_guys[i].base.alive && bad_guys[i].dying == NO)
+ if(bad_guys[i].dying == NO)
{
- for(j = i+1; j < num_bad_guys; ++j)
+ for(j = i+1; j < bad_guys.size(); ++j)
{
- if(j != i && bad_guys[j].base.alive && bad_guys[j].dying == NO)
+ if(j != i && bad_guys[j].dying == NO)
{
if(rectcollision(&bad_guys[i].base,&bad_guys[j].base) == YES)
{
/* CO_BADGUY & CO_PLAYER check */
- for(i = 0; i < num_bad_guys; ++i)
+ for(i = 0; i < bad_guys.size(); ++i)
{
- if(bad_guys[i].base.alive)
- {
if(bad_guys[i].dying == NO && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0) == YES )
{
/* We have detected a collision and now call the collision functions of the collided objects. */
player_collision(&tux, &bad_guys[i], CO_BADGUY);
}
}
- }
}
/* CO_UPGRADE & CO_PLAYER check */
- for(i = 0; i < num_upgrades; ++i)
+ for(i = 0; i < upgrades.size(); ++i)
{
- if(upgrades[i].base.alive)
- {
if(rectcollision(&upgrades[i].base,&tux.base) == YES)
{
/* We have detected a collision and now call the collision functions of the collided objects. */
upgrade_collision(&upgrades[i], &tux, CO_PLAYER);
}
-
- }
}
}
/* Handle bouncy distros: */
- for (i = 0; i < num_bouncy_distros; i++)
+ for (i = 0; i < bouncy_distros.size(); i++)
{
bouncy_distro_action(&bouncy_distros[i]);
}
/* Handle broken bricks: */
- for (i = 0; i < num_broken_bricks; i++)
+ for (i = 0; i < broken_bricks.size(); i++)
{
broken_brick_action(&broken_bricks[i]);
}
/* Handle bouncy bricks: */
- for (i = 0; i < num_bouncy_bricks; i++)
+ for (i = 0; i < bouncy_bricks.size(); i++)
{
bouncy_brick_action(&bouncy_bricks[i]);
}
/* Handle floating scores: */
- for (i = 0; i < num_floating_scores; i++)
+ for (i = 0; i < floating_scores.size(); i++)
{
floating_score_action(&floating_scores[i]);
}
/* Handle bullets: */
- for (i = 0; i < num_bullets; ++i)
+ for (i = 0; i < bullets.size(); ++i)
{
bullet_action(&bullets[i]);
}
/* Handle upgrades: */
- for (i = 0; i < num_upgrades; i++)
+ for (i = 0; i < upgrades.size(); i++)
{
upgrade_action(&upgrades[i]);
}
/* Handle bad guys: */
- for (i = 0; i < num_bad_guys; i++)
+ for (i = 0; i < bad_guys.size(); i++)
{
badguy_action(&bad_guys[i]);
}
/* (Bouncy bricks): */
- for (i = 0; i < num_bouncy_bricks; ++i)
+ for (i = 0; i < bouncy_bricks.size(); ++i)
{
bouncy_brick_draw(&bouncy_bricks[i]);
}
/* (Bad guys): */
- for (i = 0; i < num_bad_guys; ++i)
+ for (i = 0; i < bad_guys.size(); ++i)
{
badguy_draw(&bad_guys[i]);
}
/* (Bullets): */
- for (i = 0; i < num_bullets; ++i)
+ for (i = 0; i < bullets.size(); ++i)
{
bullet_draw(&bullets[i]);
}
/* (Floating scores): */
- for (i = 0; i < num_floating_scores; ++i)
+ for (i = 0; i < floating_scores.size(); ++i)
{
floating_score_draw(&floating_scores[i]);
}
/* (Upgrades): */
- for (i = 0; i < num_upgrades; ++i)
+ for (i = 0; i < upgrades.size(); ++i)
{
upgrade_draw(&upgrades[i]);
}
/* (Bouncy distros): */
- for (i = 0; i < num_bouncy_distros; ++i)
+ for (i = 0; i < bouncy_distros.size(); ++i)
{
bouncy_distro_draw(&bouncy_distros[i]);
}
/* (Broken bricks): */
- for (i = 0; i < num_broken_bricks; ++i)
+ for (i = 0; i < broken_bricks.size(); ++i)
{
broken_brick_draw(&broken_bricks[i]);
}
/* Bad guys: */
- for (i = 0; i < num_bad_guys; i++)
+ for (i = 0; i < bad_guys.size(); i++)
{
- if (bad_guys[i].base.alive &&
- bad_guys[i].base.x >= x - 32 && bad_guys[i].base.x <= x + 32 &&
+ if (bad_guys[i].base.x >= x - 32 && bad_guys[i].base.x <= x + 32 &&
bad_guys[i].base.y >= y - 16 && bad_guys[i].base.y <= y + 16)
{
if (bad_guys[i].kind == BAD_BSOD ||
/* Upgrades: */
- for (i = 0; i < num_upgrades; i++)
+ for (i = 0; i < upgrades.size(); i++)
{
- if (upgrades[i].base.alive && upgrades[i].base.height == 32 &&
+ if (upgrades[i].base.height == 32 &&
upgrades[i].base.x >= x - 32 && upgrades[i].base.x <= x + 32 &&
upgrades[i].base.y >= y - 16 && upgrades[i].base.y <= y + 16)
{
}
/* Draw the Bad guys: */
- for (i = 0; i < num_bad_guys; ++i)
+ for (i = 0; i < bad_guys.size(); ++i)
{
- if(bad_guys[i].base.alive == NO)
- continue;
/* to support frames: img_bsod_left[(frame / 5) % 4] */
if(bad_guys[i].kind == BAD_BSOD)
texture_draw(&img_bsod_left[(le_frame / 5) % 4], bad_guys[i].base.x - pos_x, bad_guys[i].base.y, NO_UPDATE);
xx = ((int)x / 32);
/* if there is a bad guy over there, remove it */
- for(i = 0; i < num_bad_guys; ++i)
- if (bad_guys[i].base.alive)
+ for(i = 0; i < bad_guys.size(); ++i)
if(xx == bad_guys[i].base.x/32 && yy == bad_guys[i].base.y/32)
- bad_guys[i].base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(&bad_guys[i]));
if(c == '0') /* if it's a bad guy */
add_bad_guy(xx*32, yy*32, BAD_BSOD);
y2 /= 32;
/* if there is a bad guy over there, remove it */
- for(i = 0; i < num_bad_guys; ++i)
- if(bad_guys[i].base.alive)
+ for(i = 0; i < bad_guys.size(); ++i)
if(bad_guys[i].base.x/32 >= x1 && bad_guys[i].base.x/32 <= x2
&& bad_guys[i].base.y/32 >= y1 && bad_guys[i].base.y/32 <= y2)
- bad_guys[i].base.alive = NO;
+ bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(&bad_guys[i]));
for(xx = x1; xx <= x2; xx++)
for(yy = y1; yy <= y2; yy++)
timer_type super_bkgd_timer;
float scroll_x;
int frame;
-bouncy_distro_type *bouncy_distros;
-broken_brick_type *broken_bricks;
-bouncy_brick_type *bouncy_bricks;
-bad_guy_type *bad_guys;
-floating_score_type *floating_scores;
-upgrade_type *upgrades;
-bullet_type *bullets;
-int num_bad_guys;
-int num_bouncy_distros;
-int num_broken_bricks;
-int num_bouncy_bricks;
-int num_floating_scores;
-int num_upgrades;
-int num_bullets;
+std::vector<bouncy_distro_type> bouncy_distros;
+std::vector<broken_brick_type> broken_bricks;
+std::vector<bouncy_brick_type> bouncy_bricks;
+std::vector<bad_guy_type> bad_guys;
+std::vector<floating_score_type> floating_scores;
+std::vector<upgrade_type> upgrades;
+std::vector<bullet_type> bullets;
player_type tux;
texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow;
timer_type time_left;
/* Initialize all 'dynamic' arrays */
void arrays_init(void)
{
-num_bad_guys = 0;
-num_bouncy_distros = 0;
-num_broken_bricks = 0;
-num_bouncy_bricks = 0;
-num_floating_scores = 0;
-num_upgrades = 0;
-num_bullets = 0;
-bad_guys = NULL;
-bouncy_distros = NULL;
-broken_bricks = NULL;
-bouncy_bricks = NULL;
-floating_scores = NULL;
-upgrades = NULL;
-bullets = NULL;
}
/* Free memory of 'dynamic' arrays */
void arrays_free(void)
{
-free(bad_guys);
-free(bouncy_distros);
-free(broken_bricks);
-free(bouncy_bricks);
-free(floating_scores);
-free(upgrades);
-free(bullets);
+bad_guys.clear();
+bouncy_distros.clear();
+broken_bricks.clear();
+bouncy_bricks.clear();
+floating_scores.clear();
+upgrades.clear();
+bullets.clear();
}
void set_defaults(void)
void add_score(float x, float y, int s)
{
- int i, found;
-
-
- /* Add the score: */
+ /* Add the score: */
score += s;
-
- /* Add a floating score thing to the game: */
-
- found = -1;
-
- for (i = 0; i < num_floating_scores && found == -1; i++)
- {
- if (!floating_scores[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_floating_scores;
- floating_scores = (floating_score_type*) realloc(floating_scores,num_floating_scores*sizeof(floating_score_type));
- floating_score_init(&floating_scores[num_floating_scores-1],x,y,s);
- found = -1;
- }
-
- if (found != -1)
- {
- floating_score_init(&floating_scores[found],x,y,s);
- }
+ floating_score_type new_floating_score;
+ floating_score_init(&new_floating_score,x,y,s);
+ floating_scores.push_back(new_floating_score);
}
/* Add a bouncy distro: */
void add_bouncy_distro(float x, float y)
{
- int i, found;
-
- found = -1;
-
- for (i = 0; i < num_bouncy_distros && found == -1; i++)
- {
- if (!bouncy_distros[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_bouncy_distros;
- bouncy_distros = (bouncy_distro_type*) realloc(bouncy_distros,num_bouncy_distros*sizeof(bouncy_distro_type));
- found = num_bouncy_distros - 1;
- }
-
- if (found != -1)
- {
- bouncy_distro_init(&bouncy_distros[found],x,y);
- }
+
+ bouncy_distro_type new_bouncy_distro;
+ bouncy_distro_init(&new_bouncy_distro,x,y);
+ bouncy_distros.push_back(new_bouncy_distro);
}
void add_broken_brick_piece(float x, float y, float xm, float ym)
{
- int i, found;
-
- found = -1;
-
- for (i = 0; i < num_broken_bricks && found == -1; i++)
- {
- if (!broken_bricks[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_broken_bricks;
- broken_bricks = (broken_brick_type*) realloc(broken_bricks,num_broken_bricks*sizeof(broken_brick_type));
- found = num_broken_bricks - 1;
- }
-
- if (found != -1)
- {
- broken_brick_init(&broken_bricks[found], x, y, xm, ym);
- }
+ broken_brick_type new_broken_brick;
+ broken_brick_init(&new_broken_brick,x,y,xm,ym);
+ broken_bricks.push_back(new_broken_brick);
}
void add_bouncy_brick(float x, float y)
{
- int i, found;
-
- found = -1;
-
- for (i = 0; i < num_bouncy_bricks && found == -1; i++)
- {
- if (!bouncy_bricks[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_bouncy_bricks;
- bouncy_bricks = (bouncy_brick_type*) realloc(bouncy_bricks,num_bouncy_bricks*sizeof(bouncy_brick_type));
- found = num_bouncy_bricks - 1;
- }
-
- if (found != -1)
- {
- bouncy_brick_init(&bouncy_bricks[found],x,y);
- }
+ bouncy_brick_type new_bouncy_brick;
+ bouncy_brick_init(&new_bouncy_brick,x,y);
+ bouncy_bricks.push_back(new_bouncy_brick);
}
void add_bad_guy(float x, float y, int kind)
{
- int i, found;
-
- found = -1;
-
- for (i = 0; i < num_bad_guys && found == -1; i++)
- {
- if (!bad_guys[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_bad_guys;
- bad_guys = (bad_guy_type*) realloc(bad_guys,num_bad_guys*sizeof(bad_guy_type));
- found = num_bad_guys - 1;
- }
-
- if (found != -1)
- {
- badguy_init(&bad_guys[found], x, y, kind);
- }
+ bad_guy_type new_bad_guy;
+ badguy_init(&new_bad_guy,x,y,kind);
+ bad_guys.push_back(new_bad_guy);
}
/* Add an upgrade: */
void add_upgrade(float x, float y, int dir, int kind)
{
- int i, found;
-
- found = -1;
-
- for (i = 0; i < num_upgrades && found == -1; i++)
- {
- if (!upgrades[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_upgrades;
- upgrades = (upgrade_type*) realloc(upgrades,num_upgrades*sizeof(upgrade_type));
- found = num_upgrades - 1;
- }
-
- if (found != -1)
- {
- upgrade_init(&upgrades[found], x, y, dir, kind);
- }
+ upgrade_type new_upgrade;
+ upgrade_init(&new_upgrade,x,y,dir,kind);
+ upgrades.push_back(new_upgrade);
}
/* Add a bullet: */
void add_bullet(float x, float y, float xm, int dir)
{
- int i, found;
+ bullet_type new_bullet;
+ bullet_init(&new_bullet,x,y,xm,dir);
+ bullets.push_back(new_bullet);
- found = -1;
-
- for (i = 0; i < num_bullets && found == -1; i++)
- {
- if (!bullets[i].base.alive)
- found = i;
- }
-
- if (found == -1)
- {
- ++num_bullets;
- bullets = (bullet_type*) realloc(bullets,num_bullets*sizeof(bullet_type));
- found = num_bullets - 1;
- }
-
- if (found != -1)
- {
- bullet_init(&bullets[found], x, y, xm, dir);
-
- play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
- }
+ play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
}
extern timer_type super_bkgd_timer;
extern float scroll_x;
extern int frame;
-extern bouncy_distro_type *bouncy_distros;
-extern broken_brick_type *broken_bricks;
-extern bouncy_brick_type *bouncy_bricks;
-extern bad_guy_type *bad_guys;
-extern floating_score_type *floating_scores;
-extern upgrade_type *upgrades;
-extern bullet_type *bullets;
-extern int num_bad_guys;
-extern int num_bouncy_distros;
-extern int num_broken_bricks;
-extern int num_bouncy_bricks;
-extern int num_floating_scores;
-extern int num_upgrades;
-extern int num_bullets;
+extern std::vector<bouncy_distro_type> bouncy_distros;
+extern std::vector<broken_brick_type> broken_bricks;
+extern std::vector<bouncy_brick_type> bouncy_bricks;
+extern std::vector<bad_guy_type> bad_guys;
+extern std::vector<floating_score_type> floating_scores;
+extern std::vector<upgrade_type> upgrades;
+extern std::vector<bullet_type> bullets;
extern player_type tux;
extern texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow;
extern timer_type time_left;
{
pbullet->base.width = 4;
pbullet->base.height = 4;
- pbullet->base.alive = YES;
if (dir == RIGHT)
{
void bullet_action(bullet_type* pbullet)
{
- if (pbullet->base.alive)
- {
pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio;
pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio;
issolid(pbullet->base.x + 4, pbullet->base.y + 2) ||
issolid(pbullet->base.x, pbullet->base.y + 2))
{
- pbullet->base.alive = NO;
+ bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet));
}
- }
}
void bullet_draw(bullet_type* pbullet)
{
- if (pbullet->base.alive &&
- pbullet->base.x >= scroll_x - pbullet->base.width &&
+ if (pbullet->base.x >= scroll_x - pbullet->base.width &&
pbullet->base.x <= scroll_x + screen->w)
{
texture_draw(&img_bullet, pbullet->base.x - scroll_x, pbullet->base.y,
{
if(c_object == CO_BADGUY)
- pbullet->base.alive = NO;
+ bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet));
}
{
pupgrade->base.width = 32;
pupgrade->base.height = 0;
- pupgrade->base.alive = YES;
pupgrade->kind = kind;
pupgrade->base.x = x;
pupgrade->base.y = y;
void upgrade_action(upgrade_type *pupgrade)
{
- if (pupgrade->base.alive)
- {
+
if (pupgrade->base.height < 32)
{
/* Rise up! */
/* Off the screen? Kill it! */
if (pupgrade->base.x < scroll_x - pupgrade->base.width)
- pupgrade->base.alive = NO;
+ upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
if (pupgrade->base.y > screen->h)
- pupgrade->base.alive = NO;
+ upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
if (issolid(pupgrade->base.x + 1, pupgrade->base.y + 32.) ||
issolid(pupgrade->base.x + 31., pupgrade->base.y + 32.))
}
}
- }
}
void upgrade_draw(upgrade_type* pupgrade)
{
SDL_Rect dest;
- if (pupgrade->base.alive)
- {
if (pupgrade->base.height < 32)
{
/* Rising up... */
NO_UPDATE);
}
}
- }
}
void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object)
/* p_c_object is CO_PLAYER, so assign it to pplayer */
pplayer = (player_type*) p_c_object;
- pupgrade->base.alive = NO;
+ upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade));
/* Affect the player: */
typedef struct base_type
{
- int alive;
float x;
float y;
float xm;
void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y)
{
- pbouncy_distro->base.alive = YES;
pbouncy_distro->base.x = x;
pbouncy_distro->base.y = y;
pbouncy_distro->base.ym = -2;
void bouncy_distro_action(bouncy_distro_type* pbouncy_distro)
{
- if (pbouncy_distro->base.alive)
- {
pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio;
pbouncy_distro->base.ym += 0.1 * frame_ratio;
if (pbouncy_distro->base.ym >= 0)
- pbouncy_distro->base.alive = NO;
- }
+ bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro));
}
void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro)
{
- if (pbouncy_distro->base.alive)
- {
texture_draw(&img_distro[0],
pbouncy_distro->base.x - scroll_x,
pbouncy_distro->base.y,
NO_UPDATE);
- }
}
void broken_brick_init(broken_brick_type* pbroken_brick, float x, float y, float xm, float ym)
{
- pbroken_brick->base.alive = YES;
pbroken_brick->base.x = x;
pbroken_brick->base.y = y;
pbroken_brick->base.xm = xm;
void broken_brick_action(broken_brick_type* pbroken_brick)
{
- if (pbroken_brick->base.alive)
- {
pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio;
pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio;
if (!timer_check(&pbroken_brick->timer))
- pbroken_brick->base.alive = NO;
- }
+ broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick));
}
void broken_brick_draw(broken_brick_type* pbroken_brick)
{
SDL_Rect src, dest;
- if (pbroken_brick->base.alive)
- {
src.x = rand() % 16;
src.y = rand() % 16;
src.w = 16;
dest.h = 16;
texture_draw_part(&img_brick[0],src.x,src.y,dest.x,dest.y,dest.w,dest.h,NO_UPDATE);
- }
}
void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y)
{
- pbouncy_brick->base.alive = YES;
pbouncy_brick->base.x = x;
pbouncy_brick->base.y = y;
pbouncy_brick->offset = 0;
void bouncy_brick_action(bouncy_brick_type* pbouncy_brick)
{
- if (pbouncy_brick->base.alive)
- {
-
pbouncy_brick->offset = (pbouncy_brick->offset +
pbouncy_brick->offset_m * frame_ratio);
/* Stop bouncing? */
if (pbouncy_brick->offset >= 0)
- pbouncy_brick->base.alive = NO;
- }
+ bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick));
}
void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick)
int s;
SDL_Rect dest;
- if (pbouncy_brick->base.alive)
- {
if (pbouncy_brick->base.x >= scroll_x - 32 &&
pbouncy_brick->base.x <= scroll_x + screen->w)
{
pbouncy_brick->base.y + pbouncy_brick->offset,
pbouncy_brick->shape);
}
- }
}
void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s)
{
- pfloating_score->base.alive = YES;
pfloating_score->base.x = x;
pfloating_score->base.y = y - 16;
timer_init(&pfloating_score->timer,YES);
void floating_score_action(floating_score_type* pfloating_score)
{
- if (pfloating_score->base.alive)
- {
pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio;
if(!timer_check(&pfloating_score->timer))
- pfloating_score->base.alive = NO;
- }
+ floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score));
}
void floating_score_draw(floating_score_type* pfloating_score)
{
- if (pfloating_score->base.alive)
- {
char str[10];
sprintf(str, "%d", pfloating_score->value);
text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1, NO_UPDATE);
- }
}