Tweaked monster movement:

- monsters will now drop off the bottom of the screen to follow 
	  players
	- monsters are now better at jumping over gaps
This commit is contained in:
Rob Pearce 2008-11-18 22:25:54 +00:00
parent 13feabf3fc
commit ae07b28313
5 changed files with 82 additions and 48 deletions

View File

@ -49,7 +49,9 @@
411,level411.dat,Infested Pipes 411,level411.dat,Infested Pipes
415,level415.dat,Half Way 415,level415.dat,Half Way
42,level42.dat,Precarious Jumps 42,level42.dat,Precarious Jumps
416,level416.dat,A Busy Day
413,level413.dat,Three Parts 413,level413.dat,Three Parts
412,level412.dat,Test Tubes 412,level412.dat,Test Tubes
109,level109.dat,THE END SO FAR 109,level109.dat,THE END SO FAR
99,level99.dat,TEST LEVEL 99,level99.dat,TEST LEVEL
417,level417.dat,NEW LEVEL

View File

@ -4,53 +4,41 @@ hurryup 30
help help
endhelp endhelp
monsters monsters
0 12 13 0 23 25
134 16 13 134 33 15
23 17 10 18 9 15
17 1 13 18 10 25
17 7 13 50 6 25
1 37 12
7 30 15
1 2 28
1 5 2
7 3 4
50 32 13
49 9 13
1 12 23
endmonsters endmonsters
exitdir 1 exitdir 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,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,
1,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,
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,4,
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,1,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,0,0,0,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,1,1,1,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,0,0,0,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,0,0,0,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,1,1,1,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,0,0,0,0,0,4,4,4,4,0,0,0,4,
4,4,4,4,4,4,4,4,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4,4,11,11,11,11,11,4,4,4,4,0,0,0,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,1,1,1,4,
4,4,4,4,4,0,0,0,0,0,0,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,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, 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,
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, 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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,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,4,
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,1,1,1,1,1,1,1,1,1,0,0,0,0,4,
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,
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,
layer2 layer2
38,0,4
30,7,8
18,11,8
22,11,8

1
defs.h
View File

