Added powerup: camera

This commit is contained in:
Rob Pearce 2008-11-24 21:35:46 +00:00
parent 0729cf09ba
commit 645522bff6
7 changed files with 256 additions and 175 deletions

BIN
data/sounds/camera.wav Normal file

Binary file not shown.

BIN
data/sprites/camera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

11
defs.h
View File

@ -297,7 +297,7 @@
/* enums */ /* enums */
/* sounds */ /* sounds */
#define MAXFX 58 #define MAXFX 59
#define FX_SHOOT 0 #define FX_SHOOT 0
#define FX_SLAM 1 #define FX_SLAM 1
#define FX_KILL 2 #define FX_KILL 2
@ -356,6 +356,7 @@
#define FX_EXTRALIFE 55 #define FX_EXTRALIFE 55
#define FX_WARP 56 #define FX_WARP 56
#define FX_JETPACK 57 #define FX_JETPACK 57
#define FX_CAMERA 58
// card suits // card suits
#define CS_HEART 1 #define CS_HEART 1
@ -381,7 +382,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 149 #define MAXPTYPES 150
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -536,6 +537,7 @@
#define P_MAGNET 146 #define P_MAGNET 146
#define P_BADMAGNET 147 #define P_BADMAGNET 147
#define P_JETPACK 148 #define P_JETPACK 148
#define P_CAMERA 149
#define FLY_FLYTIME 150 #define FLY_FLYTIME 150
@ -599,9 +601,10 @@
#define PW_MAGNET 17 // magnet #define PW_MAGNET 17 // magnet
#define PW_BADMAGNET 18 // badmagnet #define PW_BADMAGNET 18 // badmagnet
#define PW_JETPACK 19 // kangaroo #define PW_JETPACK 19 // kangaroo
#define PW_CAMERA 20 // camera
// "virtual" powerup for bosses // "virtual" powerup for bosses
#define PW_RATSHAKE 20 // shake screen horizontally #define PW_RATSHAKE 50 // shake screen horizontally
#define PW_SNAILSHAKE 21 // shake screen vertically #define PW_SNAILSHAKE 51 // shake screen vertically
#define GUNNERSPEED 2.5 // speed crosshair moves in gunner mode #define GUNNERSPEED 2.5 // speed crosshair moves in gunner mode
#define GUNNERDELAY 10 // how fast gunner powerup shoots #define GUNNERDELAY 10 // how fast gunner powerup shoots

76
rc.c
View File

