- Added animation for slamming

This commit is contained in:
Rob Pearce 2008-09-27 10:50:19 +00:00
parent 89cce7f749
commit 9b2ff9f4ca
13 changed files with 111 additions and 73 deletions

7
defs.h
View File

@ -59,7 +59,7 @@
#define MAXMAPPINGS 50 #define MAXMAPPINGS 50
#define MAXMONSTERSPERLEVEL 40 #define MAXMONSTERSPERLEVEL 40
#define MAXLETTERHEIGHT 100 #define MAXLETTERHEIGHT 100
#define MAXFRAMES 11 // max number of frames for sprites #define MAXFRAMES 16 // max number of frames for sprites
#define MAXHELP 5 #define MAXHELP 5
#define MAXTILEFRAMES 10 // max number of frames for animated tiles #define MAXTILEFRAMES 10 // max number of frames for animated tiles
@ -137,6 +137,11 @@
#define F_CLIMB1 8 #define F_CLIMB1 8
#define F_CLIMB2 9 #define F_CLIMB2 9
#define F_SHOOT 10 #define F_SHOOT 10
#define F_SLAM1 11
#define F_SLAM2 12
#define F_SLAM3 13
#define F_SLAM4 14
#define F_SLAM5 15
// Tile types // Tile types
#define T_BLANK 0 #define T_BLANK 0

BIN
rc

Binary file not shown.

13
rc.c
View File

