Removed profiling

This commit is contained in:
Rob Pearce 2008-10-27 05:12:02 +00:00
parent da87a44e2c
commit 334ed03c27
2 changed files with 57 additions and 13 deletions

View File

@ -1,7 +1,7 @@
all: rc edit all: rc edit
rc: rc.c shared.c rc.h shared.h globals.h defs.h rc: rc.c shared.c rc.h shared.h globals.h defs.h
gcc -pg -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_mixer gcc -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_mixer
edit: edit.c shared.c edit.h shared.h globals.h defs.h edit: edit.c shared.c edit.h shared.h globals.h defs.h
gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf

68
rc.c
View File

@ -71,6 +71,9 @@ int paused;
int wantframerate = B_FALSE; int wantframerate = B_FALSE;
int fps;
int fpscount;
int titlemode; int titlemode;
int blinkspeed; int blinkspeed;
int credits = 0; int credits = 0;
@ -672,19 +675,23 @@ int main (int argc, char **argv) {
player->powerup = B_FALSE; player->powerup = B_FALSE;
} }
} else if (player->powerup == PW_SPRAYUP) { // green overlay for fly spray } else if (player->powerup == PW_SPRAYUP) { // green overlay for fly spray
SDL_SetAlpha(greenbox, SDL_SRCALPHA, sprayalpha); if (levelcomplete != LV_DOPOKER) {
sprayalpha += 5; SDL_SetAlpha(greenbox, SDL_SRCALPHA, sprayalpha);
if (sprayalpha >= 100) { sprayalpha += 5;
player->powerup = PW_SPRAYDOWN; if (sprayalpha >= 100) {
player->powerup = PW_SPRAYDOWN;
}
SDL_BlitSurface(greenbox,NULL,screen,NULL);
} }
SDL_BlitSurface(greenbox,NULL,screen,NULL);
} else if (player->powerup == PW_SPRAYDOWN) { // green overlay for fly spray } else if (player->powerup == PW_SPRAYDOWN) { // green overlay for fly spray
SDL_SetAlpha(greenbox, SDL_SRCALPHA, sprayalpha); if (levelcomplete != LV_DOPOKER) {
sprayalpha -= 5; SDL_SetAlpha(greenbox, SDL_SRCALPHA, sprayalpha);
if (sprayalpha <= 0) { sprayalpha -= 5;
player->powerup = PW_SPRAYUP; if (sprayalpha <= 0) {
player->powerup = PW_SPRAYUP;
}
SDL_BlitSurface(greenbox,NULL,screen,NULL);
} }
SDL_BlitSurface(greenbox,NULL,screen,NULL);
} else if (player->powerup == PW_RATSHAKE) { // horizontal shake due to rat } else if (player->powerup == PW_RATSHAKE) { // horizontal shake due to rat
// shake screen // shake screen
if (timer % 5 == 0) { if (timer % 5 == 0) {
@ -732,6 +739,7 @@ int main (int argc, char **argv) {
if (toggletimer > 0) toggletimer--; if (toggletimer > 0) toggletimer--;
fpscount++;
tick(); tick();
} // end main loop } // end main loop
@ -774,6 +782,11 @@ void tick(void) {
} else { } else {
/* once per second */ /* once per second */
if (fpsticks - fpsstart >= 1000) { if (fpsticks - fpsstart >= 1000) {
// calculate frames per second
fps = fpscount;
fpscount = 0;
// incremenet game time
gtime++; gtime++;
// check for game over - 5 seocnds after game over text disappears // check for game over - 5 seocnds after game over text disappears
@ -3729,7 +3742,7 @@ void drawscore(void) {
} }
if (wantframerate) { if (wantframerate) {
scoreval = SDL_getFramerate(&manager); scoreval = fps;
} else { } else {
scoreval = player->score; scoreval = player->score;
} }
@ -3869,6 +3882,7 @@ void removeall(void) {
text_t *t; text_t *t;
SDL_Rect area; SDL_Rect area;
int clearfull = B_FALSE; int clearfull = B_FALSE;
int *animtile;
switch (player->powerup) { switch (player->powerup) {
@ -3892,6 +3906,18 @@ void removeall(void) {
if (curlevel->iced) clearfull = B_TRUE; if (curlevel->iced) clearfull = B_TRUE;
if (paused) clearfull = B_TRUE; if (paused) clearfull = B_TRUE;
if (playedbell == BELL_DONESOUND) {
if (timer < BELLTIME) {
clearfull = B_TRUE;
}
}
if (isbosslevel(curlevelnum)) {
clearfull = B_TRUE;
}
if (clearfull) { if (clearfull) {
// clear the entire screen // clear the entire screen
SDL_BlitSurface(temps, NULL, screen, NULL); SDL_BlitSurface(temps, NULL, screen, NULL);
@ -3912,6 +3938,22 @@ void removeall(void) {
removesprite(s); removesprite(s);
} }
// animated tiles
for (animtile = curlevel->animtiles; animtile && *animtile != -1; animtile++) {
int offset,tx,ty;
offset = *animtile;
tx = offset%LEVELW; ty = offset / LEVELW;
area.x = tx*TILEW;
area.y = ty*TILEH;
area.w = TILEW;
area.h = TILEH;
SDL_BlitSurface(temps, &area, screen, &area);
}
// remove all text // remove all text
for (t = text ; t ; t = t->next) { for (t = text ; t ; t = t->next) {
/* draw text */ /* draw text */
@ -7042,7 +7084,7 @@ if (cheat) {
gaincard(player, getrandomcard()); gaincard(player, getrandomcard());
gaincard(player, getrandomcard()); gaincard(player, getrandomcard());
/* /*
gaincard(player, P_CARDD4); /gaincard(player, P_CARDD4);
gaincard(player, P_CARDD5); gaincard(player, P_CARDD5);
gaincard(player, P_CARDS8); gaincard(player, P_CARDS8);
gaincard(player, P_CARDH8); gaincard(player, P_CARDH8);
@ -7064,6 +7106,7 @@ if (cheat) {
player->speed = 2; // fast player->speed = 2; // fast
player->netsticky = B_TRUE; player->netsticky = B_TRUE;
player->doublejump = B_TRUE; player->doublejump = B_TRUE;
player->hasbell = B_TRUE;
sprintf(tempm, "Cheat!"); sprintf(tempm, "Cheat!");
addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM);
toggletimer = 80; toggletimer = 80;
@ -7461,6 +7504,7 @@ void docannoneffect(void) {
if (player->timer3 <= 0) { if (player->timer3 <= 0) {
player->powerup = B_FALSE; player->powerup = B_FALSE;
s->dead = D_FINAL; s->dead = D_FINAL;
SDL_BlitSurface(temps, NULL, screen, NULL);
} }
} }
} }