Added playing cards - you get them if you were going to receive a powerup

which you already had.

Get a poker hand for effects!

No longer checking for collisions on effects
This commit is contained in:
Rob Pearce 2008-10-15 03:20:10 +00:00
parent b32043b53f
commit fb0be14362
7 changed files with 1009 additions and 37 deletions

58
defs.h
View File

@ -49,6 +49,7 @@
#define TEXTSIZE_LEVEL 32
#define TEXTSIZE_LIFE 36
#define TEXTSIZE_BOMB 36
#define TEXTSIZE_POKER 40
#define TEXTSIZE_HURRY 50
#define TEXTSIZE_PAUSED 50
#define TEXTSIZE_GAMEOVER 50
@ -62,11 +63,13 @@
#define MULTIDELAY 50
#define HURRYDELAY 50
#define LIFEDELAY 50
#define POKERMSGDELAY 80
#define LEVELWINDELAY 80
#define DIEDELAY 80
#define HELPDELAY 80
#define LEVELDELAY 100
#define GAMEOVERDELAY 200
#define POKERDELAY 150
@ -109,6 +112,8 @@
#define MASKOFFSETSLAMX 1
#define MASKOFFSETSLAMY -17
#define POKERWAITTIME 150 // how long to display poker msg
#define CANNONSIZE 10
@ -165,6 +170,8 @@
#define MAXHELP 5
#define MAXTILEFRAMES 10 // max number of frames for animated tiles
#define MAXCARDS 5 // how many cards a player can have
// Fixed text buffer sizes
#define BUFLEN 512
#define MIDBUFLEN 64
@ -180,7 +187,8 @@
#define FT_PERM 2
#define FT_TEMP 3
#define FT_GEM 4
#define FT_OTHER 5
#define FT_CARD 5
#define FT_OTHER 6
// monster types
#define MT_MONSTER 1
@ -235,13 +243,31 @@
#define FX_ENGAGED 38
#define FX_FLOOD 39
// card suits
#define CS_HEART 1
#define CS_DIAMOND 2
#define CS_SPADE 3
#define CS_CLUB 4
// poker effects
#define PE_HIGHCARD 1
#define PE_PAIR 2
#define PE_TWOPAIR 3
#define PE_TRIPLE 4
#define PE_STRAIGHT 5
#define PE_FLUSH 6
#define PE_FULLHOUSE 7
#define PE_FOUR 8
#define PE_STRAIGHTFLUSH 9
#define PE_ROYALFLUSH 10
// Slope types
#define S_NOTSOLID 0
#define S_SOLID 1
#define S_SLOPE 2
// Sprite types
#define MAXPTYPES 116
#define MAXPTYPES 118
#define P_PLAYER 0
#define P_RAT 1
#define P_CHEESE 2
@ -363,12 +389,27 @@
#define P_CARDCJ 113
#define P_CARDCQ 114
#define P_CARDCK 115
#define P_MOVINGCARD 116
#define P_FIVECARDS 117
// cards
#define CARDFONTX 4
#define CARDFONTY 6
#define CARDFONTSIZE 10
// card display (in top left of main screen)
#define CARDX 20
#define CARDY 55
// how fast cards move towards the corner
#define CARDSPEED 8
#define FIVECARDSPEED 8
// how many cards in a deck
#define DECKSIZE 52
#define SHUFFLEQUALITY 100
// powerups
#define PW_NONE 0
#define PW_BOXING 1 // boxing glove
@ -416,6 +457,7 @@
#define LV_CLOUDLOOP 6 // cloud looping
#define LV_NEXTLEV 7 // cloud done , nextlevel() in 5 seconds
#define LV_GAMEOVER 8 // No lives left.
#define LV_DOPOKER 9 // Got a full set of cards!
// movement types
#define MV_NONE 0 // didn't move
@ -595,10 +637,14 @@ typedef struct sprite_s {
int powerup; // what temp powerup does the player have?
int permspeed; // got the permenant speed powerup?
int permnumnets; // got the permenant numnets powerup?
int permbignet; // got the permenant bignets powerup?
int permsticky; // got the permenant sticky net powerup?
int ontramp; // on a trampoline?
int trampx; // x,y coords for trampoline we are/were on
int trampy; //
// player permenant powerups
int armour; // does the player have armour?
int gemboost; // how many extra gems do you get in a bonus
@ -606,6 +652,11 @@ typedef struct sprite_s {
int hasbell; // got a bell ?
int hasmask; // got scuba mask?
// player cards
int numcards;
int card[MAXCARDS];
int usedcard[MAXCARDS];
// monster only
int iced; // turned to ice?
SDL_Surface *iceimg; // Image to blit for ice
@ -707,6 +758,9 @@ extern char *deathtext[];
extern char *bifftext[];
extern spriteinfo_t spriteinfo[];
extern int curcard;
extern int deck[];
extern char *datadir;
#endif

2
edit.c
View File

@ -1044,6 +1044,8 @@ int isplacablesprite(int sid) {
case P_METEOR:
case P_LIFE:
case P_BIGSPEED:
case P_MOVINGCARD:
case P_FIVECARDS:
return B_FALSE;
}

View File

@ -13,6 +13,9 @@ spriteinfo_t spriteinfo[MAXPTYPES];
char *datadir;
int curcard;
int deck[DECKSIZE];
SDL_Surface *levelbg; // level background image
SDL_Surface *temps; // temporary surface

841
rc.c

File diff suppressed because it is too large Load Diff

6
rc.h
View File

@ -68,3 +68,9 @@ void togglefullscreen(void);
void initsdl(void);
void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier);
int haspowerup(sprite_t *s, int pid);
void gaincard(sprite_t *s, int cardid);
int getpokereffect(sprite_t *pl);
void dopokereffect(sprite_t *pl, int effect);
char *getpokermsg(int effect);
int getcardvalue(int cardid);
int getcardsuit(int cardid);

119
shared.c
View File

@ -568,6 +568,22 @@ void setdefaults(sprite_t *s) {
} else {
s->speed = 1;
}
if (s->permbignet) {
s->netbig = B_TRUE;
} else {
s->netbig = B_FALSE;
}
if (s->permnumnets) {
s->netmax = 4;
} else {
s->netmax = 1;
}
if (s->permsticky) {
s->netsticky = B_TRUE;
} else {
s->netsticky = B_FALSE;
}
s->frame = 0;
@ -576,11 +592,8 @@ void setdefaults(sprite_t *s) {
s->armour = B_FALSE;
s->gemboost = 1;
s->powerup = 0;
s->netbig = 0;
s->netsticky = B_FALSE;
// player-only states
s->netting = 0;
s->netmax = 1;
s->netcaught = 0;
s->slamming = 0;
s->invuln = 0;
@ -677,6 +690,7 @@ void setdefaults(sprite_t *s) {
/* initial is TRUE if we are populating the level for the first time */
sprite_t *addsprite(int id, int x, int y, char *name ) {
sprite_t *s;
int c;
if (sprite == NULL) {
sprite = malloc(sizeof(sprite_t));
@ -717,8 +731,19 @@ sprite_t *addsprite(int id, int x, int y, char *name ) {
}
s->iceimg = NULL;
// don't set this in setdefaults as it is called after player death
// don't set these in setdefaults() as setdefaults() is called after each player death
s->permspeed = B_FALSE;
s->permbignet = B_FALSE;
s->permnumnets = B_FALSE;
s->permsticky = B_FALSE;
// don't set this in setdefaults() as setdefaults() is called after each player death
s->numcards = 0;
for (c = 0; c < MAXCARDS; c++) {
s->card[c] = -1;
s->usedcard[c] = 0;
}
setdefaults(s);
@ -1179,6 +1204,8 @@ int loadimagesets(void) {
loadspriteimage(P_STARPOWERUP,F_WALK1, "sprites/star.png");
imageset[P_STARPOWERUP].numimages = 1;
// Don't load image for P_MOVINGCARD or P_FIVECARDS
for (i = 0; i < STARFRAMES; i++) {
char name[SMALLBUFLEN];
@ -1497,6 +1524,12 @@ void drawsprite(sprite_t *s) {
} else {
return;
}
} else if (s->id == P_MOVINGCARD) {
// not really needed but included here for neatness
frame = F_WALK1;
} else if (s->id == P_FIVECARDS) {
// not really needed but included here for neatness
frame = F_WALK1;
}
} else if (s->dead) {
@ -1593,7 +1626,13 @@ void drawsprite(sprite_t *s) {
frame += (MAXFRAMES*2);
}
if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) {
if (s->id == P_MOVINGCARD) {
// image comes from timer1
s->img = imageset[s->timer1].img[F_WALK1];
} else if (s->id == P_FIVECARDS) {
// do nothing - img already there!
} else if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) {
// select image based on sprite id
s->img = imageset[s->id].img[frame];
}
@ -1722,6 +1761,12 @@ void killsprite(sprite_t *s) {
// cards?
// etc
if (s->id == P_FIVECARDS) {
if (s->img) {
SDL_FreeSurface(s->img);
}
}
nextone = s->next;
if (nextone != NULL) {
nextone->prev = s->prev;
@ -1850,7 +1895,7 @@ int isfruit(int id) {
}
if (iscard(id)) return FT_FRUIT;
if (iscard(id)) return FT_CARD;
return B_FALSE;
}
@ -1875,6 +1920,8 @@ int iseffect(int id) {
case P_STAR:
case P_METEOR:
case P_MASK:
case P_MOVINGCARD:
case P_FIVECARDS:
return B_TRUE;
}
@ -2441,7 +2488,7 @@ int loadlevellist(void) {
int randompowerup(void) {
int num;
num = rand() % 26;
num = rand() % 27;
switch (num) {
case 0:
@ -2497,6 +2544,8 @@ int randompowerup(void) {
return P_TAP;
case 25:
return P_MASKPOWERUP;
case 26:
return getrandomcard();
}
}
@ -2776,9 +2825,35 @@ char *getcardletter(int num) {
// returns a random card sprite id
int getrandomcard(void) {
int i;
int cardid;
// TODO: change to 52
cardid = P_FIRSTCARD + (rand() % 52);
int gotit;
//cardid = P_FIRSTCARD + (rand() % 52);
gotit = B_TRUE;
while (gotit) {
// give current card
cardid = deck[curcard];
// move to next card
curcard++;
if (curcard >= DECKSIZE) {
shufflecards();
curcard = 0;
}
// make sure the player doesn't have it!
gotit = B_FALSE;
if (player) {
for (i = 0; i < player->numcards; i++) {
if (player->card[i] == cardid) {
gotit = B_TRUE;
}
}
}
}
printf("returning cardid %d\n",cardid);
return cardid;
}
@ -2892,3 +2967,29 @@ char *getcardname(int id) {
}
return "Unknown Card";
}
void shufflecards(void) {
int ii,i,n,thiscard;
// generate initial list of cards
for (i = 0; i < DECKSIZE; i++) {
deck[i] = P_FIRSTCARD + i;
}
// shuffle them
for (ii = 0; ii < SHUFFLEQUALITY; ii++) {
for (i = 0; i < DECKSIZE; i++) {
// 50% chance of moving to the end
if (rand() % 2) {
thiscard = deck[i];
for (n = i; n < (DECKSIZE-1); n++) {
deck[n] = deck[n+1];
}
deck[DECKSIZE-1] = thiscard;
}
}
}
curcard = 0;
}

View File

@ -55,6 +55,7 @@ void doblit(SDL_Surface *src, SDL_Surface *dst, SDL_Rect *dstarea);
char *getcardletter(int num);
int getrandomcard(void);
char *getcardname(int id);
void shufflecards(void);
// for doco
void setfruitinfo(void);
void setinfo(int id, char *name, char *desc, char *file);