@ -772,7 +772,6 @@ void movesprite(sprite_t *s) {
tiletype_t *tt; tiletype_t *tt;
tt = gettileat(s->x,s->y,&tx,&ty); tt = gettileat(s->x,s->y,&tx,&ty);
printf("finished bouncing, sprite is at: %d, %d (tileid %d)\n",tx,ty,tt->id);
s->dead = D_LASTBOUNCE; s->dead = D_LASTBOUNCE;
} }
} }
@ -2267,18 +2266,6 @@ int dofruiteffect(sprite_t *s) {
return B_FALSE; return B_FALSE;
} }
int ismonster(int id) {
if (id == P_RAT) return B_TRUE;
if (id == P_BEE) return B_TRUE;
if (id == P_SPIDER) return B_TRUE;
if (id == P_SNAKE) return B_TRUE;
if (id == P_CLOUD) return B_TRUE;
if (id == P_COKE) return B_TRUE;
return B_FALSE;
}
void usage(void) { void usage(void) {
printf("usage: rc [-fs] [-l xx]\n"); printf("usage: rc [-fs] [-l xx]\n");
printf(" -fs Start in full-screen mode.\n"); printf(" -fs Start in full-screen mode.\n");

1
rc.h
View File

@ -24,7 +24,6 @@ int isonladder(sprite_t *s);
int isonbridge(sprite_t *s); int isonbridge(sprite_t *s);
int isladderabove(sprite_t *s); int isladderabove(sprite_t *s);
int dofruiteffect(sprite_t *s); int dofruiteffect(sprite_t *s);
int ismonster(int id);
void checkcollide(sprite_t *s); void checkcollide(sprite_t *s);
void die(sprite_t *s); void die(sprite_t *s);
void nextlevel(void); void nextlevel(void);

View File

@ -40,6 +40,8 @@ int loadlevel(int wnum, int lnum) {
int numanim = 0; int numanim = 0;
int tempanim[LEVELW*LEVELH]; int tempanim[LEVELW*LEVELH];
int numenemies = 0;
printf("Loading level %d-%d...",wnum,lnum); printf("Loading level %d-%d...",wnum,lnum);
@ -231,6 +233,8 @@ int loadlevel(int wnum, int lnum) {
level->initm[level->nummonsters].starty = y*TILEH+(TILEH-2)+2; level->initm[level->nummonsters].starty = y*TILEH+(TILEH-2)+2;
level->initm[level->nummonsters].id = monid; level->initm[level->nummonsters].id = monid;
if (ismonster(monid)) numenemies++;
if (monid == P_HELP) { if (monid == P_HELP) {
if (curhelp >= numhelp) { if (curhelp >= numhelp) {
printf("Error in level - more help icons than help texts.\n"); printf("Error in level - more help icons than help texts.\n");
@ -252,6 +256,8 @@ int loadlevel(int wnum, int lnum) {
fgets(buf, BUFLEN, f); fgets(buf, BUFLEN, f);
} }
printf("got %d monsters\n", numenemies);
/* check whether we've got a new or old level version */ /* check whether we've got a new or old level version */
if (strstr(buf, ",")) { if (strstr(buf, ",")) {
/* new version */ /* new version */
@ -873,7 +879,12 @@ int loadimagesets(void) {
loadspriteimage(P_PLAYER,F_CLIMB1, "sprites/dclimb1.png"); loadspriteimage(P_PLAYER,F_CLIMB1, "sprites/dclimb1.png");
loadspriteimage(P_PLAYER,F_CLIMB2, "sprites/dclimb2.png"); loadspriteimage(P_PLAYER,F_CLIMB2, "sprites/dclimb2.png");
loadspriteimage(P_PLAYER,F_SHOOT, "sprites/dwarfshoot.png"); loadspriteimage(P_PLAYER,F_SHOOT, "sprites/dwarfshoot.png");
imageset[P_PLAYER].numimages = 11; loadspriteimage(P_PLAYER,F_SLAM1, "sprites/dslam1.png");
loadspriteimage(P_PLAYER,F_SLAM2, "sprites/dslam2.png");
loadspriteimage(P_PLAYER,F_SLAM3, "sprites/dslam3.png");
loadspriteimage(P_PLAYER,F_SLAM4, "sprites/dslam4.png");
loadspriteimage(P_PLAYER,F_SLAM5, "sprites/dslam5.png");
imageset[P_PLAYER].numimages = 16;
loadspriteimage(P_SNAKE,F_WALK1, "sprites/snake.bmp"); loadspriteimage(P_SNAKE,F_WALK1, "sprites/snake.bmp");
loadspriteimage(P_SNAKE,F_JUMP, "sprites/snakejump.bmp"); loadspriteimage(P_SNAKE,F_JUMP, "sprites/snakejump.bmp");
@ -1099,6 +1110,19 @@ void drawsprite(sprite_t *s) {
frame = F_JUMP; frame = F_JUMP;
} else if (s->falling) { } else if (s->falling) {
frame = F_FALL; frame = F_FALL;
} else if (s->slamming) {
double slamdegs = s->slamangle / (M_PI/180);
if (slamdegs < 36) {
frame = F_SLAM1;
} else if (slamdegs < 72) {
frame = F_SLAM2;
} else if (slamdegs < 108) {
frame = F_SLAM3;
} else if (slamdegs < 144) {
frame = F_SLAM4;
} else {
frame = F_SLAM5;
}
} else if (!s->teleporting) { } else if (!s->teleporting) {
if ((s->id == P_SPIDER) && (s->ys != -99)) { if ((s->id == P_SPIDER) && (s->ys != -99)) {
frame = F_FALL; frame = F_FALL;
@ -1551,3 +1575,14 @@ int candoslopes(int sid) {
} }
return B_TRUE; return B_TRUE;
} }
int ismonster(int id) {
if (id == P_RAT) return B_TRUE;
if (id == P_BEE) return B_TRUE;
if (id == P_SPIDER) return B_TRUE;
if (id == P_SNAKE) return B_TRUE;
if (id == P_CLOUD) return B_TRUE;
if (id == P_COKE) return B_TRUE;
return B_FALSE;
}

View File

@ -31,6 +31,7 @@ char monstertochar(int id);
tiletype_t *gettile(int tid); tiletype_t *gettile(int tid);
void drawtile(SDL_Surface *s, int x, int y); void drawtile(SDL_Surface *s, int x, int y);
void initglobals(void); void initglobals(void);
int ismonster(int id);
SDL_Surface *loadspriteimage(int spriteid, int frame, char *filename); SDL_Surface *loadspriteimage(int spriteid, int frame, char *filename);
#endif #endif

BIN
sprites/dslam1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

BIN
sprites/dslam2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
sprites/dslam3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

BIN
sprites/dslam4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
sprites/dslam5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,68 +1,79 @@
tileset castle tileset green
bg 0 bg 0
hurryup 30 hurryup 60
endmaps endmaps
help help
endhelp endhelp
monsters monsters
1 1 21 @ 11 5
a 10 3 @ 12 9
a 35 3 @ 27 9
r 19 6 @ 28 5
r 3 7 @ 31 28
r 37 8 @ 32 15
s 14 24 @ 34 15
s 26 24 @ 5 15
@ 34 8 @ 5 28
@ 2 7 @ 7 15
@ 5 7 P 10 19
Y 25 6 P 11 15
Y 17 6 P 19 5
Y 25 11 P 20 5
Y 21 11 P 21 5
Y 34 11 P 28 15
Y 12 11 P 29 19
Y 16 11 P 30 15
Y 29 11 P 9 15
P 20 28 S 7 5
P 20 28 Y 1 15
P 20 28 Y 11 9
P 34 28 Y 13 9
P 34 28 Y 26 9
P 34 28 Y 28 9
P 34 28 Y 3 15
P 7 28 Y 30 28
P 7 28 Y 32 28
P 7 28 Y 36 15
P 7 28 Y 38 15
Y 4 28
Y 6 28
a 31 3
a 7 19
1 18 15
r 27 5
r 16 5
r 10 12
r 29 12
r 6 15
r 31 15
endmonsters endmonsters
4,4,4,4,4,4,4,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3,0,0,0,0,0,0,0,0,4,
4,0,0,0,0,0,0,0,2,4,4,4,4,1,1,1,1,4,4,4,4,4,4,4,4,4,1,1,4,4,4,3,0,0,0,0,0,0,0,4,
4,1,1,15,15,15,1,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,15,15,15,15,15,15,15,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,14,4,14,14,14,14,14,1,14,14,14,14,14,14,14,14,14,14,14,14,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,
4,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,4,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,