Initial changes for multi-player mode

THIS VERSION MAY BE BUGGY!!
This commit is contained in:
Rob Pearce 2008-11-12 03:25:48 +00:00
parent c4055adcb2
commit 1dc13e0ca2
75 changed files with 1901 additions and 906 deletions

BIN
data/sprites/d2climb1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

BIN
data/sprites/d2climb2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

BIN
data/sprites/d2slam1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

BIN
data/sprites/d2slam2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

BIN
data/sprites/d2slam3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

BIN
data/sprites/d2slam4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
data/sprites/d2slam5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

BIN
data/sprites/d2swim1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/sprites/d2swim2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/sprites/dwarf2die.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

BIN
data/sprites/p1ready.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
data/sprites/p2dwarf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

BIN
data/sprites/p2ready.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -7,7 +7,6 @@ Use X to jump, Z to catch the rat.
Then use Down+Z to slam and kill a monster!
endhelp
monsters
0 3 19
14 7 19
14 12 19
16 30 15
@ -28,6 +27,8 @@ monsters
16 35 19
17 36 19
14 17 19
0 4 19
134 19 19
endmonsters
exitdir 1
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,

View File

@ -6,6 +6,7 @@ Plants don't move, but can still kill you!
endhelp
monsters
0 3 28
134 29 28
23 37 15
18 33 7
18 11 13

View File

@ -6,6 +6,8 @@ Snails become dangerous slugs when killed!
endhelp
monsters
0 18 13
134 21 13
23 22 13
49 29 20
49 19 24
1 30 28
@ -16,7 +18,6 @@ monsters
6 34 7
49 28 7
49 8 7
23 22 13
14 20 13
17 30 16
17 9 16

View File

@ -5,8 +5,8 @@ help
endhelp
monsters
0 3 28
134 36 28
23 21 12
49 25 28
12 29 8
12 13 8
1 20 12
@ -51,6 +51,7 @@ monsters
15 17 12
15 29 15
15 11 15
49 20 28
endmonsters
exitdir 2
44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 2 2
134 4 2
23 31 17
15 12 21
15 14 21

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 2 13
134 37 13
23 17 26
60 18 6
60 4 27

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 8 5
134 12 5
23 32 5
49 17 14
6 19 21

View File

@ -5,7 +5,8 @@ help
Drop through the bottom of this level.
endhelp
monsters
0 8 19
0 18 19
134 22 19
23 24 19
7 27 21
7 11 21

View File

@ -4,7 +4,8 @@ hurryup 60
help
endhelp
monsters
0 19 11
0 18 11
134 20 11
23 19 18
18 33 13
18 4 13

View File

@ -6,6 +6,7 @@ Jump in the direction of the logs...
endhelp
monsters
0 2 22
134 4 22
23 20 17
12 9 12
1 27 4

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 19 8
134 21 8
23 11 8
1 5 28
1 29 20

View File

@ -10,6 +10,7 @@ Send bugs/ideas to rob@nethack.net
endhelp
monsters
0 5 20
134 6 20
1 17 27
14 7 20
14 13 20

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 1 2
134 5 2
23 19 2
1 13 10
16 6 28

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 17 28
134 21 28
23 19 19
6 23 18
6 14 10

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 2 23
134 28 23
23 10 3
12 20 18
1 31 19

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 3 27
134 37 27
1 31 15
1 17 15
49 30 27

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 17 25
134 24 25
23 26 9
18 14 18
18 6 18

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 19 28
134 21 28
23 19 4
6 33 15
1 33 22

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 6 4
0 4 4
134 5 4
49 30 18
49 16 18
1 36 1

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 20 22
134 20 2
23 20 9
12 34 14
12 4 14

View File

@ -6,6 +6,7 @@ Watch out for water currents!
endhelp
monsters
0 20 8
134 22 8
23 21 18
7 33 1
7 4 1

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 19 18
0 18 18
134 19 18
23 19 21
6 13 9
6 23 9

View File

@ -6,6 +6,7 @@ Jump on trampolines to bounce high!
endhelp
monsters
0 2 24
134 11 25
23 28 6
6 11 12
6 28 24

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 20 28
134 21 28
23 16 4
6 22 22
6 17 19

View File

@ -8,7 +8,8 @@ Stand on this ledge then slam!
Collect all flowers for a bonus!
endhelp
monsters
0 4 10
0 2 10
134 4 10
14 6 10
14 12 10
14 25 10

View File

@ -6,6 +6,7 @@ Slam monsters into King Rat to damage it!
endhelp
monsters
0 6 8
134 33 8
14 11 8
45 16 20
endmonsters

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 20 17
0 19 17
134 20 17
23 14 20
18 26 4
18 7 4

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 4 10
134 32 8
6 25 12
15 10 18
15 26 18

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 6 17
134 7 17
17 26 2
17 22 2
16 24 2

View File

@ -7,6 +7,7 @@ But don't fall on them!
endhelp
monsters
0 4 27
134 33 27
23 20 15
1 19 15
1 5 7

View File

@ -5,7 +5,8 @@ help
Drop through bridges with Down+X
endhelp
monsters
0 24 8
0 18 8
134 23 8
23 20 8
1 10 4
1 11 12

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 6 8
134 33 8
128 12 27
endmonsters
exitdir 1

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 5 25
134 10 25
1 28 24
7 20 15
7 11 9
@ -15,7 +16,7 @@ monsters
1 34 16
1 27 28
1 32 20
132 30 13 488 472
132 30 13 488 224 488 472
endmonsters
exitdir 1
57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,0,0,0,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 6 28
134 17 28
23 23 14
6 23 5
1 25 20
@ -29,7 +30,7 @@ monsters
16 25 1
16 22 1
133 32 19
132 12 26 291 246
132 12 26 200 432 291 246
endmonsters
exitdir 1
57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 3 17
134 36 17
23 19 9
6 30 2
6 26 20
@ -35,9 +36,8 @@ monsters
16 31 6
16 5 8
16 35 17
1 36 17
132 8 18 239 304
132 31 18 371 304
132 8 18 136 304 239 304
132 31 18 504 304 371 304
endmonsters
exitdir 1
57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 5 8
0 4 8
134 6 8
23 18 9
60 26 25
60 16 27

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 4 22
134 6 22
23 19 14
133 4 12
133 30 5

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 21 14
0 20 14
134 22 14
23 21 23
133 34 27
133 12 4
@ -24,8 +25,8 @@ monsters
17 1 10
17 1 19
17 2 19
132 30 20 488 336 188 336 188 171 492 171
132 11 10 184 176 491 176 491 330 186 330
132 30 20 488 336 488 336 188 336 188 171 492 171
132 11 10 184 176 184 176 491 176 491 330 186 330
endmonsters
exitdir 1
61,61,61,61,61,61,61,61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,61,61,61,61,61,61,61,61,

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 7 28
134 30 28
1 35 13
1 2 13
15 14 5
@ -27,7 +28,7 @@ monsters
15 33 19
15 24 8
15 23 8
132 19 6 312 442
132 19 6 312 112 312 442
15 18 5
15 20 5
16 19 5

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 6 2
134 5 5
23 28 14
60 31 5
60 10 8

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 2 3
0 1 3
134 2 3
23 6 23
133 33 23
133 24 17
@ -14,7 +15,7 @@ monsters
133 23 20
133 32 9
133 7 19
132 2 4 40 80 40 80 40 80 40 80 40 80 40 434 179 434 179 73 322 73 322 434 467 434 467 73 603 73 603 434 468 434 468 73 468 73 323 73 323 434 180 434 180 73
132 2 4 40 80 40 80 40 80 40 80 40 80 40 80 40 434 179 434 179 73 322 73 322 434 467 434 467 73 603 73 603 434 468 434 468 73 468 73 323 73 323 434 180 434 180 73
6 20 25
6 34 2
15 5 3

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 15 22
0 16 22
134 22 22
23 20 9
12 35 9
12 5 9
@ -26,9 +27,9 @@ monsters
16 5 22
1 29 23
1 7 23
132 6 20 536 336
132 37 17 34 288
132 31 14 137 240
132 6 20 104 336 536 336
132 37 17 600 288 34 288
132 31 14 504 240 137 240
endmonsters
exitdir 1
57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 1 17
134 37 17
23 20 15
15 36 9
7 29 1

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 4 27
0 2 28
134 6 28
23 18 16
1 10 4
1 23 8

View File

@ -6,6 +6,7 @@ Rolling logs will push you along.
endhelp
monsters
0 5 25
134 34 25
23 19 1
17 21 1
15 8 21

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 4 28
134 35 28
23 33 28
12 9 3
12 34 3

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 2 28
134 34 28
23 27 10
6 21 4
1 7 8

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 1 20
134 2 20
23 37 20
6 36 7
6 2 9

View File

@ -4,7 +4,8 @@ hurryup 60
help
endhelp
monsters
0 20 12
0 19 12
134 21 12
23 20 12
16 11 5
16 12 9

View File

@ -4,7 +4,8 @@ hurryup 30
help
endhelp
monsters
0 5 26
0 2 26
134 6 26
23 27 6
18 28 26
18 35 3

View File

@ -5,6 +5,7 @@ help
endhelp
monsters
0 12 13
134 16 13
23 17 10
17 1 13
17 7 13

View File

@ -4,7 +4,9 @@ hurryup 90
help
endhelp
monsters
0 32 7
0 30 7
134 32 7
23 21 6
1 33 23
1 4 23
17 34 23
@ -42,7 +44,6 @@ monsters
7 12 22
12 10 20
12 30 20
23 21 6
endmonsters
exitdir 1
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,

16
defs.h
View File

@ -325,7 +325,7 @@
#define S_SLOPE 2
// Sprite types
#define MAXPTYPES 134
#define MAXPTYPES 135
#define P_PLAYER 0
#define P_RAT 1
#define P_CHEESE 2
@ -465,6 +465,7 @@
#define P_RANDOM 131
#define P_PLATFORM 132
#define P_FLY 133
#define P_PLAYER2 134
#define FLY_FLYTIME 150
@ -486,6 +487,14 @@
#define CARDFONTY 6
#define CARDFONTSIZE 10
// score display
#define P1SCOREX 20
#define P1LIVESX 20
#define SCOREY 7
#define LIVESY 25
// card display (in top left of main screen)
#define CARDX 20
#define CARDY 55
@ -702,6 +711,8 @@ typedef struct level_s {
struct level_s *prev;
int p1x; /* player 1 start pos */
int p1y;
int p2x; /* player 2 start pos */
int p2y;
int powerupx; /* powerup position */
int powerupy; /* powerup position */
int gotpowerup; /* has the random powerup appeared yet? */
@ -873,7 +884,7 @@ extern SDL_Color black;
extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube;
extern SDL_Surface *healthbar[];
extern SDL_Surface *greenbox, *redbox;
extern sprite_t *sprite, *lastsprite, *player, *boss, *mask;
extern sprite_t *sprite, *lastsprite, *player, *player2, *boss;
extern level_t *curlevel;
extern tiletype_t fakeblock;
extern int gtime;
@ -905,6 +916,7 @@ extern char *deathtext[];
extern char *bifftext[];
extern spriteinfo_t spriteinfo[];
extern int want1up,want2up;
extern int gotcard;
extern int curcard;

6
edit.c
View File

@ -135,6 +135,9 @@ int main (int argc, char **argv) {
exit(1);
}
want1up = B_TRUE;
want2up = B_TRUE;
atexit(cleanup);
@ -323,7 +326,7 @@ int main (int argc, char **argv) {
/* checks */
// can only have one player/powerup pos
if ((selsprite == P_PLAYER) || (selsprite == P_POWERUPPOS)) {
if ((selsprite == P_PLAYER) || (selsprite == P_PLAYER2) || (selsprite == P_POWERUPPOS)) {
/* does a player start pos already exist? */
sprite_t *s;
for (s = sprite ; s ; s = s->next) {
@ -1128,6 +1131,7 @@ int isplacablesprite(int sid) {
if (sid == P_PLATFORM) return B_TRUE;
if (sid == P_HELP) return B_TRUE;
if (sid == P_PLAYER) return B_TRUE;
if (sid == P_PLAYER2) return B_TRUE;
if (sid == P_POWERUPPOS) return B_TRUE;
if (ismonster(sid) && (sid != P_BLACKCLOUD)) return B_TRUE;
if (isfruit(sid) == FT_GEM) return B_TRUE;

View File

@ -9,6 +9,8 @@ int numlevels;
int maxlevid;
int want1up,want2up;
int gamemode; // easy or hard?
int showhelp; // show help text?
@ -35,9 +37,8 @@ SDL_Surface *redbox; // for gunner
SDL_Surface *healthbar[HEALTHFRAMES]; // for boss health
sprite_t *sprite; // head of sprite linked list
sprite_t *lastsprite; // tail of sprite linked list
sprite_t *player; // pointer to the player's sprite
sprite_t *player, *player2; // pointer to the player's sprite
sprite_t *boss; // point to current boss on level (normally NULL)
sprite_t *mask; // point to scuba mask
Mix_Music *music, *fastmusic, *normalmusic,*bossmusic,*hiscoremusic;
Mix_Chunk *sfx[MAXFX];

2037
rc.c

File diff suppressed because it is too large Load Diff

19
rc.h
View File

@ -24,7 +24,7 @@ int isongroundpoint(sprite_t *s, int x, int y);
int isonladder(sprite_t *s);
int isonbridge(sprite_t *s);
int isladderabove(sprite_t *s);
int dofruiteffect(sprite_t *s);
int dofruiteffect(sprite_t *pp, sprite_t *s);
void checkcollide(sprite_t *s);
void checkcollideplatform(sprite_t *s);
void die(sprite_t *s);
@ -70,25 +70,26 @@ void togglefullscreen(void);
void initsdl(void);
void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier);
int haspowerup(sprite_t *s, int pid);
sprite_t *haspowerupany(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);
char *getpokermsg2(int effect, char *buf);
void handleinput(void);
int keydown(int checkfor);
int keydown(int whichplayer, int checkfor);
void trytojump(sprite_t *pl);
void trytoslam(sprite_t *pl);
void trytoshoot(sprite_t *pl);
void docannoneffect(void);
void docannoneffect(sprite_t *pp);
void dotitlescreen(void);
void startgame(void);
void uncatch(sprite_t *s);
void makeinvuln(sprite_t *s);
void handletitleinput(int key);
void handletitleinput(int whichplayer, int key);
void setjoymappings(void);
//int keytojoybutton(int key);
int joybuttondown(int key);
int joybuttondown(int whichplayer, int key);
int joybuttontokey(int buttonnum);
void drawcredits(void);
int drawoutlinetext(SDL_Surface *where,int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol);
@ -104,8 +105,16 @@ int isendoflev(void);
void keeponscreen(sprite_t *s);
void stopteleporting(sprite_t *s);
void losepowerup(sprite_t *s);
void disablepowerups(int pid);
int easymode(void);
int uncaughtmonsters(void);
void swimup(sprite_t *pl);
void swimdown(sprite_t *pl);
double getdistance(double x1, double y1, double x2, double y2);
void doplayermovement(sprite_t *pl);
double getxdisttoplayer(sprite_t *s);
double getydisttoplayer(sprite_t *s);
int playersalive(void);
sprite_t *isplayerbelow(sprite_t *s);
sprite_t *isplayerabove(sprite_t *s);
sprite_t *isplayerright(sprite_t *s);

133
shared.c
View File

@ -43,6 +43,8 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
int leveldone;
int tempanim[LEVELW*LEVELH];
sprite_t *ss, *nextss;
int numenemies = 0;
@ -105,13 +107,15 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
killtext(text);
}
/* clear sprite linked list (leave player) */
if (sprite != NULL) {
while (sprite->next) {
killsprite(sprite->next);
/* clear sprite linked list (leave players) */
for (ss = sprite ; ss ; ss = nextss) {
nextss = ss->next;
if (!isplayer(ss)) {
killsprite(ss);
}
}
/* read tileset */
/*
fgets(buf, BUFLEN, f);
@ -288,6 +292,9 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
if (monid == P_PLAYER) {
level->p1x = x;
level->p1y = y;
} else if (monid == P_PLAYER2) {
level->p2x = x;
level->p2y = y;
} else if (monid == P_POWERUPPOS) {
level->powerupx = x;
level->powerupy = y;
@ -485,8 +492,14 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
printf("Level is missing player 1 start position.\n");
return B_TRUE;
}
if ((level->p2x == 0) || (level->p2y == 0)) {
printf("Level is missing player 2 start position.\n");
return B_TRUE;
}
#endif
printf("p1 is %d,%d p2 s %d,%d\n",level->p1x,level->p1y,level->p2x, level->p2y);
/* free help texts */
for (i = 0; i < numhelp; i++) {
free(help[i]);
@ -494,10 +507,17 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
/* add player if required */
if (want1up) {
if (player == NULL) {
addsprite(P_PLAYER, (curlevel->p1x * TILEW) + (TILEW/2),
(curlevel->p1y * TILEH) + TILEH-2 , "Player" );
player = lastsprite;
player = addsprite(P_PLAYER, (curlevel->p1x * TILEW) + (TILEW/2),
(curlevel->p1y * TILEH) + TILEH-2 , "Player 1" );
}
}
if (want2up) {
if (player2 == NULL) {
player2 = addsprite(P_PLAYER2, (curlevel->p2x * TILEW) + (TILEW/2),
(curlevel->p2y * TILEH) + TILEH-2 , "Player 2" );
}
}
// don't move player to start of the level if they already exist, becuase they're
@ -512,6 +532,8 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
player->x = (curlevel->p1x * TILEW) + (TILEW/2);
player->y = (curlevel->p1y * TILEH) + TILEH-2 ;
player2->x = (curlevel->p2x * TILEW) + (TILEW/2);
player2->y = (curlevel->p2y * TILEH) + TILEH-2 ;
#endif
/*else {
@ -570,7 +592,6 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
resethurryup(level);
boss = NULL;
mask = NULL;
printf("Done.\n");
/*
@ -586,7 +607,7 @@ printf(".\n");
void setdefaults(sprite_t *s) {
if (s == player) {
if (isplayer(s)) {
// player powerup stats
if (s->permspeed) {
s->speed = 2;
@ -750,7 +771,7 @@ void setdefaults(sprite_t *s) {
}
if (s != player) {
if (!isplayer(s)) {
s->score = getpoints(s->id);
}
@ -1132,6 +1153,24 @@ int loadimagesets(void) {
loadspriteimage(P_PLAYER,F_SWIM2, "sprites/dswim2.png");
imageset[P_PLAYER].numimages = 18;
loadspriteimage(P_PLAYER2,F_WALK1, "sprites/p2dwarf.png");
loadspriteimage(P_PLAYER2,F_JUMP, "sprites/p2dwarfjump.png");
loadspriteimage(P_PLAYER2,F_FALL, "sprites/p2dwarffall.png");
loadspriteimage(P_PLAYER2,F_CAUGHT, "sprites/p2dwarf.png");
loadspriteimage(P_PLAYER2,F_DEAD, "sprites/dwarf2die.png");
/* next 3 are auto generated */
loadspriteimage(P_PLAYER2,F_CLIMB1, "sprites/d2climb1.png");
loadspriteimage(P_PLAYER2,F_CLIMB2, "sprites/d2climb2.png");
loadspriteimage(P_PLAYER2,F_SHOOT, "sprites/dwarf2shoot.png");
loadspriteimage(P_PLAYER2,F_SLAM1, "sprites/d2slam1.png");
loadspriteimage(P_PLAYER2,F_SLAM2, "sprites/d2slam2.png");
loadspriteimage(P_PLAYER2,F_SLAM3, "sprites/d2slam3.png");
loadspriteimage(P_PLAYER2,F_SLAM4, "sprites/d2slam4.png");
loadspriteimage(P_PLAYER2,F_SLAM5, "sprites/d2slam5.png");
loadspriteimage(P_PLAYER2,F_SWIM1, "sprites/d2swim1.png");
loadspriteimage(P_PLAYER2,F_SWIM2, "sprites/d2swim2.png");
imageset[P_PLAYER2].numimages = 18;
loadspriteimage(P_ARMOUR,F_WALK1, "sprites/armor.png");
loadspriteimage(P_ARMOUR,F_JUMP, "sprites/armorjump.png");
loadspriteimage(P_ARMOUR,F_FALL, "sprites/armorfall.png");
@ -1676,16 +1715,21 @@ void drawsprite(sprite_t *s) {
int frame = 0;
// don't show caught mosnters in gunner mode
if ((s != player) && (s->caughtby == player) && (player->powerup == PW_GUNNER)) {
if (!isplayer(s) && (s->caughtby) ) {
if ((player) && (player->powerup == PW_GUNNER)) {
return;
}
if ((player2) && (player2->powerup == PW_GUNNER)) {
return;
}
}
if ((s == player) && (levelcomplete == LV_NEXTLEV)) {
if (isplayer(s) && (levelcomplete == LV_NEXTLEV)) {
frame = F_SHOOT;
if (curlevel->exitdir == D_RIGHT) {
player->dir = 1;
s->dir = 1;
} else if (curlevel->exitdir == D_LEFT) {
player->dir = -1;
s->dir = -1;
}
} else {
/* select frame */
@ -1726,8 +1770,8 @@ void drawsprite(sprite_t *s) {
frame = s->timer1;
} else if (s->id == P_MASK) {
// only draw this if the player is swimming
if (player->swimming) {
if (player->dir > 0) {
if (s->owner->swimming) {
if (s->owner->dir > 0) {
frame = 0;
} else {
frame = 1;
@ -1744,7 +1788,7 @@ void drawsprite(sprite_t *s) {
}
} else if (s->dead) {
if (s == player) {
if (isplayer(s)) {
frame = F_DEAD;
} else if (s == boss) {
frame = F_DEAD;
@ -1795,7 +1839,7 @@ void drawsprite(sprite_t *s) {
} else {
frame = F_CLIMB1;
}
} else if ((s->swimming) && (s == player) && !s->slamming) {
} else if ((s->swimming) && isplayer(s) && !s->slamming) {
if ((timer/12) % 2 == 0) {
frame = F_SWIM1;
} else {
@ -1893,13 +1937,13 @@ void drawsprite(sprite_t *s) {
frame += MAXFRAMES;
}
} else if ((s->id == P_WINGLEFT) || (s->id == P_WINGRIGHT)) {
if (player->dir == -1) {
if (s->owner->dir == -1) {
frame += MAXFRAMES;
}
}
/* make red if required */
if (s->angry && s->id != P_BLACKCLOUD) {
if (s != player) {
if (!isplayer(s)) {
frame += (MAXFRAMES*2);
}
}
@ -1985,7 +2029,7 @@ void drawsprite(sprite_t *s) {
if ((s->invuln) && (levelcomplete != LV_HELPFREEZE)) {
if (timer % 2 == 0) {
//SDL_BlitSurface(s->img, NULL, screen, &area);
if (s == player) {
if (isplayer(s)) {
drawplayer(s, &area);
} else {
doblit(s->img, screen, &area);
@ -1993,7 +2037,7 @@ void drawsprite(sprite_t *s) {
}
} else if ((s->doomcount > 0) && (s->doomcount <= 150) && (levelcomplete != LV_HELPFREEZE)) {
if ((timer/2) % 2 == 0) {
if (s == player) {
if (isplayer(s)) {
drawplayer(s, &area);
} else {
doblit(s->img, screen, &area);
@ -2005,7 +2049,7 @@ void drawsprite(sprite_t *s) {
doblit(s->img, screen, &area);
}
} else {
if (s == player) {
if (isplayer(s)) {
drawplayer(s, &area);
} else {
doblit(s->img, screen, &area);
@ -2086,14 +2130,16 @@ void killsprite(sprite_t *s) {
}
// remove mask pointer
/*
if (mask == s) {
mask = NULL;
}
*/
if (s->caughtby) {
s->caughtby = NULL;
s->caughtstate = B_FALSE;
player->netcaught--;
s->caughtby->netcaught--;
}
s->zapping = NULL;
@ -2882,6 +2928,7 @@ int randompowerup(void) {
int num;
num = rand() % 34;
return getrandomcard();
switch (num) {
case 0:
default:
@ -3300,11 +3347,20 @@ int getrandomcard(void) {
}
}
}
if (player2) {
for (i = 0; i < player2->numcards; i++) {
if (player2->card[i] == cardid) {
gotit = B_TRUE;
}
}
}
// are we forcing it to be good?
if ((forcegoodcard) && (player->numcards > 0)) {
if (forcegoodcard) {
if ((player && player->numcards > 0) || (player2 && player2->numcards > 0)) {
int okay = B_FALSE;
int csuit,cval;
if (player) {
for (i = 0; i < player->numcards; i++) {
cval = getcardvalue(player->card[i]);
csuit = getcardsuit(player->card[i]);
@ -3313,12 +3369,24 @@ int getrandomcard(void) {
if (cval == (getcardvalue(cardid)+1)) okay = B_TRUE;
if (cval == (getcardvalue(cardid)-1)) okay = B_TRUE;
}
}
if (player2) {
for (i = 0; i < player2->numcards; i++) {
cval = getcardvalue(player2->card[i]);
csuit = getcardsuit(player2->card[i]);
if (csuit == getcardsuit(cardid)) okay = B_TRUE;
if (cval == (getcardvalue(cardid))) okay = B_TRUE;
if (cval == (getcardvalue(cardid)+1)) okay = B_TRUE;
if (cval == (getcardvalue(cardid)-1)) okay = B_TRUE;
}
}
// if not a good card, go to next one
if (!okay) {
gotit = B_TRUE;
}
}
}
}
//printf("returning cardid %d\n",cardid);
@ -3518,7 +3586,7 @@ void drawplayer(sprite_t *s, SDL_Rect *where) {
#ifndef __EDITOR
if (player->powerup == PW_GUNNER) {
if (s->powerup == PW_GUNNER) {
// just draw crosshairs
// box
drawbox16(screen, s->x-(TILEW/2),s->y-(TILEH/2),s->x+(TILEW/2),s->y+(TILEH/2), &green, NULL);
@ -3641,3 +3709,16 @@ void resethurryup(level_t *lev) {
nexthurryup += 15;
}
}
int isplayer(sprite_t *s) {
if (player && (s == player)) return B_TRUE;
if (player2 && (s == player2)) return B_TRUE;
return B_FALSE;
}
int playersalive(void) {
if (player && player->dead) return B_FALSE;
if (player2 && player2->dead) return B_FALSE;
return B_TRUE;
}

View File

@ -63,9 +63,13 @@ int getworld(int lev);
int getlevel(int lev);
void drawplayer(sprite_t *s, SDL_Rect *where);
void resethurryup(level_t *lev);
int isplayer(sprite_t *s);
int isplayer(sprite_t *s);
int playersalive();
// for doco
void setfruitinfo(void);
void setinfo(int id, char *name, char *desc, char *file);
void dumpinfo(void);
#endif