From 39f85d7e89bd1ef7cb0b4629bd1d51d3c77b8735 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Sun, 24 Jul 2016 18:27:15 +1200 Subject: [PATCH] Converted graphics to use OpenGL. --- Makefile | 4 +- defs.h | 14 + edit.c | 4 +- rc.c | 969 ++++++++++++++++++++----------------------------------- rc.h | 7 + shared.c | 92 +++++- shared.h | 4 +- todo | 23 ++ 8 files changed, 493 insertions(+), 624 deletions(-) create mode 100644 todo diff --git a/Makefile b/Makefile index 76681c2..afd3b6f 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ LIBS = libs/libSDL-1.2.0.dylib libs/libSDL_image-1.2.0.dylib libs/libSDL_mixer-1 all: rc edit rc: rc.c shared.c rc.h shared.h globals.h defs.h - gcc -Wall -DREV=\"`git rev-parse HEAD`\" -o rc -g rc.c shared.c `sdl-config --cflags --libs` -lsqlite3 -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer + gcc -Wall -DOPENGL -DREV=\"`git rev-parse HEAD`\" -o rc -g rc.c shared.c `sdl-config --cflags --libs` -lsqlite3 -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer -framework OpenGL edit: edit.c shared.c edit.h shared.h globals.h defs.h - gcc -DREV=\"`git rev-parse HEAD`\" -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf + gcc -DOPENGL -DREV=\"`git rev-parse HEAD`\" -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -framework OpenGL app: rc if [ `uname -s` != "Darwin" ]; then echo "Mac .app bundle generation is only available under OSX."; exit 1; fi; diff --git a/defs.h b/defs.h index 4b97d49..cff6774 100644 --- a/defs.h +++ b/defs.h @@ -8,6 +8,13 @@ #define FILE_TILEDEFS "tiledefs.dat" #define DIR_LEVELS "levels" +// sizes +#define SCREENW 640 +#define SCREENH 480 + + +#define B_CLEAR -1 +#define B_NOCLEAR 0 /* Macros */ //#define OPENGL @@ -1165,6 +1172,13 @@ typedef struct imageset_s { } imageset_t; imageset_t imageset[MAXPTYPES]; +typedef struct levscrollinfo_s { + int dstx[2],dsty[2],xdis[2],ydis[2]; + double pspeed[2]; + sprite_t *player, *player2; + sprite_t *cloud, *cloud2; +} levscrollinfo_t; + /* external globals */ extern char progname[]; extern SDL_Color black; diff --git a/edit.c b/edit.c index 1890d2e..af08b64 100644 --- a/edit.c +++ b/edit.c @@ -232,7 +232,7 @@ int main (int argc, char **argv) { draweditorlevel(); drawpalette(); drawsprites(); - flip(); + flip(B_TRUE); timer = 0; @@ -743,7 +743,7 @@ int main (int argc, char **argv) { } - flip(); + flip(B_TRUE); if (++timer == 100) timer = 0; if (toggletimer > 0) toggletimer--; diff --git a/rc.c b/rc.c index 6193b96..e2bfa82 100644 --- a/rc.c +++ b/rc.c @@ -26,6 +26,9 @@ #include #include #include +#ifdef OPENGL +#include +#endif #include #include "shared.h" @@ -95,6 +98,19 @@ int gameovertime; int sprayalpha; // for spray effect +#ifdef OPENGL +SDL_Surface *realscreen; + +extern GLuint tex; +extern float texw,texh; +extern GLint sampleBuffers, samples; + +int rm = 0x000000ff; +int gm = 0x0000ff00; +int bm = 0x00ff0000; +int am = 0xff000000; +#endif + regrow_t regrow[MAXREGROW]; // for tile regrowth int numregrow = 0; @@ -354,9 +370,6 @@ int main (int argc, char **argv) { initsdl(); - - - if (TTF_Init()) { printf("TTF_Init: %s\n", TTF_GetError()); } @@ -783,10 +796,10 @@ int main (int argc, char **argv) { SDL_Rect area; area.x = 0; area.y = 0; - area.w = 640; - area.h = 480; + area.w = SCREENW; + area.h = SCREENH; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,fcol.r,fcol.g,fcol.b)); - flip(); + flip(B_TRUE); } } } @@ -827,8 +840,8 @@ int main (int argc, char **argv) { SDL_Rect area; area.x = 0; area.y = 0; - area.w = 640; - area.h = 480; + area.w = SCREENW; + area.h = SCREENH; // screen fades from white to black val = 255 - globtimer; @@ -933,8 +946,8 @@ int main (int argc, char **argv) { area.x = 0; area.y = 0; - area.w = 640; - area.h = 480; + area.w = SCREENW; + area.h = SCREENH; // clear screen SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); @@ -979,13 +992,13 @@ int main (int argc, char **argv) { if (paused) { SDL_Rect area; // show that we are paused - area.x = (640/2) - (pausedshadow->w/2) - 2; - area.y = (480/2) - (pausedshadow->h/2) + 2; + area.x = (SCREENW/2) - (pausedshadow->w/2) - 2; + area.y = (SCREENH/2) - (pausedshadow->h/2) + 2; area.w = 0; area.h = 0; SDL_BlitSurface(pausedshadow, NULL, screen, &area); - area.x = (640/2) - (pausedtext->w/2); - area.y = (480/2) - (pausedtext->h/2); + area.x = (SCREENW/2) - (pausedtext->w/2); + area.y = (SCREENH/2) - (pausedtext->h/2); area.w = 0; area.h = 0; SDL_BlitSurface(pausedtext, NULL, screen, &area); @@ -1004,14 +1017,14 @@ int main (int argc, char **argv) { amt = (rand() % 20)+1; area.x = 0; area.y = amt; - area.w = 640; - area.h = 480-amt; + area.w = SCREENW; + area.h = SCREENH-amt; SDL_BlitSurface(screen, &area, screen, NULL); area.x = 0; - area.y = 480-amt; - area.w = 640; + area.y = SCREENH-amt; + area.w = SCREENW; area.h = amt; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); } @@ -1045,15 +1058,15 @@ int main (int argc, char **argv) { amt = (rand() % 20)+1; area.x = amt; area.y = 0; - area.w = 640-amt; - area.h = 480; + area.w = SCREENW-amt; + area.h = SCREENH; SDL_BlitSurface(screen, &area, screen, NULL); - area.x = 640-amt; + area.x = SCREENW-amt; area.y = 0; area.w = amt; - area.h = 480; + area.h = SCREENH; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); } @@ -1061,7 +1074,7 @@ int main (int argc, char **argv) { // create rat if (timer % 10 == 0) { if (countmonsters(-1) < 8) { // max 7 rats + king rat - puffin(P_RAT, rand() % (640-(TILEW*8))+(TILEW*4), TILEH, "gen_rat",0); + puffin(P_RAT, rand() % (SCREENW-(TILEW*8))+(TILEW*4), TILEH, "gen_rat",0); } } @@ -1080,14 +1093,14 @@ int main (int argc, char **argv) { // offset screen upwards area.x = 0; area.y = amt; - area.w = 640; - area.h = 480-amt; + area.w = SCREENW; + area.h = SCREENH-amt; SDL_BlitSurface(screen, &area, screen, NULL); // fill in empty bit area.x = 0; - area.y = 480-amt; - area.w = 640; + area.y = SCREENH-amt; + area.w = SCREENW; area.h = amt; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); } @@ -1137,14 +1150,14 @@ int main (int argc, char **argv) { // offset screen upwards area.x = 0; area.y = amt; - area.w = 640; - area.h = 480-amt; + area.w = SCREENW; + area.h = SCREENH-amt; SDL_BlitSurface(screen, &area, screen, NULL); // fill in empty bit area.x = 0; - area.y = 480-amt; - area.w = 640; + area.y = SCREENH-amt; + area.w = SCREENW; area.h = amt; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); } @@ -1188,7 +1201,7 @@ printf("timer = %d\n",timer); sprite_t *ss; int x,y; // spawn a new fruit - x = (rand() % (640-(TILEW*2))) + TILEW; + x = (rand() % (SCREENW-(TILEW*2))) + TILEW; y = 0; ss = addsprite(fruittypes[curfruittype], x,y, "fruit_endgame"); incfruittype(); @@ -1254,7 +1267,7 @@ printf("timer = %d\n",timer); /********************************************** * Update the screen */ - flip(); + flip(B_TRUE); /********************************************** @@ -1572,18 +1585,18 @@ void tick(void) { case D_RIGHT: default: x = TILEW/2; - y = rand() % 480; + y = rand() % SCREENH; break; case D_LEFT: - x = 640-(TILEW/2); - y = rand() % 480; + x = SCREENW-(TILEW/2); + y = rand() % SCREENH; break; case D_UP: - x = rand() % 640; - y = 480-(TILEW/2); + x = rand() % SCREENW; + y = SCREENH-(TILEW/2); break; case D_DOWN: - x = rand() % 640; + x = rand() % SCREENW; y = TILEW/2; break; } @@ -1830,14 +1843,14 @@ void nextlevel(void) { // make players face the correct way if (player) { - if (player->x < (640/2)) { + if (player->x < (SCREENW/2)) { player->dir = D_RIGHT; } else { player->dir = D_LEFT; } } if (player2) { - if (player2->x < (640/2)) { + if (player2->x < (SCREENW/2)) { player2->dir = D_RIGHT; } else { player2->dir = D_LEFT; @@ -2175,19 +2188,19 @@ void die(sprite_t *s) { // give a permenant powerup! switch (s->id) { case P_KINGRAT: - addsprite(P_BIGSPEED, (640/2), 0, "bigspeed"); + addsprite(P_BIGSPEED, (SCREENW/2), 0, "bigspeed"); break; case P_KINGSNAIL: - addsprite(P_BIGSCUBA, (640/2), 0, "bigscuba"); + addsprite(P_BIGSCUBA, (SCREENW/2), 0, "bigscuba"); break; case P_KINGFLY: - addsprite(P_SUPERUMBRELLA, (640/2), 0, "bigumbrella"); + addsprite(P_SUPERUMBRELLA, (SCREENW/2), 0, "bigumbrella"); break; case P_KINGANT: - addsprite(P_BIGHELMET, (640/2), 0, "bighelmet"); + addsprite(P_BIGHELMET, (SCREENW/2), 0, "bighelmet"); break; case P_KINGCAT: - addsprite(P_BIGCHEST, (640/2), 0, "bigchest"); + addsprite(P_BIGCHEST, (SCREENW/2), 0, "bigchest"); break; } } else if ((s->id == P_SNAIL) && (s->lives > 0)) { // snails can't die but turn into slugs instead @@ -2840,9 +2853,9 @@ void bouncesprite(sprite_t *s) { s->x += s->xs; s->y += s->ys; - if (s->x >= (640-TILEW-(s->img->w/2))) { + if (s->x >= (SCREENW-TILEW-(s->img->w/2))) { // move back onto screen - while (s->x >= (640-TILEW-(s->img->w/2))) { + while (s->x >= (SCREENW-TILEW-(s->img->w/2))) { s->x--; } if (s->xs > 0) s->xs = -s->xs; // reverse direction @@ -2856,8 +2869,8 @@ void bouncesprite(sprite_t *s) { s->bounces++; } - if (s->y >= (480-(s->img->h/2))) { - while (s->y >= (480-(s->img->h/2))) { + if (s->y >= (SCREENH-(s->img->h/2))) { + while (s->y >= (SCREENH-(s->img->h/2))) { s->y--; } if (s->ys > 0) s->ys = -s->ys; // reverse direction @@ -2936,8 +2949,8 @@ int movesprite(sprite_t *s) { s->y = s->img->h; } } - if (s->x > (640 - s->img->w/2)) { - s->x = 640 - s->img->w/2; + if (s->x > (SCREENW - s->img->w/2)) { + s->x = SCREENW - s->img->w/2; } if (s->x < (s->img->w/2)) { s->x = s->img->w/2; @@ -3007,7 +3020,7 @@ int movesprite(sprite_t *s) { } /* if we've fallen off the bottom... */ - if (s->y >= (480+s->img->h)) { + if (s->y >= (SCREENH+s->img->h)) { /* pause before respawning */ s->jumpspeed = 0; /* this is now a timer */ s->dead = D_LASTBOUNCE; @@ -3054,7 +3067,7 @@ int movesprite(sprite_t *s) { y = ty*TILEH - 2; /* make sure it's within the screen */ - if (x > (640-TILEW)) x = 640-TILEW; + if (x > (SCREENW-TILEW)) x = SCREENW-TILEW; if (x < (TILEW)) x = TILEW; if (s->quickdie || (isonground(s) && !isongroundpoint(s, s->x, s->y-TILEH))) { @@ -3524,7 +3537,7 @@ int movesprite(sprite_t *s) { s->y = s->y + s->ys; // if off screen - if ((s->x >= 640 - s->img->w/2) || (s->x <= s->img->w/2) || (s->y <= 0) || (s->y >= 480+s->img->h)) { + if ((s->x >= SCREENW - s->img->w/2) || (s->x <= s->img->w/2) || (s->y <= 0) || (s->y >= SCREENH+s->img->h)) { // die s->dead = D_FINAL; } @@ -3556,7 +3569,7 @@ int movesprite(sprite_t *s) { } // if off screen - if (s->y >= (480 + s->img->h)) { + if (s->y >= (SCREENH + s->img->h)) { // die s->dead = D_FINAL; } @@ -3738,7 +3751,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -3843,7 +3856,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -3938,7 +3951,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -4029,7 +4042,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -4153,7 +4166,7 @@ int movesprite(sprite_t *s) { if (xdiff <= (TILEW*8)) { move = B_TRUE; } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -4317,7 +4330,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -4757,7 +4770,7 @@ int movesprite(sprite_t *s) { /* can we move? */ - if (s->x >= 640 - (s->img->w/2) - 2) { + if (s->x >= SCREENW - (s->img->w/2) - 2) { /* turn */ s->xs = -abs(s->xs); } else if (s->x <= (s->img->w/2)) { @@ -4767,7 +4780,7 @@ int movesprite(sprite_t *s) { if (s->y <= s->img->h) { s->ys = abs(s->ys); - } else if (s->y >= 480-2 ) { + } else if (s->y >= SCREENH-2 ) { s->ys = -abs(s->ys); } @@ -4807,8 +4820,8 @@ int movesprite(sprite_t *s) { s->timer2--; if (s->timer2 <= 0) { - if ((s->y >= s->img->h*4) && (s->y <= (480-s->img->h*2))) { - if ((s->x >= s->img->w) && (s->x <= 640-(s->img->w))) { + if ((s->y >= s->img->h*4) && (s->y <= (SCREENH-s->img->h*2))) { + if ((s->x >= s->img->w) && (s->x <= SCREENW-(s->img->w))) { if (s->timer1 == KFS_FLY1) { s->timer1 = KFS_HORZWAIT; s->timer3 = s->y; @@ -4851,7 +4864,7 @@ int movesprite(sprite_t *s) { for (ss = sprite ; ss ; ss = ss->next) { if ((ss->id == P_FLY) && (ss->owner == s)) { ss->timer1 = KFS_HORZPUSH; - ss->timer2 = n * (640/(numflies+1)); // target x + ss->timer2 = n * (SCREENW/(numflies+1)); // target x //printf("setting target to %d\n",ss->timer2); n++; } @@ -4942,7 +4955,7 @@ int movesprite(sprite_t *s) { for (ss = sprite ; ss ; ss = ss->next) { if ((ss->id == P_FLY) && (ss->owner == s)) { ss->timer1 = KFS_VERTPUSH; - ss->timer2 = n * (480/(numflies+1)); // target x + ss->timer2 = n * (SCREENH/(numflies+1)); // target x //printf("setting target to y = %d\n",ss->timer2); n++; } @@ -5097,7 +5110,7 @@ int movesprite(sprite_t *s) { nextstate = KAS_WAITFORTOP1; } else { jumpheight = 3; - jumptarget = 480 - (TILEH*3); // jump to bottom + jumptarget = SCREENH - (TILEH*3); // jump to bottom nextstate = KAS_WAITFORTOP2; } @@ -5190,7 +5203,7 @@ int movesprite(sprite_t *s) { } else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*10))) { jump(s,D_LEFT); } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -5500,7 +5513,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -5696,7 +5709,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -5921,7 +5934,7 @@ int movesprite(sprite_t *s) { jump(s,D_LEFT); } } - } else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) { + } else if (level->bottomopen && (s->y >= (SCREENH - 100)) && isplayerabove(s)) { // if near bottom of the screen and can fall through... move = B_TRUE; } @@ -6120,7 +6133,7 @@ int movesprite(sprite_t *s) { /* can we move? */ - if (s->x >= 640 - (boss->img->w/2) - 2) { + if (s->x >= SCREENW - (boss->img->w/2) - 2) { /* turn */ s->xs = -abs(s->xs); } else if (s->x <= (boss->img->w/2)) { @@ -6130,7 +6143,7 @@ int movesprite(sprite_t *s) { if (s->y <= boss->img->h) { s->ys = abs(s->ys); - } else if (s->y >= 480-2 ) { + } else if (s->y >= SCREENH-2 ) { s->ys = -abs(s->ys); } @@ -6385,7 +6398,7 @@ int movesprite(sprite_t *s) { } /* if on ground, go up */ - if (!s->flies && (isonground(s) || (s->y >= (480-TILEH) ) )) { + if (!s->flies && (isonground(s) || (s->y >= (SCREENH-TILEH) ) )) { s->flies = B_TRUE; s->falling = B_FALSE; s->ys = -getspeed(s); @@ -6477,7 +6490,7 @@ int movesprite(sprite_t *s) { } // die if it leaves screen - if (s->x >= (640-TILEW)) { + if (s->x >= (SCREENW-TILEW)) { s->dead = D_FINAL; } else if (s->x <= TILEW) { s->dead = D_FINAL; @@ -6487,7 +6500,7 @@ int movesprite(sprite_t *s) { s->y = s->y + s->ys; // if off screen - if ((s->xs > 0) && (s->x >= (640 - s->img->w))) { + if ((s->xs > 0) && (s->x >= (SCREENW - s->img->w))) { s->dead = D_FINAL; } else if ((s->xs < 0) && (s->x <= (s->img->w))) { s->dead = D_FINAL; @@ -6505,18 +6518,18 @@ int movesprite(sprite_t *s) { s->x += s->xs; s->y += s->ys; // die if it leaves screen - if (s->x >= (640-TILEW)) { + if (s->x >= (SCREENW-TILEW)) { s->dead = D_FINAL; } else if (s->x <= TILEW) { s->dead = D_FINAL; - } else if (s->y >= (480+(s->img->h))) { + } else if (s->y >= (SCREENH+(s->img->h))) { s->dead = D_FINAL; } else if (s->y <= TILEH) { s->dead = D_FINAL; } } else if (s->id == P_RAYGUNBULLET) { s->x += s->xs; - if (s->x >= (640-TILEW)) { + if (s->x >= (SCREENW-TILEW)) { s->dead = D_FINAL; } else if (s->x <= TILEW) { s->dead = D_FINAL; @@ -6608,8 +6621,8 @@ int movesprite(sprite_t *s) { // should never happen, but... if (s->x < 0) s->x = 320; if (s->y < 0) s->y = 240; - if (s->x >= 640) s->x = 320; - if (s->y >= 480) s->y = 240; + if (s->x >= SCREENW) s->x = 320; + if (s->y >= SCREENH) s->y = 240; // stick player to us s->owner->x = s->x; @@ -6653,11 +6666,11 @@ int movesprite(sprite_t *s) { s->y += s->ys; // keep on screen (but use player height - if (s->x > 640-(s->img->w/2)) { - s->x = 640 - (s->img->w/2); + if (s->x > SCREENW-(s->img->w/2)) { + s->x = SCREENW - (s->img->w/2); } - if (s->y > 480-(s->img->h/2)) { - s->y = 480 - (s->img->h/2); + if (s->y > SCREENH-(s->img->h/2)) { + s->y = SCREENH - (s->img->h/2); } if (s->x < s->img->w/2) { s->x = s->img->w/2; @@ -6740,19 +6753,19 @@ int movesprite(sprite_t *s) { s->x += s->xs; s->y += s->ys; - if (s->x >= (640 - s->img->w/2)) { + if (s->x >= (SCREENW - s->img->w/2)) { s->xs = -s->xs; - s->x = 640 - s->img->w/2; + s->x = SCREENW - s->img->w/2; } if (s->x <= (s->img->w/2)) { s->xs = -s->xs; s->x = s->img->w/2; } - //if (s->y >= (480 - s->img->h)) { - if (s->y >= 480-1) { + //if (s->y >= (SCREENH - s->img->h)) { + if (s->y >= SCREENH-1) { s->ys = -s->ys; - //s->y = 480 - s->img->h; - s->y = 480-1; + //s->y = SCREENH - s->img->h; + s->y = SCREENH-1; } if (s->y <= (s->img->h)) { s->ys = -s->ys; @@ -6795,7 +6808,7 @@ int movesprite(sprite_t *s) { if (abs(who->y - s->y) <= (TILEH)) { double dis; double spd; - dis = abs(who->x - s->x); // ie. 0 - 640 + dis = abs(who->x - s->x); // ie. 0 - SCREENW if (dis <= 320) { spd = dis / 45; // ie. 0 - 10 // now reverse it (so the closer it is, the faster it goes) @@ -6815,7 +6828,7 @@ int movesprite(sprite_t *s) { if (abs(who->y - s->y) <= (TILEH)) { double dis; double spd; - dis = abs(who->x - s->x); // ie. 0 - 640 + dis = abs(who->x - s->x); // ie. 0 - SCREENW if (dis <= 320) { spd = dis / 45; // ie. 0 - 10 // now reverse it (so the closer it is, the faster it goes) @@ -6839,7 +6852,7 @@ int movesprite(sprite_t *s) { if (s->ys > ENDGAMEFALLSPEED) s->ys = ENDGAMEFALLSPEED; // if off screen - if (s->y >= (480 + s->img->h)) { + if (s->y >= (SCREENH + s->img->h)) { // die s->dead = D_FINAL; } @@ -7051,32 +7064,34 @@ void dotileeffects(sprite_t *s) { // initial transition to a new level void drawlevel(void) { int x,y,i; - int dstx[2],dsty[2],xdis[2],ydis[2]; double turns; - double pspeed[2]; double dist[2]; - SDL_Rect area,dst; int speed = 16; - SDL_Surface *playerbg = NULL, *playerbg2 = NULL; - SDL_Surface *cloudbg = NULL,*cloudbg2 = NULL; + //SDL_Surface *playerbg = NULL, *playerbg2 = NULL; + //SDL_Surface *cloudbg = NULL,*cloudbg2 = NULL; + SDL_Surface *screencopy = NULL; int got1p = B_FALSE,got2p = B_FALSE; - sprite_t tempcloud, tempcloud2; - sprite_t *cloud = NULL, *cloud2 = NULL; + levscrollinfo_t scrollinfo; if (temps) { SDL_FreeSurface(temps); temps = NULL; } - temps = SDL_CreateRGBSurface(SDL_SWSURFACE, - 640, 480, + temps = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREENW, SCREENH, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, screen->format->Amask); - SDL_DisplayFormat(temps); + // no alpha mask on screen copy - otherwise we'll need to draw + // black all over it to make clear out alpha channel. + screencopy = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREENW, SCREENH, + screen->format->BitsPerPixel, screen->format->Rmask, + screen->format->Gmask,screen->format->Bmask, 0); + SDL_DisplayFormat(screencopy); + if (player && player->lives > 0) got1p = B_TRUE; if (player2 && player2->lives > 0) got2p = B_TRUE; @@ -7086,109 +7101,87 @@ void drawlevel(void) { return; } + // initialise values so we don't accidentally use them + // uninitialied... + scrollinfo.player = player; + scrollinfo.player2 = player2; + scrollinfo.cloud = NULL; + scrollinfo.cloud2 = NULL; + for (i = 0; i < 2; i++) { + scrollinfo.dstx[i] = 0; + scrollinfo.dsty[i] = 0; + scrollinfo.xdis[i] = 0; + scrollinfo.ydis[i] = 0; + scrollinfo.pspeed[i] = 1; + } + + // init clouds if (got1p) { - cloud = &tempcloud; - cloud->id = P_PINKCLOUD; - cloud->iceimg = NULL; - setdefaults(cloud); + scrollinfo.cloud = &tempcloud; + scrollinfo.cloud->id = P_PINKCLOUD; + scrollinfo.cloud->iceimg = NULL; + setdefaults(scrollinfo.cloud); // redo image - cloud->img =rotozoomSurfaceXY(imageset[P_PINKCLOUD].img[F_WALK1],0,1,1,0); + scrollinfo.cloud->img =rotozoomSurfaceXY(imageset[P_PINKCLOUD].img[F_WALK1],0,1,1,0); // set player image player->img = imageset[player->id].img[F_SHOOT]; - // create buffer for player background - playerbg = SDL_CreateRGBSurface(SDL_SWSURFACE, - player->img->w+1, player->img->h+1, - screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask,screen->format->Bmask, - screen->format->Amask); - SDL_DisplayFormat(playerbg); - // create buffer for cloud background - cloudbg = SDL_CreateRGBSurface(SDL_SWSURFACE, - cloud->img->w+1, cloud->img->h+1, - screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask,screen->format->Bmask, - screen->format->Amask); - SDL_DisplayFormat(cloudbg); } if (got2p) { - cloud2 = &tempcloud2; - cloud2->id = P_PINKCLOUD; - cloud2->iceimg = NULL; - setdefaults(cloud2); + scrollinfo.cloud2 = &tempcloud2; + scrollinfo.cloud2->id = P_PINKCLOUD; + scrollinfo.cloud2->iceimg = NULL; + setdefaults(scrollinfo.cloud2); // redo image - cloud2->img =rotozoomSurfaceXY(imageset[P_PINKCLOUD].img[F_WALK1],0,1,1,0); + scrollinfo.cloud2->img =rotozoomSurfaceXY(imageset[P_PINKCLOUD].img[F_WALK1],0,1,1,0); // set player image player2->img = imageset[player2->id].img[F_SHOOT]; - // create buffer for player background - playerbg2 = SDL_CreateRGBSurface(SDL_SWSURFACE, - player2->img->w+1, player2->img->h+1, - screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask,screen->format->Bmask, - screen->format->Amask); - SDL_DisplayFormat(playerbg2); - // create buffer for cloud background - cloudbg2 = SDL_CreateRGBSurface(SDL_SWSURFACE, - cloud2->img->w+1, cloud2->img->h+1, - screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask,screen->format->Bmask, - screen->format->Amask); - SDL_DisplayFormat(cloudbg2); - } - - // draw the full level onto the temporary surface + // draw the full (new) level onto the temporary surface for (x = 0; x < LEVELW; x++) { for (y = 0; y < LEVELH; y++) { drawtile(temps,x,y); } } - // initialise values so we don't accidentally use them - // uninitialied... - for (i = 0; i < 2; i++) { - dstx[i] = 0; - dsty[i] = 0; - xdis[i] = 0; - ydis[i] = 0; - pspeed[i] = 1; - } // figure out where the players' new start positions are if (player) { - dstx[0] = (curlevel->p1x * TILEW) + (TILEW/2); - dsty[0] = (curlevel->p1y * TILEH) + TILEH-2; + scrollinfo.dstx[0] = (curlevel->p1x * TILEW) + (TILEW/2); + scrollinfo.dsty[0] = (curlevel->p1y * TILEH) + TILEH-2; } if (player2) { - dstx[1] = (curlevel->p2x * TILEW) + (TILEW/2); - dsty[1] = (curlevel->p2y * TILEH) + TILEH-2; + scrollinfo.dstx[1] = (curlevel->p2x * TILEW) + (TILEW/2); + scrollinfo.dsty[1] = (curlevel->p2y * TILEH) + TILEH-2; } // figure out distance to newposition if (player) { - xdis[0] = player->x - dstx[0]; if (xdis[0] < 0) xdis[0] = -xdis[0]; - ydis[0] = player->y - dsty[0]; if (ydis[0] < 0) ydis[0] = -ydis[0]; + scrollinfo.xdis[0] = player->x - scrollinfo.dstx[0]; + if (scrollinfo.xdis[0] < 0) scrollinfo.xdis[0] = -scrollinfo.xdis[0]; + scrollinfo.ydis[0] = player->y - scrollinfo.dsty[0]; + if (scrollinfo.ydis[0] < 0) scrollinfo.ydis[0] = -scrollinfo.ydis[0]; } if (player2) { - xdis[1] = player2->x - dstx[1]; if (xdis[1] < 0) xdis[1] = -xdis[1]; - ydis[1] = player2->y - dsty[1]; if (ydis[1] < 0) ydis[1] = -ydis[1]; + scrollinfo.xdis[1] = player2->x - scrollinfo.dstx[1]; + if (scrollinfo.xdis[1] < 0) scrollinfo.xdis[1] = -scrollinfo.xdis[1]; + scrollinfo.ydis[1] = player2->y - scrollinfo.dsty[1]; + if (scrollinfo.ydis[1] < 0) scrollinfo.ydis[1] = -scrollinfo.ydis[1]; } - - // figure out how many loops it will take to scroll to the next level switch (oldexitdir) { case D_LEFT: case D_RIGHT: speed = 16; - turns = 640 / speed; + turns = SCREENW / speed; break; case D_UP: case D_DOWN: default: speed = 12; - turns = 480 / speed; + turns = SCREENH / speed; break; } //turns -= 2; // just to be safe @@ -7197,426 +7190,70 @@ void drawlevel(void) { // figure out how fast player needs to move to get there in time if (player) { - dist[0] = sqrt((xdis[0]*xdis[0]) + (ydis[0]*ydis[0])); - pspeed[0] = dist[0] / turns; + dist[0] = sqrt((scrollinfo.xdis[0]*scrollinfo.xdis[0]) + (scrollinfo.ydis[0]*scrollinfo.ydis[0])); + scrollinfo.pspeed[0] = dist[0] / turns; } if (player2) { - dist[1] = sqrt((xdis[1]*xdis[1]) + (ydis[1]*ydis[1])); - pspeed[1] = dist[1] / turns; + dist[1] = sqrt((scrollinfo.xdis[1]*scrollinfo.xdis[1]) + (scrollinfo.ydis[1]*scrollinfo.ydis[1])); + scrollinfo.pspeed[1] = dist[1] / turns; } // just to be sure //pspeed += 1; - + + // The overall plan here is: + // - Move player(s) + cloud(s) to new position + // - shuffle screen along + // - blit the next column of the new level in place + if (oldexitdir == D_LEFT) { - // blit a column at a time to the real screen, shuffling - // the real one along. - for (x = 0; x < 640; x += speed) { - // move player - if (player && player->lives > 0) moveto(player,dstx[0],dsty[0],pspeed[0],pspeed[0]); - if (player2 && player2->lives > 0) moveto(player2,dstx[1],dsty[1],pspeed[1],pspeed[1]); - // set cloud location - if (player && player->lives > 0) { - cloud->x = player->x; - cloud->y = player->y + (cloud->img->h / 2); - } - if (player2 && player2->lives > 0) { - cloud2->x = player2->x; - cloud2->y = player2->y + (cloud2->img->h / 2); - } + for (x = 0; x < SCREENW; x += speed) { + leveltransition_moveplayer(&scrollinfo); - // shuffle real screen - area.x = 0; - area.y = 0; - area.w = 640-speed; - area.h = 480; + leveltransition_scrolllevel( 0, 0, SCREENW-speed, SCREENH, + speed, 0, 0, 0, + SCREENW-x, 0, speed, SCREENH, + 0, 0, 0, 0); - dst.x = speed; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(screen, &area, screen, &dst); - - // blit next column from temp surface (take last column first) - area.x = 640-x; - area.y = 0; - area.w = speed; - area.h = 480; - - dst.x = 0; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(temps, &area, screen, &dst); - - // remember area behind players - if (player && player->lives > 0) { - player->img = imageset[player->id].img[F_SHOOT]; - grabbehind(player, playerbg); - grabbehind(cloud, cloudbg); - } - if (player2 && player2->lives > 0) { - player2->img = imageset[player2->id].img[F_SHOOT]; - grabbehind(player2, playerbg2); - grabbehind(cloud2, cloudbg2); - } - - // draw player - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - drawsprite(player); - drawsprite(cloud); - } - if (player2 && player2->lives > 0) { - drawsprite(player2); - drawsprite(cloud2); - } - } - - // update screen - //SDL_GL_SwapBuffers(); - SDL_UpdateRect(screen, 0,0,640,480); - if (!paused) { - SDL_framerateDelay(&manager); - } - - // remove players - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - area.x = player->x - player->img->w/2; - area.y = player->y - player->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg, NULL, screen, &area ); - area.x = cloud->x - cloud->img->w/2; - area.y = cloud->y - cloud->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg, NULL, screen, &area ); - } - if (player2 && player2->lives > 0) { - area.x = player2->x - player2->img->w/2; - area.y = player2->y - player2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg2, NULL, screen, &area ); - area.x = cloud2->x - cloud2->img->w/2; - area.y = cloud2->y - cloud2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg2, NULL, screen, &area ); - } - } + leveltransition_blit(&scrollinfo, screencopy); } } else if (oldexitdir == D_UP) { - // blit a row at a time to the real screen, shuffling - // the real one along. - for (y = 0; y < 480; y += speed) { - // move player - if (player && player->lives > 0) moveto(player,dstx[0],dsty[0],pspeed[0],pspeed[0]); - if (player2 && player2->lives > 0) moveto(player2,dstx[1],dsty[1],pspeed[1],pspeed[1]); - // set cloud location - if (player && player->lives > 0) { - cloud->x = player->x; - cloud->y = player->y + (cloud->img->h / 2); - } - if (player2 && player2->lives > 0) { - cloud2->x = player2->x; - cloud2->y = player2->y + (cloud2->img->h / 2); - } + for (y = 0; y < SCREENH; y += speed) { + leveltransition_moveplayer(&scrollinfo); - // shuffle real screen - area.x = 0; - area.y = 0; - area.w = 640; - area.h = 480-speed; + leveltransition_scrolllevel( 0, 0, SCREENW, SCREENH-speed, + 0, speed, 0, 0, + 0, SCREENH-y, SCREENW, speed, + 0, 0, 0, 0); - dst.x = 0; - dst.y = speed; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(screen, &area, screen, &dst); - - // blit next row from temp surface (take last column first) - area.x = 0; - area.y = 480-y; - area.w = 640; - area.h = speed; - - dst.x = 0; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(temps, &area, screen, &dst); - - // remember area behind player - if (player && player->lives > 0) { - player->img = imageset[player->id].img[F_SHOOT]; - grabbehind(player, playerbg); - grabbehind(cloud, cloudbg); - } - if (player2 && player2->lives > 0) { - player2->img = imageset[player2->id].img[F_SHOOT]; - grabbehind(player2, playerbg2); - grabbehind(cloud2, cloudbg2); - } - - - // draw player - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - drawsprite(player); - drawsprite(cloud); - } - if (player2 && player2->lives > 0) { - drawsprite(player2); - drawsprite(cloud2); - } - } - - // update screen - //SDL_GL_SwapBuffers(); - SDL_UpdateRect(screen, 0,0,640,480); - if (!paused) SDL_framerateDelay(&manager); - - // remove players - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - area.x = player->x - player->img->w/2; - area.y = player->y - player->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg, NULL, screen, &area ); - area.x = cloud->x - cloud->img->w/2; - area.y = cloud->y - cloud->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg, NULL, screen, &area ); - } - if (player2 && player2->lives > 0) { - area.x = player2->x - player2->img->w/2; - area.y = player2->y - player2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg2, NULL, screen, &area ); - area.x = cloud2->x - cloud2->img->w/2; - area.y = cloud2->y - cloud2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg2, NULL, screen, &area ); - } - } + leveltransition_blit(&scrollinfo, screencopy); } } else if (oldexitdir == D_DOWN) { - // blit a row at a time to the real screen, shuffling - // the real one along. - for (y = 0; y < 480; y += speed) { - // move player - if (player && player->lives > 0) moveto(player,dstx[0],dsty[0],pspeed[0],pspeed[0]); - if (player2 && player2->lives > 0) moveto(player2,dstx[1],dsty[1],pspeed[1],pspeed[1]); - // set cloud location - if (player && player->lives > 0) { - cloud->x = player->x; - cloud->y = player->y + (cloud->img->h / 2); - } - if (player2 && player2->lives > 0) { - cloud2->x = player2->x; - cloud2->y = player2->y + (cloud2->img->h / 2); - } + for (y = 0; y < SCREENH; y += speed) { + leveltransition_moveplayer(&scrollinfo); - // shuffle real screen - area.x = 0; - area.y = speed; - area.w = 640; - area.h = 480-speed; - - dst.x = 0; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(screen, &area, screen, &dst); - - // blit next row from temp surface (take last column first) - area.x = 0; - area.y = y; - area.w = 640; - area.h = speed; - - dst.x = 0; - dst.y = 480-speed; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(temps, &area, screen, &dst); - - // remember area behind players - if (player && player->lives > 0) { - player->img = imageset[player->id].img[F_SHOOT]; - grabbehind(player, playerbg); - grabbehind(cloud, cloudbg); - } - if (player2 && player2->lives > 0) { - player2->img = imageset[player2->id].img[F_SHOOT]; - grabbehind(player2, playerbg2); - grabbehind(cloud2, cloudbg2); - } - - // draw player - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - drawsprite(player); - drawsprite(cloud); - } - if (player2 && player2->lives > 0) { - drawsprite(player2); - drawsprite(cloud2); - } - } - - // update screen - //SDL_GL_SwapBuffers(); - SDL_UpdateRect(screen, 0,0,640,480); - if (!paused) SDL_framerateDelay(&manager); - - - // remove players - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - area.x = player->x - player->img->w/2; - area.y = player->y - player->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg, NULL, screen, &area ); - area.x = cloud->x - cloud->img->w/2; - area.y = cloud->y - cloud->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg, NULL, screen, &area ); - } - if (player2 && player2->lives > 0) { - area.x = player2->x - player2->img->w/2; - area.y = player2->y - player2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg2, NULL, screen, &area ); - area.x = cloud2->x - cloud2->img->w/2; - area.y = cloud2->y - cloud2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg2, NULL, screen, &area ); - } - } + leveltransition_scrolllevel( 0, speed, SCREENW, SCREENH-speed, + 0, 0, 0, 0, + 0, y, SCREENW, speed, + 0, SCREENH-speed, 0, 0); + + leveltransition_blit(&scrollinfo, screencopy); } } else { // RIGHT right, or default - // blit a column at a time to the real screen, shuffling - // the real one along. - for (x = 0; x < 640; x += speed) { - // move player - if (player && player->lives > 0) moveto(player,dstx[0],dsty[0],pspeed[0],pspeed[0]); - if (player2 && player2->lives > 0) moveto(player2,dstx[1],dsty[1],pspeed[1],pspeed[1]); - // set cloud location - if (player && player->lives > 0) { - cloud->x = player->x; - cloud->y = player->y + (cloud->img->h / 2); - } - if (player2 && player2->lives > 0) { - cloud2->x = player2->x; - cloud2->y = player2->y + (cloud2->img->h / 2); - } + for (x = 0; x < SCREENW; x += speed) { + leveltransition_moveplayer(&scrollinfo); - // shuffle real screen - area.x = speed; - area.y = 0; - area.w = 640-speed; - area.h = 480; + leveltransition_scrolllevel( speed, 0, SCREENW-speed, SCREENH, + 0, 0, 0, 0, + x, 0, speed, SCREENW, + SCREENW-speed, 0, 0, 0); - dst.x = 0; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(screen, &area, screen, &dst); - - // blit next column from temp surface (take last column first) - area.x = x; - area.y = 0; - area.w = speed; - area.h = 480; - - dst.x = 640-speed; - dst.y = 0; - dst.w = 0; - dst.h = 0; - SDL_BlitSurface(temps, &area, screen, &dst); - - // remember area behind players - if (player && player->lives > 0) { - player->img = imageset[player->id].img[F_SHOOT]; - grabbehind(player, playerbg); - grabbehind(cloud, cloudbg); - } - if (player2 && player2->lives > 0) { - player2->img = imageset[player2->id].img[F_SHOOT]; - grabbehind(player2, playerbg2); - grabbehind(cloud2, cloudbg2); - } - - // draw player - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - drawsprite(player); - drawsprite(cloud); - } - if (player2 && player2->lives > 0) { - drawsprite(player2); - drawsprite(cloud2); - } - } - - // update screen - //SDL_GL_SwapBuffers(); - SDL_UpdateRect(screen, 0,0,640,480); - if (!paused) SDL_framerateDelay(&manager); - - // remove players - if (curlevelnum != INTRO_LEVELNUM) { - if (player && player->lives > 0) { - area.x = player->x - player->img->w/2; - area.y = player->y - player->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg, NULL, screen, &area ); - area.x = cloud->x - cloud->img->w/2; - area.y = cloud->y - cloud->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg, NULL, screen, &area ); - } - if (player2 && player2->lives > 0) { - area.x = player2->x - player2->img->w/2; - area.y = player2->y - player2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(playerbg2, NULL, screen, &area ); - area.x = cloud2->x - cloud2->img->w/2; - area.y = cloud2->y - cloud2->img->h; - area.w = 0; - area.h = 0; - SDL_BlitSurface(cloudbg2, NULL, screen, &area ); - } - } + leveltransition_blit(&scrollinfo, screencopy); } } - if (player && player->lives > 0) { - SDL_FreeSurface(playerbg); - SDL_FreeSurface(cloudbg); - SDL_FreeSurface(cloud->img); - } - if (player2 && player2->lives > 0) { - SDL_FreeSurface(playerbg2); - SDL_FreeSurface(cloudbg2); - SDL_FreeSurface(cloud2->img); - } + SDL_BlitSurface(screencopy, NULL, screen, NULL); levelcomplete = B_FALSE; } @@ -7831,7 +7468,7 @@ void drawbosshealth(void) { maxhealth = getbosshealth(boss->id); - area.x = (640/2) - maxhealth*(healthbar[0]->w+HEALTHBARGAP); + area.x = (SCREENW/2) - maxhealth*(healthbar[0]->w+HEALTHBARGAP); area.y = HEALTHBARY; area.w = 0; area.h = 0; @@ -7990,7 +7627,7 @@ void drawscore(void) { /* shadow */ score = TTF_RenderText_Solid(font[TEXTSIZE_SCORE], tempm, black); - area.x = 640 - score->w - P1SCOREX - 2; + area.x = SCREENW - score->w - P1SCOREX - 2; area.y = SCOREY-2; area.w = 0; area.h = 0; @@ -7998,7 +7635,7 @@ void drawscore(void) { SDL_FreeSurface(score); /* score */ score = TTF_RenderText_Solid(font[TEXTSIZE_SCORE], tempm, scorecol); - area.x = 640 - score->w - P1SCOREX; + area.x = SCREENW - score->w - P1SCOREX; area.y = SCOREY; area.w = 0; area.h = 0; @@ -8010,7 +7647,7 @@ void drawscore(void) { if (player2->lives > 0) { // show 1 less than lives numtoshow = player2->lives-1; - area.x = 640 - P1LIVESX; + area.x = SCREENW - P1LIVESX; area.y = LIVESY; area.w = 0; area.h = 0; @@ -8040,7 +7677,7 @@ void drawscore(void) { area.x += (myhead->w + 3); } } else { - area.x = 640 - P1LIVESX - (myhead->w); + area.x = SCREENW - P1LIVESX - (myhead->w); area.y = LIVESY; area.w = 0; area.h = 0; @@ -8051,8 +7688,8 @@ void drawscore(void) { // cards if (levelcomplete != LV_DOPOKER) { - //area.x = 640 - CARDX - (5*(imageset[P_FIRSTCARD].img[F_WALK1]->w + 2)); - area.x = 640 - CARDX - (imageset[P_FIRSTCARD].img[F_WALK1]->w ); + //area.x = SCREENW - CARDX - (5*(imageset[P_FIRSTCARD].img[F_WALK1]->w + 2)); + area.x = SCREENW - CARDX - (imageset[P_FIRSTCARD].img[F_WALK1]->w ); area.y = CARDY; area.w = 0; area.h = 0; @@ -8109,14 +7746,14 @@ void drawtext(void) { if (t->x - (t->img->w / 2) < 2) { // left t->x = 2 + (t->img->w/2); } - if (t->x + (t->img->w / 2) > 640-2) { // right - t->x = 640-2 - (t->img->w/2); + if (t->x + (t->img->w / 2) > SCREENW-2) { // right + t->x = SCREENW-2 - (t->img->w/2); } if (t->y - (t->img->h / 2) < 2) { // top t->y = 2 + (t->img->h/2); } - if (t->y + (t->img->h / 2) > 480-2) { // bottom - t->y = 480-2 - (t->img->h/2); + if (t->y + (t->img->h / 2) > SCREENH-2) { // bottom + t->y = SCREENH-2 - (t->img->h/2); } @@ -8966,7 +8603,7 @@ void dogravity(sprite_t *s) { } else { // not jumping int ontheground; - if ((isfruit(s->id) == FT_SUPER) && (s->y < 480/2)) { + if ((isfruit(s->id) == FT_SUPER) && (s->y < SCREENH/2)) { ontheground = B_FALSE; } else { ontheground = isonground(s); @@ -9180,7 +8817,7 @@ void dogravity(sprite_t *s) { } netx = s->x + cos(s->slamangle-(180*(M_PI/180)))*dist*s->dir; nety = s->y + sin(s->slamangle-(180*(M_PI/180)))*dist; - if ((netx >= (640-TILEW)) || (netx <= TILEW)) { + if ((netx >= (SCREENW-TILEW)) || (netx <= TILEW)) { hitwall = B_TRUE; } @@ -9855,7 +9492,7 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) { for (i = 0; i < MINUPSTARS; i++) { sprite_t *ss; ss = addupstar(); - ss->y = (rand() % (480-(TILEH*2))) + TILEH; + ss->y = (rand() % (SCREENH-(TILEH*2))) + TILEH; } // all tiles become fruit for (ty = 0 ; ty < LEVELH; ty++) { @@ -10219,7 +9856,7 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) { wid = imageset[P_METEOR].img[0]->w; hei = imageset[P_METEOR].img[0]->h; for (n = 0; n < 7; n++) { - sp = addsprite(P_METEOR, rand() % (640 - (wid*2)) + (wid/2), - (rand() % (hei*7)), "meteor"); + sp = addsprite(P_METEOR, rand() % (SCREENW - (wid*2)) + (wid/2), - (rand() % (hei*7)), "meteor"); sp->ys = (rand() % METEORMAXSPEED)+2; } lastmet = sp; @@ -10523,7 +10160,7 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) { if (pp == player) { newc->timer2 = CARDX + (pp->numcards * (cardwidth+2)) + (cardwidth/2); } else if (pp == player2) { - int cardx2 = 640 - CARDX - (imageset[P_FIRSTCARD].img[F_WALK1]->w + 2); + int cardx2 = SCREENW - CARDX - (imageset[P_FIRSTCARD].img[F_WALK1]->w + 2); newc->timer2 = cardx2 - (pp->numcards * (cardwidth+2)) + (cardwidth/2); } newc->timer3 = CARDY + cardheight; @@ -11015,8 +10652,8 @@ sprite_t *addupstar(void) { sprite_t *ss; int x,y; // spawn a new star - x = (rand() % (640-(TILEW*2))) + TILEW; - y = 480; + x = (rand() % (SCREENW-(TILEW*2))) + TILEW; + y = SCREENH; ss = addsprite(P_UPSTAR, x, y, "upstar"); ss->xs = 0; ss->ys = (rand() % 4)+1; @@ -11306,7 +10943,7 @@ void checkwrap(sprite_t *s) { if (!s->dead) { if (!iseffect(s->id)) { /* if we've fallen off the bottom... */ - if (s->y > (480+s->img->h)) { + if (s->y > (SCREENH+s->img->h)) { if (inintro()) { // die s->dead = D_FINAL; @@ -11318,7 +10955,7 @@ void checkwrap(sprite_t *s) { /* if we've gone off the top */ if (s->y < -s->img->h) { // move to bottom - s->y = (480+s->img->h); + s->y = (SCREENH+s->img->h); } } } @@ -11386,7 +11023,11 @@ void togglefullscreen(void) { fullscreen = B_TRUE; } + #ifdef OPENGL + realscreen=SDL_SetVideoMode(realscreen->w,realscreen->h,realscreen->format->BitsPerPixel,SDL_SWSURFACE|SDL_OPENGL|(fullscreen?SDL_FULLSCREEN:0)); + #else screen=SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,SDL_SWSURFACE|(screen->flags&SDL_FULLSCREEN?0:SDL_FULLSCREEN)); + #endif // set title bar if required if (!fullscreen) { @@ -11399,10 +11040,31 @@ void togglefullscreen(void) { /* redo framerate manager */ SDL_setFramerate(&manager, WANTFPS); } + + gengl(screen); + blittoscreen(); } +#ifdef OPENGL +void initgl(void) { + glClearColor( 0, 0, 0, 0 ); + glDisable(GL_DEPTH_TEST); + glDepthFunc(GL_NEVER); + glEnable( GL_TEXTURE_2D ); // Need this to display a texture + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glViewport( 0, 0, SCREENW, SCREENH ); // set screen size + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( 0, SCREENW, SCREENH, 0, -1, 1 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} +#endif + void initsdl(void) { int i; + int wantbpp = 32; if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)==-1) { printf("SDL_Init: %s\n", SDL_GetError()); exit(1); @@ -11421,17 +11083,22 @@ void initsdl(void) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); //SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - screen = SDL_SetVideoMode(640,480,16,SDL_OPENGLBLIT|vidargs); + //screen = SDL_SetVideoMode(SCREENW,SCREENH,16,SDL_SWSURFACE|SDL_OPENGLBLIT|vidargs); + realscreen = SDL_SetVideoMode(SCREENW,SCREENH,wantbpp,SDL_SWSURFACE|SDL_OPENGL|vidargs); + + screen = SDL_CreateRGBSurface(SDL_SWSURFACE, realscreen->w, realscreen->h, wantbpp, rm, gm, bm ,am); + SDL_SetAlpha(screen, SDL_SRCALPHA, 0); #else - //screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_DOUBLEBUF|vidargs); + //screen = SDL_SetVideoMode(SCREENW,SCREENH,16,SDL_SWSURFACE|SDL_DOUBLEBUF|vidargs); // Try for 16 bit mode, but SDL_ANYFORMAT means that 32 bit is acceptable. - screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_ANYFORMAT|vidargs); + screen = SDL_SetVideoMode(SCREENW,SCREENH,wantbpp,SDL_SWSURFACE|SDL_ANYFORMAT|vidargs); + #endif // set drawpixel function based on what depth we ended up with - if (screen->format->BitsPerPixel == 32) { + if (realscreen->format->BitsPerPixel == 32) { drawpixel = drawpixel32; printf("32 bit mode in use.\n"); } else { @@ -11439,6 +11106,10 @@ void initsdl(void) { printf("16 bit mode in use.\n"); } + #ifdef OPENGL + initgl(); + #endif + // set title bar SDL_WM_SetCaption(progname, progname); @@ -11742,7 +11413,7 @@ void gaincard(sprite_t *s, int cardid) { if (s == player) { newsp = addsprite(P_FIVECARDS, CARDX, CARDY, "fivecards"); } else { - int cardx2 = 640 - CARDX - (5*(imageset[P_FIRSTCARD].img[F_WALK1]->w + 2)); + int cardx2 = SCREENW - CARDX - (5*(imageset[P_FIRSTCARD].img[F_WALK1]->w + 2)); newsp = addsprite(P_FIVECARDS, cardx2, CARDY, "fivecards"); } newsp->owner = s; @@ -12454,7 +12125,7 @@ if (cheat) { } if (keydown(0, SDLK_v)) { // cheat if (toggletimer == 0) { - // addsprite(P_BIGCHEST, (640/2), 0, "bigchest"); + // addsprite(P_BIGCHEST, (SCREENW/2), 0, "bigchest"); // all powerups playfx(FX_POWERUP); sprintf(tempm, "Cheat!"); @@ -12752,6 +12423,79 @@ void swimdown(sprite_t *pl) { } } +void leveltransition_blit(levscrollinfo_t *l, SDL_Surface *copybuffer) { + // remember entire screen + SDL_BlitSurface(screen, NULL, copybuffer, NULL); + + // draw player(s) + if (curlevelnum != INTRO_LEVELNUM) { + if (l->player && l->player->lives > 0) { + drawsprite(l->player); + drawsprite(l->cloud); + } + if (l->player2 && l->player2->lives > 0) { + drawsprite(l->player2); + drawsprite(l->cloud2); + } + } + + // update screen + flip(B_FALSE); + + if (!paused) SDL_framerateDelay(&manager); + + // remove players + if (curlevelnum != INTRO_LEVELNUM) { + // restore copy of screen + SDL_BlitSurface(copybuffer, NULL, screen, NULL); + } +} + +void leveltransition_moveplayer(levscrollinfo_t *l) { + // move player + if (l->player && l->player->lives > 0) moveto(l->player,l->dstx[0],l->dsty[0],l->pspeed[0],l->pspeed[0]); + if (l->player2 && l->player2->lives > 0) moveto(l->player2,l->dstx[1],l->dsty[1],l->pspeed[1],l->pspeed[1]); + // set cloud location + if (l->player && l->player->lives > 0) { + l->cloud->x = l->player->x; + l->cloud->y = l->player->y + (l->cloud->img->h / 2); + } + if (l->player2 && l->player2->lives > 0) { + l->cloud2->x = l->player2->x; + l->cloud2->y = l->player2->y + (l->cloud2->img->h / 2); + } +} + +void leveltransition_scrolllevel(int srcx, int srcy, int srcw, int srch, + int dstx, int dsty, int dstw, int dsth, + int nextcolx, int nextcoly, int nextcolw, int nextcolh, + int nextcol_dstx, int nextcol_dsty, int nextcol_dstw, int nextcol_dsth) { + SDL_Rect src,dst,area; + + // shuffle real screen + src.x = srcx; + src.y = srcy; + src.w = srcw; + src.h = srch; + + dst.x = dstx; + dst.y = dsty; + dst.w = dstw; + dst.h = dsth; + SDL_BlitSurface(screen, &src, screen, &dst); + + // blit next column from temp surface (take last column first) + area.x = nextcolx; + area.y = nextcoly; + area.w = nextcolw; + area.h = nextcolh; + + dst.x = nextcol_dstx; + dst.y = nextcol_dsty; + dst.w = nextcol_dstw; + dst.h = nextcol_dsth; + SDL_BlitSurface(temps, &area, screen, &dst); +} void trytojump(sprite_t *pl) { int pnum; @@ -13000,7 +12744,7 @@ void docannoneffect(sprite_t *pp) { // horiz lines for (i = 0; i < initsize ; i++) { - drawline(screen,0,yy,640,yy,white); + drawline(screen,0,yy,SCREENW,yy,white); for (s3 = sprite; s3 ; s3 = s3->next) { if (ismonster(s3->id) && !s3->dead) { if (!s3->caughtby) { @@ -13016,7 +12760,7 @@ void docannoneffect(sprite_t *pp) { } // vert lines for (i = 0; i < initsize ; i++) { - drawline(screen,xx,0,xx,480,white); + drawline(screen,xx,0,xx,SCREENH,white); for (s3 = sprite; s3 ; s3 = s3->next) { if (ismonster(s3->id) && !s3->dead) { if (!s3->caughtby) { @@ -13210,8 +12954,8 @@ void dotitlescreen(void) { if (titlemode != TS_HISCORES) { // version number - //area.x = 640 - (ver->w) - 10; - area.x = (640/2) - (ver->w/2) - 10; + //area.x = SCREENW - (ver->w) - 10; + area.x = (SCREENW/2) - (ver->w/2) - 10; area.y = 150; SDL_SetColors(ver, &black, 1, 1); SDL_BlitSurface(ver, NULL, screen, &area); @@ -13254,15 +12998,15 @@ void dotitlescreen(void) { // who is in? if (want1up) { area.x = 10; - area.y = (480/2) - (p1ready->h/2); + area.y = (SCREENH/2) - (p1ready->h/2); area.y += (sin(bouncetimer * (M_PI/180)) * 20); SDL_BlitSurface(swapplayers ? p1readyalt : p1ready, NULL, screen, &area); } if (want2up) { - area.x = 640 - p2ready->w - 10; - area.y = (480/2) - (p2ready->h/2); + area.x = SCREENW - p2ready->w - 10; + area.y = (SCREENH/2) - (p2ready->h/2); area.y -= (sin(bouncetimer * (M_PI/180)) * 20); @@ -13314,7 +13058,7 @@ void dotitlescreen(void) { // help on/off area.x = 320 - 100 +2; - area.y = 480 - 50 +2; + area.y = SCREENH - 50 +2; SDL_SetColors(help, &black, 1, 1); SDL_BlitSurface(help, NULL, screen, &area); @@ -13324,7 +13068,7 @@ void dotitlescreen(void) { // "on" area.x += (help->w+10)+2; - area.y = 480 - 50 +2; + area.y = SCREENH - 50 +2; SDL_SetColors(helpon, &black, 1, 1); SDL_BlitSurface(helpon, NULL, screen, &area); @@ -13340,7 +13084,7 @@ void dotitlescreen(void) { // "off" area.x += (helpon->w+10)+2; - area.y = 480 - 50 +2; + area.y = SCREENH - 50 +2; SDL_SetColors(helpoff, &black, 1, 1); SDL_BlitSurface(helpoff, NULL, screen, &area); @@ -13389,7 +13133,7 @@ void dotitlescreen(void) { drawcredits(); SDL_framerateDelay(&manager); - SDL_UpdateRect(screen, 0,0,640,480); + flip(B_TRUE); hticks = SDL_GetTicks(); if (htstart == 0) { @@ -13576,7 +13320,7 @@ void startgame(void) { nextlevel(); firstlevel = B_FALSE; - flip(); + flip(B_TRUE); if (skipto == -1) { playfx(FX_BIRDS); @@ -13750,7 +13494,7 @@ void drawcredits(void) { } credittext = TTF_RenderText_Solid(font[TEXTSIZE_CREDIT], tempst, black); area.x = 320 - (credittext->w / 2) + 2; - area.y = 480 - 2 - (credittext->h)+2; + area.y = SCREENH - 2 - (credittext->h)+2; if (lockcredits) { SDL_SetColors(credittext, &red2, 1, 1); } else { @@ -14284,7 +14028,7 @@ void checkhiscores(sprite_t *who){ } if (!paused) SDL_framerateDelay(&manager); - SDL_UpdateRect(screen, 0,0,640,480); + flip(B_TRUE); } @@ -14355,8 +14099,7 @@ void showhiscores(void){ } } - SDL_UpdateRect(screen, 0,0,640,480); - + flip(B_TRUE); hticks = SDL_GetTicks(); if (htstart == 0) { @@ -14539,8 +14282,8 @@ int isendoflev(void) { } void keeponscreen(sprite_t *s) { - if (s->x >= (640-(s->img->w/2))) { - s->x = 640 - (s->img->w/2)-1; + if (s->x >= (SCREENW-(s->img->w/2))) { + s->x = SCREENW - (s->img->w/2)-1; } if (s->x <= s->img->w/2) { s->x = (s->img->w/2)+1; @@ -14548,8 +14291,8 @@ void keeponscreen(sprite_t *s) { if (s->y <= s->img->h) { s->y = s->img->h+1; } - if (s->y >= 480) { - s->y = 480 - 1; + if (s->y >= SCREENH) { + s->y = SCREENH - 1; } } @@ -14625,7 +14368,7 @@ void doplayermovement(sprite_t *pl) { if (pl->powerup == PW_GUNNER) { // move crosshairs if (keydown(pnum,KEY_RIGHT)) { - if (pl->x < 640-(TILEW/2)) { + if (pl->x < SCREENW-(TILEW/2)) { pl->x += GUNNERSPEED; } } @@ -14635,7 +14378,7 @@ void doplayermovement(sprite_t *pl) { } } if (keydown(pnum,KEY_DOWN)) { - if (pl->y < 480-(TILEH/2)) { + if (pl->y < SCREENH-(TILEH/2)) { pl->y += GUNNERSPEED; } } @@ -14739,7 +14482,7 @@ void doplayermovement(sprite_t *pl) { spd = getspeed(pl)/2; if (spd < 1) spd = 1; // drift downwards - if (pl->y < 480-spd) pl->y += spd; + if (pl->y < SCREENH-spd) pl->y += spd; pl->moved = MV_FLY; } else if ((pl->swimming) && (pl->hasmask)) { // swimming diff --git a/rc.h b/rc.h index 9caac38..c31f917 100644 --- a/rc.h +++ b/rc.h @@ -76,6 +76,7 @@ int getmonjumpspeed(sprite_t *s); int getjumpdelay(int mid); void togglepause(void); void togglefullscreen(void); +void initgl(void); void initsdl(void); void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier); int haspowerup(sprite_t *s, int pid); @@ -87,6 +88,12 @@ char *getpokermsg(int effect); char *getpokermsg2(int effect, char *buf); void handleinput(void); int keydown(int whichplayer, int checkfor); +void leveltransition_blit(levscrollinfo_t *l, SDL_Surface *copybuffer); +void leveltransition_moveplayer(levscrollinfo_t *l); +void leveltransition_scrolllevel(int srcx, int srcy, int srcw, int srch, + int dstx, int dsty, int dstw, int dsth, + int nextcolx, int nextcoly, int nextcolw, int nextcolh, + int nextcol_dstx, int nextcol_dsty, int nextcol_dstw, int nextcol_dsth); void trytojump(sprite_t *pl); void trytoslam(sprite_t *pl); void trytoshoot(sprite_t *pl); diff --git a/shared.c b/shared.c index 742bbbc..c10a339 100644 --- a/shared.c +++ b/shared.c @@ -14,6 +14,9 @@ #include #include #include +#ifdef OPENGL +#include +#endif #include "defs.h" #include "globals.h" @@ -25,6 +28,83 @@ extern int nfadingtiles; extern SDL_Surface *temptilesurf; #endif +#ifdef OPENGL +extern SDL_Surface *realscreen; +GLuint tex = -1; // texture which is created based on realscreen. +float texw = 0,texh = 0; +GLint sampleBuffers, samples; +#endif + +void blittoscreen(void) { + GLfloat texcoords[8]; + GLfloat vertices[8]; + + // clear screen first + glClearColor( 0, 0, 0, 1.0); + glClear( GL_COLOR_BUFFER_BIT ); + + // Bind the texture to which subsequent calls refer to + glBindTexture( GL_TEXTURE_2D, tex ); + + // translate to move to specified spot + // + glLoadIdentity(); + + glRotatef(0, 1.0, 0, 0); + + glTranslatef( texw/2, texh/2, 0); + texcoords[0] = 0; texcoords[1] = 0; + texcoords[2] = 0; texcoords[3] = 1.0; + texcoords[4] = 1.0; texcoords[5] = 1.0; + texcoords[6] = 1.0; texcoords[7] = 0; + + vertices[0] = -texw/2; vertices[1] = -texh/2; + vertices[2] = -texw/2; vertices[3] = texh/2; + vertices[4] = texw/2; vertices[5] = texh/2; + vertices[6] = texw/2; vertices[7] = -texh/2; + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glVertexPointer(2, GL_FLOAT, 0, vertices); + glTexCoordPointer(2, GL_FLOAT, 0, texcoords); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glLoadIdentity(); + + // unbind + glBindTexture( GL_TEXTURE_2D, 0); + + // override + //glClearColor( 0, 0, 1.0, 1.0); + //glClear( GL_COLOR_BUFFER_BIT ); + + SDL_GL_SwapBuffers(); +} + +void gengl(SDL_Surface *surf) { + int ncol; + GLenum texform; + ncol = surf->format->BytesPerPixel; + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE); + // del old texture + glDeleteTextures( 1, &tex ); + // Have OpenGL generate a texture object handle for us + glGenTextures( 1, &tex ); + // Bind the texture object + glBindTexture( GL_TEXTURE_2D, tex ); + // Set the texture's stretching properties + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + // remember w/h + texw = surf->w; + texh = surf->h; + ncol = 4; + texform = GL_RGBA; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, texw, texh, 0, texform, GL_UNSIGNED_BYTE, surf->pixels ); +} + int loadlevel(int lnum, int wantmonsters) { FILE *f; int x,y; @@ -2760,7 +2840,6 @@ void drawsprite(sprite_t *s) { // draw it doblit(s->iceimg, screen, &area); //SDL_BlitSurface(s->iceimg, NULL, screen, &area); - } // anchor @@ -2790,8 +2869,6 @@ void drawsprite(sprite_t *s) { s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), *col1,*col2); } } - - } @@ -2871,10 +2948,13 @@ void killsprite(sprite_t *s) { } -void flip(void) { +void flip(int wantclear) { #ifdef OPENGL - SDL_UpdateRect(screen,0,0,screen->w,screen->h); - SDL_GL_SwapBuffers(); + gengl(screen); + blittoscreen(); + if (wantclear) { + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, black.r, black.g, black.b)); + } #else SDL_Flip(screen); #endif diff --git a/shared.h b/shared.h index fe329b0..627fd18 100644 --- a/shared.h +++ b/shared.h @@ -5,6 +5,8 @@ #include "defs.h" /* functions */ +void blittoscreen(void); +void gengl(SDL_Surface *surf); int loadlevel(int lnum, int wantmonsters); void setdefaults(sprite_t *s); int loadtiletypes(char *filename); @@ -13,7 +15,7 @@ tiletype_t *gettileat(int pixx,int pixy, int *tilex, int *tiley); tiletype_t *gettilexy(int tilex,int tiley); int loadimagesets(void); int isbullet(int id); -void flip(void); +void flip(int wantclear); void killsprite(sprite_t *s); void drawsprite(sprite_t *s); int gettileframecount(int tid); diff --git a/todo b/todo new file mode 100644 index 0000000..5295c90 --- /dev/null +++ b/todo @@ -0,0 +1,23 @@ +- On spike school, allow 40 more seconds before hurryup. + +- Convert to openGL so it will run properly in non-fullsecreen mode. + *initial conversion + + cloud isn't being cleared properly during level transition + + +- get it working not super slow while in non-fullscreen mode. + might have to convert to opengl. + +- Draw graphics for between-level sequences. + - draw and scan ? + - had a plan for this somewhere, i think in an old omnioutliner doc + +- Compose original music tracks. + +- Review difficulty curve over all levels. + 1-5 little room in the middle is a bit tricky for level 5 + although the rest of the level is pretty easy. + maybe move it slightly later + +