- Added cheat mode

- Added powerup: shield
This commit is contained in:
Rob Pearce 2008-09-28 05:19:23 +00:00
parent f1962993b2
commit d1786a5f11
5 changed files with 35 additions and 5 deletions

8
defs.h
View File

@ -40,8 +40,6 @@
#define HELPDELAY 80 #define HELPDELAY 80
//
#define POWERUPTIME 15 // # secs before a powerup appears
// Sizes // Sizes
@ -56,8 +54,10 @@
// Game mechanics // Game mechanics
#define INVULNTIME 200 // how long player stays invulnerable for #define INVULNTIME 200 // how long player stays invulnerable for
#define SHIELDTIME 500 // how long a shield lasts
#define FALLSPEED 4 // terminal velocity of falling sprites #define FALLSPEED 4 // terminal velocity of falling sprites
#define NETSPEED 9 // how fast the player's net moves #define NETSPEED 9 // how fast the player's net moves
#define POWERUPTIME 15 // # secs before a powerup appears
// Limits // Limits
@ -107,7 +107,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 30 #define MAXPTYPES 31
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -138,6 +138,7 @@
#define P_FTODIAMOND 27 #define P_FTODIAMOND 27
#define P_FTOGEM 28 #define P_FTOGEM 28
#define P_BOMB 29 #define P_BOMB 29
#define P_SHIELD 30
// powerups // powerups
#define PW_NONE 0 #define PW_NONE 0
@ -376,6 +377,7 @@ extern Mix_Chunk *sfx[];
extern int oldexitdir; extern int oldexitdir;
extern int levelcomplete; extern int levelcomplete;
extern text_t *text, *lasttext; extern text_t *text, *lasttext;
extern int cheat;
#endif #endif

View File

@ -19,6 +19,8 @@ level_t *curlevel; // the current level's data
int levelcomplete; // has the levle been finished? int levelcomplete; // has the levle been finished?
int cheat;
tiletype_t fakeblock; // used for returning tiletypes from a function tiletype_t fakeblock; // used for returning tiletypes from a function
int oldexitdir; // exit direction of previous level int oldexitdir; // exit direction of previous level

BIN
rc

Binary file not shown.

22
rc.c
View File

@ -88,6 +88,7 @@ int main (int argc, char **argv) {
curlevelnum = 1; curlevelnum = 1;
musicplaying = B_FALSE; musicplaying = B_FALSE;
cheat = B_FALSE;
/* handle arguments */ /* handle arguments */
if (argc >= 2) { if (argc >= 2) {
@ -95,6 +96,9 @@ int main (int argc, char **argv) {
if (!strcmp(argv[i], "-fs")) { if (!strcmp(argv[i], "-fs")) {
printf("Fullscreen mode enabled.\n"); printf("Fullscreen mode enabled.\n");
vidargs |= SDL_FULLSCREEN; vidargs |= SDL_FULLSCREEN;
} else if (!strcmp(argv[i], "-c")) {
printf("Cheat mode.\n");
cheat = B_TRUE;
} else if (!strcmp(argv[i], "-l")) { } else if (!strcmp(argv[i], "-l")) {
if (++i >= argc) { if (++i >= argc) {
printf("Missing level number.\n"); printf("Missing level number.\n");
@ -596,6 +600,10 @@ void nextlevel(void) {
player->slamming = B_FALSE; player->slamming = B_FALSE;
player->jumping = B_FALSE; player->jumping = B_FALSE;
player->powerup = B_FALSE; player->powerup = B_FALSE;
if (cheat) {
player->speed = 2;
}
} }
void jump(sprite_t *s, int dir) { void jump(sprite_t *s, int dir) {
@ -2613,6 +2621,15 @@ int dofruiteffect(sprite_t *s) {
die(s2); die(s2);
} }
} }
return B_TRUE;
} else if (s->id == P_SHIELD) {
playfx(FX_POWERUP);
sprintf(tempm, "Shield!");
addtext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,POINTSDELAY);
// temp invincibility
player->invuln = SHIELDTIME;
return B_TRUE; return B_TRUE;
} else if (s->id == P_HELP) { } else if (s->id == P_HELP) {
playfx(FX_POWERUP); playfx(FX_POWERUP);
@ -2844,7 +2861,8 @@ SDL_Surface *grabbehind(sprite_t *s, SDL_Surface *surf) {
// returns a random powerup // returns a random powerup
int randompowerup(void) { int randompowerup(void) {
int num; int num;
num = rand() % 7; num = rand() % 8;
switch (num) { switch (num) {
case 0: case 0:
@ -2862,6 +2880,8 @@ int randompowerup(void) {
return P_FTOGEM; return P_FTOGEM;
case 6: case 6:
return P_BOMB; return P_BOMB;
case 7:
return P_SHIELD;
} }
} }

View File

@ -66,7 +66,9 @@ int loadlevel(int wnum, int lnum) {
/* default */ /* default */
level->hurryuptime = 30; level->hurryuptime = 30;
level->poweruptime = POWERUPTIME; if (cheat) {
level->poweruptime = 5;
} else level->poweruptime = POWERUPTIME;
level->p1x = 0; level->p1x = 0;
level->p1y = 0; level->p1y = 0;
level->powerupx = -1; level->powerupx = -1;
@ -1045,6 +1047,9 @@ int loadimagesets(void) {
loadspriteimage(P_BOMB,F_WALK1, "sprites/bomb.png"); loadspriteimage(P_BOMB,F_WALK1, "sprites/bomb.png");
imageset[P_BOMB].numimages = 1; imageset[P_BOMB].numimages = 1;
loadspriteimage(P_SHIELD,F_WALK1, "sprites/shield.png");
imageset[P_SHIELD].numimages = 1;
for (i = 0; i < PUFFFRAMES; i++) { for (i = 0; i < PUFFFRAMES; i++) {
char name[SMALLBUFLEN]; char name[SMALLBUFLEN];
sprintf(name, "sprites/puff%d.png",i); sprintf(name, "sprites/puff%d.png",i);
@ -1376,6 +1381,7 @@ int isfruit(int id) {
case P_FTODIAMOND: case P_FTODIAMOND:
case P_FTOGEM: case P_FTOGEM:
case P_BOMB: case P_BOMB:
case P_SHIELD:
/* flowers */ /* flowers */
case P_FLOWERYELLOW: case P_FLOWERYELLOW:
case P_FLOWERRED: case P_FLOWERRED: