diff --git a/rc b/rc index 3930a1c..6e8293f 100755 Binary files a/rc and b/rc differ diff --git a/rc.c b/rc.c index cb94ba8..a23b30e 100644 --- a/rc.c +++ b/rc.c @@ -200,6 +200,8 @@ int main (int argc, char **argv) { s->invuln = INVULNTIME; } else { killsprite(s); + // check for level completion + countmonsters(); } } @@ -247,6 +249,13 @@ int main (int argc, char **argv) { toggletimer = 50; } } + // dump sprites + if (keys[SDLK_d]) { + if (toggletimer == 0) { + dumpsprites(); + toggletimer = 50; + } + } if (keys[SDLK_RETURN]) { if (toggletimer == 0) { SDL_WM_ToggleFullScreen(screen); @@ -525,8 +534,6 @@ void nextlevel(void) { // remove the player removesprite(player); - // don't want the player flashing - player->invuln = 0; /* in case we skipped the level due to a powerup etc */ levelcomplete = LV_NEXTLEV; @@ -537,10 +544,15 @@ void nextlevel(void) { playmusic(normalmusic); } + // don't want the player flashing while scrolling + player->invuln = 0; + // these two handle the scroll effect to the next level loadlevel(curworld,curlevelnum); drawlevel(); + // now the player gets invincibility + player->invuln = INVULNTIME; /* reset game stats */ levelcomplete = LV_INIT; @@ -583,7 +595,6 @@ void jump(sprite_t *s, int dir) { } void die(sprite_t *s) { - int mcount = 0; sprite_t *s2; /* clouds can't die like this */ if (s->id == P_CLOUD) return; @@ -617,6 +628,16 @@ void die(sprite_t *s) { s->netting = 0; s->slamming = 0; + // check for level clear + countmonsters(); + +} + +// check whether the level has been won +void countmonsters(void) { + sprite_t *s2; + int mcount; + mcount = 0; /* any monsters left? */ if (!levelcomplete) { for (s2 = sprite->next ; s2 ; s2 = s2->next) { @@ -2729,6 +2750,8 @@ int randompowerup(void) { num = rand() % 4; +return P_BOXING; + switch (num) { case 0: default: @@ -2741,3 +2764,22 @@ int randompowerup(void) { return P_BOXING; } } + +void dumpsprites(void) { + sprite_t *s; + int i = 0; + int mcount = 0; + for (s = sprite; s ; s = s->next) { + printf("Sprite #%d: %s at %1.0f,%1.0f id=%d (",i,s->name,s->x,s->y, s->id); + if (ismonster(s->id)) { printf("MONSTER, "); mcount++; } + if (isfruit(s->id)) printf("FRUIT, "); + if (isflower(s->id)) printf("FLOWER, "); + if (isbullet(s->id)) printf("BULLET, "); + if (iseffect(s->id)) printf("EFFECT, "); + printf(")\n"); + } + + printf("--------\n"); + printf("Total monsters: %d\n",mcount); + printf("\n\n"); +} diff --git a/rc.h b/rc.h index 04d4006..5363dd2 100644 --- a/rc.h +++ b/rc.h @@ -41,3 +41,5 @@ void channeldone(int channel); void movetostart(sprite_t *p, int dstx, int dsty, int speed); SDL_Surface *grabbehind(sprite_t *s, SDL_Surface *surf); int randompowerup(void); +void dumpsprites(void); +void countmonsters(void);