From ae07b2831383b7f240e2d65a863a98bd47a2baa2 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 18 Nov 2008 22:25:54 +0000 Subject: [PATCH] Tweaked monster movement: - monsters will now drop off the bottom of the screen to follow players - monsters are now better at jumping over gaps --- data/levels.dat | 2 ++ data/world1/level99.dat | 78 +++++++++++++++++------------------------ defs.h | 1 + rc.c | 39 +++++++++++++++++++-- shared.c | 10 ++++++ 5 files changed, 82 insertions(+), 48 deletions(-) diff --git a/data/levels.dat b/data/levels.dat index 07c15a2..ce4b8bc 100644 --- a/data/levels.dat +++ b/data/levels.dat @@ -49,7 +49,9 @@ 411,level411.dat,Infested Pipes 415,level415.dat,Half Way 42,level42.dat,Precarious Jumps +416,level416.dat,A Busy Day 413,level413.dat,Three Parts 412,level412.dat,Test Tubes 109,level109.dat,THE END SO FAR 99,level99.dat,TEST LEVEL +417,level417.dat,NEW LEVEL diff --git a/data/world1/level99.dat b/data/world1/level99.dat index 1fb4c99..c69fe20 100644 --- a/data/world1/level99.dat +++ b/data/world1/level99.dat @@ -4,53 +4,41 @@ hurryup 30 help endhelp monsters -0 12 13 -134 16 13 -23 17 10 -17 1 13 -17 7 13 -1 37 12 -7 30 15 -1 2 28 -1 5 2 -7 3 4 -50 32 13 -49 9 13 -1 12 23 +0 23 25 +134 33 15 +18 9 15 +18 10 25 +50 6 25 endmonsters 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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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,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,4,4,4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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 -38,0,4 -30,7,8 -18,11,8 -22,11,8 diff --git a/defs.h b/defs.h index 3f9cb7b..bff54a1 100644 --- a/defs.h +++ b/defs.h @@ -723,6 +723,7 @@ typedef struct level_s { int *animtiles; // array of offsets to map positions which are animated struct level_s *next; struct level_s *prev; + int bottomopen; // can you fall through the bottom of the level? int p1x; /* player 1 start pos */ int p1y; int p2x; /* player 2 start pos */ diff --git a/rc.c b/rc.c index 809666c..1480086 100644 --- a/rc.c +++ b/rc.c @@ -356,7 +356,7 @@ int main (int argc, char **argv) { } else { // cheat want1up = B_TRUE; - want2up = B_TRUE; + want2up = B_FALSE; } // shuffle cards @@ -1295,7 +1295,9 @@ void jump(sprite_t *s, int dir) { s->jumping = 1; s->dir = -s->jumpdir; // face backwards } else { - s->jumpdir = dir; + // TODO: check this (the * getspeed bit)! + //s->jumpdir = s->dir * getspeed(s); + s->jumpdir = s->dir; if (s->jumpdir != 0) { s->dir = s->jumpdir; } @@ -2252,6 +2254,7 @@ int movesprite(sprite_t *s) { if (s->jumptimer == 0) { s->jumping = 1; s->jumpspeed = s->willjumpspeed; +printf("jumping: %0.2f\n",s->jumpdir); if (s->jumpdir != 0) s->dir = s->jumpdir; return B_FALSE; } 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))) { 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); if ((tunder->solid == S_SLOPE) || (t2under->solid == S_SLOPE)) { movex(s, s->dir*getspeed(s)); + } else if (s->jumpdir) { + movex(s, s->jumpdir*getspeed(s)); } } } else if (s->id == P_SNAIL) { @@ -2804,6 +2812,9 @@ int movesprite(sprite_t *s) { if (xdiff <= (TILEW*8)) { 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 { @@ -2859,6 +2870,8 @@ int movesprite(sprite_t *s) { if (s->recoiling) { // fall backwards rv = movex(s, -s->dir*getspeed(s)); + } else if (s->jumpdir) { + movex(s, s->jumpdir*getspeed(s)); } } } 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))) { 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 { move = B_TRUE; @@ -2911,7 +2927,7 @@ int movesprite(sprite_t *s) { (player2 && (!player2->dead) && (player2->y <= s->y))) { int ydiff; - if (player && (!player->dead) && (player->y <= s->y-TILEH)) { + if ( (player && (!player->dead) && (player->y <= s->y))) { ydiff = s->y - player->y; } else { 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))) { 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 { 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) { /* timer1 loopsfrom 0 - 19 @@ -3412,6 +3433,9 @@ int movesprite(sprite_t *s) { 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 { @@ -3502,6 +3526,8 @@ int movesprite(sprite_t *s) { } } } + } else { // falling + movex(s, s->jumpdir*getspeed(s)); } } else if (s->id == P_BEE) { @@ -5968,6 +5994,12 @@ void dogravity(sprite_t *s) { s->useddoublejump = B_FALSE; } + // reset jumpdir + if (!s->jumptimer) { + s->jumpdir = 0; + } +//oooooooooo + if (s->falling && s->iced) { // when an iced monster hits the ground, it smashes @@ -10873,3 +10905,4 @@ sprite_t *isplayerright(sprite_t *s) { return NULL; } + diff --git a/shared.c b/shared.c index 98f92b6..2987fb3 100644 --- a/shared.c +++ b/shared.c @@ -378,6 +378,7 @@ int loadlevel(int wnum, int lnum, int wantmonsters) { x = 0; y = 0; leveldone = B_FALSE; + level->bottomopen = B_FALSE; // default, could get chnaged in the next block of code while (!leveldone) { /* process a line of level data */ if (newversion) { @@ -416,6 +417,15 @@ int loadlevel(int wnum, int lnum, int wantmonsters) { 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++; p = strtok(NULL, ","); }