@ -723,6 +723,7 @@ typedef struct level_s {
int *animtiles; // array of offsets to map positions which are animated int *animtiles; // array of offsets to map positions which are animated
struct level_s *next; struct level_s *next;
struct level_s *prev; struct level_s *prev;
int bottomopen; // can you fall through the bottom of the level?
int p1x; /* player 1 start pos */ int p1x; /* player 1 start pos */
int p1y; int p1y;
int p2x; /* player 2 start pos */ int p2x; /* player 2 start pos */

39
rc.c
View File

@ -356,7 +356,7 @@ int main (int argc, char **argv) {
} else { } else {
// cheat // cheat
want1up = B_TRUE; want1up = B_TRUE;
want2up = B_TRUE; want2up = B_FALSE;
} }
// shuffle cards // shuffle cards
@ -1295,7 +1295,9 @@ void jump(sprite_t *s, int dir) {
s->jumping = 1; s->jumping = 1;
s->dir = -s->jumpdir; // face backwards s->dir = -s->jumpdir; // face backwards
} else { } else {
s->jumpdir = dir; // TODO: check this (the * getspeed bit)!
//s->jumpdir = s->dir * getspeed(s);
s->jumpdir = s->dir;
if (s->jumpdir != 0) { if (s->jumpdir != 0) {
s->dir = s->jumpdir; s->dir = s->jumpdir;
} }
@ -2252,6 +2254,7 @@ int movesprite(sprite_t *s) {
if (s->jumptimer == 0) { if (s->jumptimer == 0) {
s->jumping = 1; s->jumping = 1;
s->jumpspeed = s->willjumpspeed; s->jumpspeed = s->willjumpspeed;
printf("jumping: %0.2f\n",s->jumpdir);
if (s->jumpdir != 0) s->dir = s->jumpdir; if (s->jumpdir != 0) s->dir = s->jumpdir;
return B_FALSE; return B_FALSE;
} else if (s->jumptimer % 20 == 0) { } else if (s->jumptimer % 20 == 0) {
@ -2726,6 +2729,9 @@ int movesprite(sprite_t *s) {
} else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*7))) { } else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*7))) {
jump(s,D_LEFT); jump(s,D_LEFT);
} }
} else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) {
// if near bottom of the screen and can fall through...
move = B_TRUE;
} }
} }
} }
@ -2784,6 +2790,8 @@ int movesprite(sprite_t *s) {
t2under = gettileat(s->x ,s->y+s->img->h,NULL,NULL); t2under = gettileat(s->x ,s->y+s->img->h,NULL,NULL);
if ((tunder->solid == S_SLOPE) || (t2under->solid == S_SLOPE)) { if ((tunder->solid == S_SLOPE) || (t2under->solid == S_SLOPE)) {
movex(s, s->dir*getspeed(s)); movex(s, s->dir*getspeed(s));
} else if (s->jumpdir) {
movex(s, s->jumpdir*getspeed(s));
} }
} }
} else if (s->id == P_SNAIL) { } else if (s->id == P_SNAIL) {
@ -2804,6 +2812,9 @@ int movesprite(sprite_t *s) {
if (xdiff <= (TILEW*8)) { if (xdiff <= (TILEW*8)) {
move = B_TRUE; move = B_TRUE;
} }
} else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) {
// if near bottom of the screen and can fall through...
move = B_TRUE;
} }
} }
} else { } else {
@ -2859,6 +2870,8 @@ int movesprite(sprite_t *s) {
if (s->recoiling) { if (s->recoiling) {
// fall backwards // fall backwards
rv = movex(s, -s->dir*getspeed(s)); rv = movex(s, -s->dir*getspeed(s));
} else if (s->jumpdir) {
movex(s, s->jumpdir*getspeed(s));
} }
} }
} else if (s->id == P_SLUG) { } else if (s->id == P_SLUG) {
@ -2886,6 +2899,9 @@ int movesprite(sprite_t *s) {
} else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*9))) { } else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*9))) {
jump(s,D_LEFT); jump(s,D_LEFT);
} }
} else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) {
// if near bottom of the screen and can fall through...
move = B_TRUE;
} }
} else { } else {
move = B_TRUE; move = B_TRUE;
@ -2911,7 +2927,7 @@ int movesprite(sprite_t *s) {
(player2 && (!player2->dead) && (player2->y <= s->y))) { (player2 && (!player2->dead) && (player2->y <= s->y))) {
int ydiff; int ydiff;
if (player && (!player->dead) && (player->y <= s->y-TILEH)) { if ( (player && (!player->dead) && (player->y <= s->y))) {
ydiff = s->y - player->y; ydiff = s->y - player->y;
} else { } else {
ydiff = s->y - player2->y; ydiff = s->y - player2->y;
@ -3330,6 +3346,9 @@ int movesprite(sprite_t *s) {
} else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*7))) { } else if ((s->dir == D_LEFT) && (xdiff < 0) && (xdiff >= -(TILEW*7))) {
jump(s,D_LEFT); jump(s,D_LEFT);
} }
} else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) {
// if near bottom of the screen and can fall through...
move = B_TRUE;
} }
} else { } else {
move = B_TRUE; move = B_TRUE;
@ -3371,6 +3390,8 @@ int movesprite(sprite_t *s) {
} }
} }
} }
} else { // falling
movex(s, s->jumpdir*getspeed(s));
} }
} else if (s->id == P_SNAKE) { } else if (s->id == P_SNAKE) {
/* timer1 loopsfrom 0 - 19 /* timer1 loopsfrom 0 - 19
@ -3412,6 +3433,9 @@ int movesprite(sprite_t *s) {
jump(s,D_LEFT); jump(s,D_LEFT);
} }
} }
} else if (level->bottomopen && (s->y >= (480 - 100)) && isplayerabove(s)) {
// if near bottom of the screen and can fall through...
move = B_TRUE;
} }
} }
} else { } else {
@ -3502,6 +3526,8 @@ int movesprite(sprite_t *s) {
} }
} }
} }
} else { // falling
movex(s, s->jumpdir*getspeed(s));
} }
} else if (s->id == P_BEE) { } else if (s->id == P_BEE) {
@ -5968,6 +5994,12 @@ void dogravity(sprite_t *s) {
s->useddoublejump = B_FALSE; s->useddoublejump = B_FALSE;
} }
// reset jumpdir
if (!s->jumptimer) {
s->jumpdir = 0;
}
//oooooooooo
if (s->falling && s->iced) { if (s->falling && s->iced) {
// when an iced monster hits the ground, it smashes // when an iced monster hits the ground, it smashes
@ -10873,3 +10905,4 @@ sprite_t *isplayerright(sprite_t *s) {
return NULL; return NULL;
} }

View File

@ -378,6 +378,7 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
x = 0; x = 0;
y = 0; y = 0;
leveldone = B_FALSE; leveldone = B_FALSE;
level->bottomopen = B_FALSE; // default, could get chnaged in the next block of code
while (!leveldone) { while (!leveldone) {
/* process a line of level data */ /* process a line of level data */
if (newversion) { if (newversion) {
@ -416,6 +417,15 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
numanim++; numanim++;
} }
// if this is the last line, update level->bottomopen
if (y == LEVELH-1) {
tiletype_t *thistile;
thistile = gettile(tileid);
if (!thistile->solid) {
level->bottomopen = B_TRUE;
}
}
x++; x++;
p = strtok(NULL, ","); p = strtok(NULL, ",");
} }