@ -71,6 +71,8 @@ double gunorigy[2];
int gundelay[2]; int gundelay[2];
int guntime; int guntime;
int cameraalpha;
int playedbell; int playedbell;
int clocktime; int clocktime;
@ -632,6 +634,28 @@ int main (int argc, char **argv) {
} }
} }
} }
// camera flash
if ((globpowerup == PW_CAMERA) && (cameraalpha)) {
SDL_Surface *whitebox;
whitebox = SDL_CreateRGBSurface(SDL_SWSURFACE,
screen->w,
screen->h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask, 0);
SDL_FillRect(whitebox, NULL, SDL_MapRGB(screen->format,255,255,255));
SDL_SetAlpha(whitebox, SDL_SRCALPHA, cameraalpha);
// clear screen
SDL_BlitSurface(whitebox,NULL,screen,NULL);
SDL_FreeSurface(whitebox);
if (timer % 10 == 0) {
cameraalpha -= 35;
if (cameraalpha < 0) cameraalpha = 0;
}
}
/********************************************** /**********************************************
* Collision detection * Collision detection
@ -2922,6 +2946,9 @@ int movesprite(sprite_t *s) {
tiletype_t *tunder; tiletype_t *tunder;
if (globpowerup == PW_CAMERA) {
move = B_TRUE;
} else {
/* distance to closest player */ /* distance to closest player */
xdiff = getxdisttoplayer(s, NULL); xdiff = getxdisttoplayer(s, NULL);
absxdiff = abs(xdiff); absxdiff = abs(xdiff);
@ -2958,6 +2985,7 @@ int movesprite(sprite_t *s) {
} else { } else {
move = B_TRUE; move = B_TRUE;
} }
}
/* either move or turn around */ /* either move or turn around */
if (move) { if (move) {
@ -3020,6 +3048,9 @@ int movesprite(sprite_t *s) {
int move = B_FALSE; int move = B_FALSE;
int xdiff, absxdiff; int xdiff, absxdiff;
if (globpowerup == PW_CAMERA) {
move = B_TRUE;
} else {
/* distance to closest player */ /* distance to closest player */
xdiff = getxdisttoplayer(s, NULL); xdiff = getxdisttoplayer(s, NULL);
absxdiff = abs(xdiff); absxdiff = abs(xdiff);
@ -3041,6 +3072,7 @@ int movesprite(sprite_t *s) {
} else { } else {
move = B_TRUE; move = B_TRUE;
} }
}
/* either move or turn around */ /* either move or turn around */
if (move) { if (move) {
@ -3101,6 +3133,9 @@ int movesprite(sprite_t *s) {
int xdiff, absxdiff; int xdiff, absxdiff;
if (globpowerup == PW_CAMERA) {
move = B_TRUE;
} else {
/* distance to closest player */ /* distance to closest player */
xdiff = getxdisttoplayer(s, NULL); xdiff = getxdisttoplayer(s, NULL);
absxdiff = abs(xdiff); absxdiff = abs(xdiff);
@ -3127,6 +3162,7 @@ int movesprite(sprite_t *s) {
} else { } else {
move = B_TRUE; move = B_TRUE;
} }
}
/* either move or turn around */ /* either move or turn around */
if (move) { if (move) {
@ -3141,6 +3177,7 @@ int movesprite(sprite_t *s) {
if (globpowerup != PW_CAMERA) {
/* moves like an angry rat all the time */ /* moves like an angry rat all the time */
if ((!s->jumping) && (!s->jumptimer)) { if ((!s->jumping) && (!s->jumptimer)) {
/* if player is above us or at same level...*/ /* if player is above us or at same level...*/
@ -3176,6 +3213,7 @@ int movesprite(sprite_t *s) {
} }
} }
} }
}
} else { // falling } else { // falling
int rv; int rv;
// move forwards // move forwards
@ -3562,6 +3600,9 @@ int movesprite(sprite_t *s) {
int xdiff, absxdiff; int xdiff, absxdiff;
if (globpowerup == PW_CAMERA) {
move = B_TRUE;
} else {
/* distance to player */ /* distance to player */
xdiff = getxdisttoplayer(s, NULL); xdiff = getxdisttoplayer(s, NULL);
absxdiff = abs(xdiff); absxdiff = abs(xdiff);
@ -3589,6 +3630,7 @@ int movesprite(sprite_t *s) {
} else { } else {
move = B_TRUE; move = B_TRUE;
} }
}
/* either move or turn around */ /* either move or turn around */
if (move) { if (move) {
@ -3604,6 +3646,7 @@ int movesprite(sprite_t *s) {
/* moves like an angry rat all the time */ /* moves like an angry rat all the time */
if (globpowerup != PW_CAMERA) {
if ((playersalive()) && (!s->jumping) && (!s->jumptimer)) { if ((playersalive()) && (!s->jumping) && (!s->jumptimer)) {
sprite_t *abovep; sprite_t *abovep;
/* if player is above us...*/ /* if player is above us...*/
@ -3626,6 +3669,7 @@ int movesprite(sprite_t *s) {
} }
} }
} }
}
} else { // falling } else { // falling
movex(s, s->jumpdir*getspeed(s)); movex(s, s->jumpdir*getspeed(s));
} }
@ -3647,6 +3691,9 @@ int movesprite(sprite_t *s) {
int xdiff, absxdiff,ydiff; int xdiff, absxdiff,ydiff;
if (globpowerup == PW_CAMERA) {
move = B_TRUE;
} else {
/* distance to player */ /* distance to player */
xdiff = getxdisttoplayer(s, NULL); xdiff = getxdisttoplayer(s, NULL);
absxdiff = abs(xdiff); absxdiff = abs(xdiff);
@ -3677,6 +3724,7 @@ int movesprite(sprite_t *s) {
} else { } else {
move = B_TRUE; move = B_TRUE;
} }
}
/* shoot */ /* shoot */
ydiff = getydisttoplayer(s); ydiff = getydisttoplayer(s);
@ -3704,6 +3752,7 @@ int movesprite(sprite_t *s) {
shoot = B_TRUE; shoot = B_TRUE;
} }
} }
if (globpowerup == PW_CAMERA) shoot = B_FALSE;
if (shoot) { if (shoot) {
// if our shooting timer is okay // if our shooting timer is okay
if (s->timer1 == 0) { if (s->timer1 == 0) {
@ -3734,7 +3783,7 @@ int movesprite(sprite_t *s) {
} }
if (s->angry) { if (s->angry && (globpowerup != PW_CAMERA)) {
if (playersalive() && (!s->jumping) && (!s->jumptimer)) { if (playersalive() && (!s->jumping) && (!s->jumptimer)) {
/* if player is above us, jump */ /* if player is above us, jump */
if ( (player && (!player->dead) && (player->y < s->y)) || if ( (player && (!player->dead) && (player->y < s->y)) ||
@ -3929,12 +3978,14 @@ int movesprite(sprite_t *s) {
playerdist = playerdist2; playerdist = playerdist2;
} }
if (globpowerup != PW_CAMERA) {
if (playerdist <= (TILEW*10)) { if (playerdist <= (TILEW*10)) {
s->timer1 = 0; s->timer1 = 0;
s->flies = F_FLYHORZ; s->flies = F_FLYHORZ;
s->xs = -99; s->xs = -99;
s->ys = -99; s->ys = -99;
} }
}
// ...and take off eventually anyway // ...and take off eventually anyway
s->timer1++; s->timer1++;
@ -7378,6 +7429,13 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) {
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM);
globpowerup = PW_ANCHOR; globpowerup = PW_ANCHOR;
return B_TRUE; return B_TRUE;
} else if (s->id == P_CAMERA) {
playfx(FX_CAMERA);
sprintf(tempm, "Blind enemies!");
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM);
globpowerup = PW_CAMERA;
cameraalpha = 255;
return B_TRUE;
} else if (s->id == P_WAND) { } else if (s->id == P_WAND) {
sprite_t *s2; sprite_t *s2;
@ -7651,6 +7709,7 @@ int initsound(void) {
loadfx(FX_EXTRALIFE, "extralife.wav"); loadfx(FX_EXTRALIFE, "extralife.wav");
loadfx(FX_WARP, "warp.wav"); loadfx(FX_WARP, "warp.wav");
loadfx(FX_JETPACK, "jetpack.wav"); loadfx(FX_JETPACK, "jetpack.wav");
loadfx(FX_CAMERA, "camera.wav");
// load sound effects // load sound effects
for (i = 0; i < MAXFX; i++) { for (i = 0; i < MAXFX; i++) {
@ -9266,8 +9325,8 @@ void handleinput(void) {
} }
if (cheat) { if (cheat) {
if (keydown(0, SDLK_q)) { if (keydown(0, SDLK_q)) {
//gtime = nexthurryup-1; gtime = nexthurryup-1;
gtime = nexthurryup+14; //gtime = nexthurryup+14;
} }
if (keydown(0, SDLK_b)) { if (keydown(0, SDLK_b)) {
//gtime = nexthurryup-1; //gtime = nexthurryup-1;
@ -11414,6 +11473,8 @@ void doplayermovement(sprite_t *pl) {
double getxdisttoplayer(sprite_t *s, sprite_t **pl) { double getxdisttoplayer(sprite_t *s, sprite_t **pl) {
double xdiff1,xdiff2,xdiff; double xdiff1,xdiff2,xdiff;
if (globpowerup == PW_CAMERA) return 9999;
/* distance to closest player */ /* distance to closest player */
if (player) { if (player) {
xdiff1 = abs(player->x - s->x); xdiff1 = abs(player->x - s->x);
@ -11442,6 +11503,8 @@ double getxdisttoplayer(sprite_t *s, sprite_t **pl) {
double getydisttoplayer(sprite_t *s) { double getydisttoplayer(sprite_t *s) {
double ydiff1,ydiff2,ydiff; double ydiff1,ydiff2,ydiff;
/* distance to closest player */ /* distance to closest player */
if (globpowerup == PW_CAMERA) return 9999;
if (player) { if (player) {
ydiff1 = player->y - s->y; ydiff1 = player->y - s->y;
} else { } else {
@ -11465,6 +11528,8 @@ double getydisttoplayer(sprite_t *s) {
sprite_t *isplayerbelow(sprite_t *s) { sprite_t *isplayerbelow(sprite_t *s) {
if (globpowerup == PW_CAMERA) return NULL;
if (player && !player->dead && player->y > s->y) return player; if (player && !player->dead && player->y > s->y) return player;
if (player2 && !player2->dead && player2->y > s->y) return player2; if (player2 && !player2->dead && player2->y > s->y) return player2;
@ -11472,12 +11537,17 @@ sprite_t *isplayerbelow(sprite_t *s) {
} }
sprite_t *isplayerabove(sprite_t *s) { sprite_t *isplayerabove(sprite_t *s) {
if (globpowerup == PW_CAMERA) return NULL;
if (player && !player->dead && player->y < s->y) return player; if (player && !player->dead && player->y < s->y) return player;
if (player2 && !player2->dead && player2->y < s->y) return player2; if (player2 && !player2->dead && player2->y < s->y) return player2;
return NULL; return NULL;
} }
sprite_t *isplayerright(sprite_t *s) { sprite_t *isplayerright(sprite_t *s) {
if (globpowerup == PW_CAMERA) return NULL;
if (player && !player->dead && player->x > s->x) return player; if (player && !player->dead && player->x > s->x) return player;
if (player2 && !player2->dead && player2->x > s->x) return player2; if (player2 && !player2->dead && player2->x > s->x) return player2;

View File

@ -1563,6 +1563,9 @@ int loadimagesets(void) {
loadspriteimage(P_JETPACK,F_WALK1, "sprites/jetpack.png"); loadspriteimage(P_JETPACK,F_WALK1, "sprites/jetpack.png");
imageset[P_JETPACK].numimages = 1; imageset[P_JETPACK].numimages = 1;
loadspriteimage(P_CAMERA,F_WALK1, "sprites/camera.png");
imageset[P_CAMERA].numimages = 1;
loadspriteimage(P_ZAPPOWERUP,F_WALK1, "sprites/zapper.png"); loadspriteimage(P_ZAPPOWERUP,F_WALK1, "sprites/zapper.png");
imageset[P_ZAPPOWERUP].numimages = 1; imageset[P_ZAPPOWERUP].numimages = 1;
@ -2459,6 +2462,7 @@ int isfruit(int id) {
case P_MAGNET: case P_MAGNET:
case P_BADMAGNET: case P_BADMAGNET:
case P_JETPACK: case P_JETPACK:
case P_CAMERA:
return FT_TEMP; return FT_TEMP;
/* flowers */ /* flowers */
case P_FLOWERYELLOW: case P_FLOWERYELLOW:
@ -3102,7 +3106,7 @@ int loadlevellist(void) {
int randompowerup(void) { int randompowerup(void) {
int num; int num;
num = rand() % 42; num = rand() % 43;
switch (num) { switch (num) {
case 0: case 0:
@ -3195,6 +3199,8 @@ int randompowerup(void) {
return P_BADMAGNET; return P_BADMAGNET;
case 41: case 41:
return P_JETPACK; return P_JETPACK;
case 42:
return P_CAMERA;
} }
} }
@ -3346,6 +3352,7 @@ void setfruitinfo(void) {
setinfo(P_MAGNET, "Magnet", "Collecting this powerup will align the magnetic forces of the earth in your favour, attracting all nearby fruits towards you.", "magnet.png"); setinfo(P_MAGNET, "Magnet", "Collecting this powerup will align the magnetic forces of the earth in your favour, attracting all nearby fruits towards you.", "magnet.png");
setinfo(P_BADMAGNET, "Red Skull", "This skull curses you and will repel fruits away from you, denying you access to them!", "badmagnet.png"); setinfo(P_BADMAGNET, "Red Skull", "This skull curses you and will repel fruits away from you, denying you access to them!", "badmagnet.png");
setinfo(P_JETPACK, "Jetpack", "For the remainder of the current level, the jetpack's thrust will add to your jumping ability!", "jetpack.png"); setinfo(P_JETPACK, "Jetpack", "For the remainder of the current level, the jetpack's thrust will add to your jumping ability!", "jetpack.png");
setinfo(P_CAMERA, "Camera", "Creates a bright flash of light, blinding all enemies.", "camera.png");
setinfo(P_ZAPPOWERUP, "Bug Zapper", "Zaps nearby enemies with miniature bolts of lightning", "zapper.png"); setinfo(P_ZAPPOWERUP, "Bug Zapper", "Zaps nearby enemies with miniature bolts of lightning", "zapper.png");
setinfo(P_SKULL, "Green Skull", "Avoid these at all costs! The green skull will cause you to lose all net powerups.", "skull.png"); setinfo(P_SKULL, "Green Skull", "Avoid these at all costs! The green skull will cause you to lose all net powerups.", "skull.png");
setinfo(P_CLOVER, "4-Leaf Clover", "Increases your luck...", "clover.png"); setinfo(P_CLOVER, "4-Leaf Clover", "Increases your luck...", "clover.png");

BIN
website/img/camera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -81,8 +81,9 @@
<td align=center><img src="img/magnet.png"><br>Magnet</td><td>Collecting this powerup will align the magnetic forces of the earth in your favour, attracting all nearby fruits towards you.</td> <td align=center><img src="img/magnet.png"><br>Magnet</td><td>Collecting this powerup will align the magnetic forces of the earth in your favour, attracting all nearby fruits towards you.</td>
</tr><tr><td align=center><img src="img/badmagnet.png"><br>Red Skull</td><td>This skull curses you and will repel fruits away from you, denying you access to them!</td> </tr><tr><td align=center><img src="img/badmagnet.png"><br>Red Skull</td><td>This skull curses you and will repel fruits away from you, denying you access to them!</td>
<td align=center><img src="img/jetpack.png"><br>Jetpack</td><td>For the remainder of the current level, the jetpack's thrust will add to your jumping ability!</td> <td align=center><img src="img/jetpack.png"><br>Jetpack</td><td>For the remainder of the current level, the jetpack's thrust will add to your jumping ability!</td>
</tr><tr><td align=center><font color="ff00ff"><b><big>?</big></b></font><br>Random</td><td>Gives you a random effect...</td> </tr><tr><td align=center><img src="img/camera.png"><br>Camera</td><td>Creates a bright flash of light, blinding all enemies.</td>
<td colspan=2>&nbsp;</td></tr><tr bgcolor="#ffff00"><th colspan=4>Super Powerups</th></tr> <td align=center><font color="ff00ff"><b><big>?</big></b></font><br>Random</td><td>Gives you a random effect...</td>
</tr><tr bgcolor="#ffff00"><th colspan=4>Super Powerups</th></tr>
<tr><td align=center><img src="img/bigspeed.png"><br>Big Speed Up</td><td>Makes you walk faster, permenantly!</td> <tr><td align=center><img src="img/bigspeed.png"><br>Big Speed Up</td><td>Makes you walk faster, permenantly!</td>
<td align=center><img src="img/bigscuba.png"><br>Big Scuba Mask</td><td>Permenantly gives you fast underwater movement.</td> <td align=center><img src="img/bigscuba.png"><br>Big Scuba Mask</td><td>Permenantly gives you fast underwater movement.</td>
</tr></table> </tr></table>