- Added new monster: fly

- Level tweaks
- Removed broken moving platform inertia - they now just pause.
This commit is contained in:
Rob Pearce 2008-11-09 05:24:07 +00:00
parent 1bc25f661f
commit 81210a050a
12 changed files with 234 additions and 82 deletions

View File

@ -39,10 +39,12 @@
18,level8.5.dat,Look out above... 18,level8.5.dat,Look out above...
40,level40.dat,King Snail 40,level40.dat,King Snail
41,level41.dat,Basic Kitchen 41,level41.dat,Basic Kitchen
42,level42.dat,Precarious Loaves 407,level407.dat,The Fly
403,level403.dat,Delayed Release
404,level404.dat,Off Cuts 404,level404.dat,Off Cuts
42,level42.dat,Precarious Loaves
405,level405.dat,Pitfalls 405,level405.dat,Pitfalls
403,level403.dat,Delayed Release
406,level406.dat,The Kitchen Sink
109,level109.dat,THE END SO FAR 109,level109.dat,THE END SO FAR
99,level99.dat,TEST LEVEL 99,level99.dat,TEST LEVEL
406,level406.dat,NEW LEVEL 408,level408.dat,NEW LEVEL

BIN
data/sprites/fly.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/sprites/flycaught.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

BIN
data/sprites/flydead.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/sprites/flyjump.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/sprites/flywalk2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -6,11 +6,9 @@ endhelp
monsters monsters
0 6 28 0 6 28
23 23 14 23 23 14
132 13 27 260 412 205 384 254 352 206 325 249 296 207 266 249 266 210 296 248 322 209 351 252 381 210 409 256 441 209 441
6 23 5 6 23 5
1 25 20 1 25 20
18 38 10 18 38 10
6 32 19
1 8 5 1 8 5
124 27 11 124 27 11
124 34 7 124 34 7
@ -30,6 +28,8 @@ monsters
16 26 1 16 26 1
16 25 1 16 25 1
16 22 1 16 22 1
132 11 27 184 448 278 246
133 32 19
endmonsters endmonsters
exitdir 1 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, 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,
@ -63,11 +63,6 @@ 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, 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,
57,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,57, 57,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,57,
layer2 layer2
13,0,62
14,0,62
15,0,62
16,0,62
17,0,62
36,11,8 36,11,8
36,12,7 36,12,7
36,13,7 36,13,7

View File

@ -54,8 +54,8 @@ 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, 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,
57,58,58,58,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,58,58,58,57, 57,58,58,58,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,58,58,58,57,
57,57,57,57,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,57,57,57,57,57, 57,57,57,57,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,57,57,57,57,57,
57,57,57,57,57,58,0,0,0,0,0,0,59,58,58,58,58,58,58,58,58,58,58,58,58,58,60,0,0,0,0,0,0,0,58,57,57,57,57,57, 57,57,57,57,57,58,0,0,0,0,0,0,0,0,0,0,59,58,58,58,58,58,60,0,0,0,0,0,0,0,0,0,0,0,58,57,57,57,57,57,
57,57,57,57,57,57,58,58,58,58,58,58,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,57,57,57,57,57,57, 57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,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,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,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,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,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,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,57,57,57,57,57,57,

13
defs.h
View File

@ -325,7 +325,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 133 #define MAXPTYPES 134
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -464,8 +464,18 @@
#define P_BIGNUMNETS 130 #define P_BIGNUMNETS 130
#define P_RANDOM 131 #define P_RANDOM 131
#define P_PLATFORM 132 #define P_PLATFORM 132
#define P_FLY 133
#define FLY_FLYTIME 150
#define FLY_WALKTIME 300
#define F_WALK 0
#define F_FLYHORZ 1
#define F_FLYVERT 2
#define PLATFORMPAUSE 60
#define PLATFORMDELAY 4 #define PLATFORMDELAY 4
#define PLATFORM_ACCEL 0.5 // how fast platforms accelerate/decellerate #define PLATFORM_ACCEL 0.5 // how fast platforms accelerate/decellerate
#define PLATFORM_MINSPEED 0.3 #define PLATFORM_MINSPEED 0.3
@ -564,6 +574,7 @@
#define MV_NONE 0 // didn't move #define MV_NONE 0 // didn't move
#define MV_WALK 1 // walked/climbed on purpose #define MV_WALK 1 // walked/climbed on purpose
#define MV_ICE 3 // slid on ice #define MV_ICE 3 // slid on ice
#define MV_FLY 4 // flying
// Tile types // Tile types

7
edit.c
View File

@ -840,8 +840,9 @@ void drawsprites(void) {
for (s = sprite; s != NULL; s = s->next) { for (s = sprite; s != NULL; s = s->next) {
drawsprite(s); drawsprite(s);
// waypoint selection mode // waypoint selection mode
if (state == LS_WAYPOINTS) { //if (state == LS_WAYPOINTS) {
if (waypointm == s) { //if (waypointm == s) {
if (s->id == P_PLATFORM) {
int i; int i;
double curx,cury; double curx,cury;
drawbox16(screen, s->x - s->img->w/2,s->y - s->img->h, drawbox16(screen, s->x - s->img->w/2,s->y - s->img->h,
@ -856,7 +857,7 @@ void drawsprites(void) {
curx = s->wayx[i]; cury = s->wayy[i]; curx = s->wayx[i]; cury = s->wayy[i];
} }
} }
} //}
} }
} }

233
rc.c
View File

@ -2979,80 +2979,46 @@ int movesprite(sprite_t *s) {
if (s->numwaypoints > 0) { if (s->numwaypoints > 0) {
sprite_t *s2; sprite_t *s2;
double oldx,oldy,xdiff,ydiff; double oldx,oldy,xdiff,ydiff;
double slowpoint;
slowpoint = ((double)TILEW*2.5); if (s->timer1 == 0) {
//slowpoint = (0.10 * s->dbltimer); // 10% of full distance oldx = s->x;
oldy = s->y;
oldx = s->x; // move torwaeds next waypoints
oldy = s->y;
// move torwaeds next waypoints
dstx = s->wayx[s->curwaypoint];
dsty = s->wayy[s->curwaypoint];
if (s->dbltimer == -1) { // haven't set full distance yet
s->dbltimer = getdistance(s->x,s->y,dstx,dsty);
if (s->dbltimer > slowpoint*2) {
s->timer1 = 0; // at top speed
} else {
s->timer1 = 1;
}
}
rv = moveto(s,dstx,dsty,s->speed,s->speed);
// remember how far we moved
xdiff = s->x - oldx;
ydiff = s->y - oldy;
// got there?
if (rv == 0) {
// go to next waypoint
s->curwaypoint++;
if (s->curwaypoint >= s->numwaypoints) {
s->curwaypoint = 0;
}
// recalc total distance
dstx = s->wayx[s->curwaypoint]; dstx = s->wayx[s->curwaypoint];
dsty = s->wayy[s->curwaypoint]; dsty = s->wayy[s->curwaypoint];
s->dbltimer = getdistance(s->x,s->y,dstx,dsty);
rv = moveto(s,dstx,dsty,s->speed,s->speed);
// remember how far we moved
xdiff = s->x - oldx;
ydiff = s->y - oldy;
// got there?
if (rv == 0) {
// pause
s->timer1 = PLATFORMPAUSE;
}
// move anything on top of us by the same amount
for (s2 = sprite ; s2 ; s2 = s2->next) {
if (s2->onplatform == s) {
s2->x += xdiff;
s2->y += ydiff;
}
}
} else { } else {
// adjust speed s->timer1--;
if (timer % PLATFORMDELAY == 0) { if (s->timer1 == 0) {
double maxspeed = getspeed(s); // go to next waypoint
s->curwaypoint++;
if ((rv <= slowpoint) && (s->timer1 <= 0)) { // getting close... if (s->curwaypoint >= s->numwaypoints) {
// slow down s->curwaypoint = 0;
s->timer1 = -1;
if (s->speed > PLATFORM_MINSPEED) {
s->speed -= PLATFORM_ACCEL;
if (s->speed < PLATFORM_MINSPEED) s->speed = PLATFORM_MINSPEED;
}
} else if (s->speed < maxspeed) {
// speed up
s->timer1 = 1; // speeding up
s->speed += PLATFORM_ACCEL;
if (s->speed > maxspeed) s->speed = maxspeed;
}
// reached top speed?
if (s->speed >= maxspeed) {
if (rv > slowpoint*2) {
s->timer1 = 0; // at top speed
}
} }
} }
} }
// move anything on top of us by the same amount
for (s2 = sprite ; s2 ; s2 = s2->next) {
if (s2->onplatform == s) {
s2->x += xdiff;
s2->y += ydiff;
}
}
} }
} else if (s->id == P_TICK) { } else if (s->id == P_TICK) {
@ -3275,6 +3241,140 @@ int movesprite(sprite_t *s) {
s->y += s->ys; s->y += s->ys;
s->dir = absxs; s->dir = absxs;
s->moved = MV_WALK; s->moved = MV_WALK;
} else if (s->id == P_FLY) { // fly - like bee but more erratic flight and can walk on ground if player far away
double absxs,absys;
double xmod,ymod;
if (s->flies) {
if ((s->xs == -99) || (s->ys == -99)) {
s->xs = getspeed(s);
s->ys = -getspeed(s);
}
if (s->xs > 0) absxs = 1;
else absxs = -1;
if (s->ys > 0) absys = 1;
else absys = -1;
/* this will fix the speed if ANGRY is set */
s->xs = absxs*getspeed(s);
s->ys = absys*getspeed(s);
if (s->flies == F_FLYVERT) {
ymod = sin(((double)timer * (double)3.6) * (M_PI/180));
//ymod *= 0.8;
if (s->ys * (ymod) > 0) absys = 1;
else absys = -1;
} else if (s->flies == F_FLYHORZ) {
xmod = sin(((double)timer * (double)3.6) * (M_PI/180));
if (s->xs * (xmod) > 0) absxs = 1;
else absxs = -1;
}
/* can we move? */
tt = gettileat(s->x + absxs*((s->img->w/2)+8), s->y-(s->img->h/2),NULL,NULL);
if ((tt->solid) || (tt->spikes )) {
/* turn */
s->xs = -s->xs;
}
tt = gettileat(s->x, s->y-(s->img->h/2) + absys*((s->img->h/2)+8),NULL,NULL);
if ((tt->solid) || (tt->spikes) || (tt->water)) {
/* turn */
s->ys = -s->ys;
}
/* move */
if (s->flies == F_FLYVERT) {
s->x += s->xs;
s->y += (s->ys * ymod);
} else {
s->x += (s->xs * xmod);
s->y += s->ys;
}
s->dir = absxs;
s->moved = MV_FLY;
// inc flying timer
s->timer1++;
if (s->timer1 >= FLY_FLYTIME) {
if (s->flies == F_FLYHORZ) {
s->flies = F_FLYVERT;
} else {
s->flies = F_WALK;
}
s->timer1 = 0;
}
} else { // walking - move like a rat
double myspeed = getspeed(s) * 0.75;
double playerdist;
if (!s->falling) {
int move = B_FALSE;
int xdiff, absxdiff;
tiletype_t *tunder;
/* distance to player */
xdiff = player->x - s->x;
if (xdiff < 0) absxdiff = -xdiff;
else absxdiff = xdiff;
// tile in front and below
tt = gettileat(s->x + s->dir*myspeed + (s->dir * (s->img->w/2)),s->y + (TILEH/2),NULL,NULL);
// tile below
tunder = gettileat(s->x ,s->y + 1,NULL,NULL);
/* if there's a hole in front of us and below*/
if (tt->solid == S_NOTSOLID) {
// we're on a slope
if (tunder->solid == S_SLOPE) {
move = B_TRUE;
}
} else {
move = B_TRUE;
}
/* either move or turn around */
if (move) {
rv = movex(s, s->dir*myspeed);
if (rv) {
/* if we couldn't move (hit a wall), turn */
s->dir = -s->dir;
}
} else {
s->dir = -s->dir;
}
s->moved = MV_WALK;
// take off if player is close
playerdist = getdistance(player->x,player->y,s->x,s->y);
if (playerdist <= (TILEW*10)) {
s->timer1 = 0;
s->flies = F_FLYHORZ;
s->xs = -99;
s->ys = -99;
}
// ...and take off eventually anyway
s->timer1++;
if (s->timer1 >= FLY_WALKTIME) {
s->timer1 = 0;
s->flies = F_FLYHORZ;
s->xs = -99;
s->ys = -99;
}
} else { // falling
tiletype_t *tunder, *t2under;
// tile below
tunder = gettileat(s->x ,s->y,NULL,NULL);
t2under = gettileat(s->x ,s->y+s->img->h,NULL,NULL);
if ((tunder->solid == S_SLOPE) || (t2under->solid == S_SLOPE)) {
movex(s, s->dir*myspeed);
}
}
}
} else if (s->id == P_FISH) { // very similar to bee } else if (s->id == P_FISH) { // very similar to bee
double absxs,absys; double absxs,absys;
if ((s->xs == -99) || (s->ys == -99)) { if ((s->xs == -99) || (s->ys == -99)) {
@ -4181,6 +4281,9 @@ double getspeed(sprite_t *s ) {
} else if (id == P_BEE) { } else if (id == P_BEE) {
if (s->angry) speed = 2; if (s->angry) speed = 2;
else speed = 1; else speed = 1;
} else if (id == P_FLY) {
if (s->angry) speed = 2.5;
else speed = 1.5;
} else if (id == P_SPIDER) { } else if (id == P_SPIDER) {
if (s->angry) speed = 2; if (s->angry) speed = 2;
else speed = 1.5; else speed = 1.5;

View File

@ -259,7 +259,14 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
// waypoints // waypoints
if (isplatform(monid)) { if (isplatform(monid)) {
level->initm[level->nummonsters].numwaypoints = 0;
// initial waypoint is start position
level->initm[level->nummonsters].wayx[0] = x*TILEW+(TILEW/2);
level->initm[level->nummonsters].wayy[0] = y*TILEH+(TILEH-2)+2;
level->initm[level->nummonsters].numwaypoints = 1;
// read waypoints // read waypoints
p = strtok(NULL, " "); p = strtok(NULL, " ");
while (p) { while (p) {
@ -725,6 +732,9 @@ void setdefaults(sprite_t *s) {
case P_SPIDER: case P_SPIDER:
s->flies = B_TRUE; s->flies = B_TRUE;
break; break;
case P_FLY:
s->flies = F_FLYVERT;
break;
default: default:
s->flies = B_FALSE; s->flies = B_FALSE;
break; break;
@ -1156,6 +1166,14 @@ int loadimagesets(void) {
/* next 3 are auto generated */ /* next 3 are auto generated */
imageset[P_BEE].numimages = 8; imageset[P_BEE].numimages = 8;
loadspriteimage(P_FLY,F_WALK1, "sprites/fly.png");
loadspriteimage(P_FLY,F_JUMP, "sprites/flywalk2.png");
loadspriteimage(P_FLY,F_FALL, "sprites/flyjump.png");
loadspriteimage(P_FLY,F_CAUGHT, "sprites/flycaught.png");
loadspriteimage(P_FLY,F_DEAD, "sprites/flydead.png");
/* next 3 are auto generated */
imageset[P_FLY].numimages = 8;
loadspriteimage(P_SPIDER,F_WALK1, "sprites/newspider.png"); loadspriteimage(P_SPIDER,F_WALK1, "sprites/newspider.png");
loadspriteimage(P_SPIDER,F_JUMP, "sprites/newspiderjump.png"); loadspriteimage(P_SPIDER,F_JUMP, "sprites/newspiderjump.png");
loadspriteimage(P_SPIDER,F_FALL, "sprites/newspiderfall.png"); loadspriteimage(P_SPIDER,F_FALL, "sprites/newspiderfall.png");
@ -1810,13 +1828,32 @@ void drawsprite(sprite_t *s) {
if ((s->id == P_SPIDER) && (s->ys != -99)) { if ((s->id == P_SPIDER) && (s->ys != -99)) {
frame = F_FALL; frame = F_FALL;
} else { } else {
// DEFAULT FOR EVERYTHING
// walking / sliding // walking / sliding
if (s->moved == MV_WALK) { if (s->moved == MV_WALK) {
// toggle between walking frames
if ((timer/12) % 2 == 0) { if ((timer/12) % 2 == 0) {
frame = F_WALK1; frame = F_WALK1;
} else { } else {
frame = F_JUMP; frame = F_JUMP;
} }
} else if (s->moved == MV_FLY) {
int animspeed;
// fly animates faster
if ((s->id == P_FLY) && (s->flies)) {
animspeed = 3;
} else {
animspeed = 12;
}
// toggle between flying frames
if ((timer/animspeed) % 2 == 0) {
frame = F_WALK1;
} else {
frame = F_FALL;
}
} else if (s->moved == MV_ICE) { } else if (s->moved == MV_ICE) {
frame = F_FALL; frame = F_FALL;
} else { } else {
@ -1857,6 +1894,7 @@ void drawsprite(sprite_t *s) {
// image based on timer1 // image based on timer1
s->img = imageset[s->timer1].img[F_WALK1]; s->img = imageset[s->timer1].img[F_WALK1];
} else if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) { } else if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) {
// ALL OTHERS:
// select image based on sprite id // select image based on sprite id
s->img = imageset[s->id].img[frame]; s->img = imageset[s->id].img[frame];
} }
@ -2613,6 +2651,7 @@ int ismonster(int id) {
switch (id) { switch (id) {
case P_RAT: case P_RAT:
case P_BEE: case P_BEE:
case P_FLY:
case P_SPIDER: case P_SPIDER:
case P_SNAKE: case P_SNAKE:
case P_TICK: case P_TICK:
@ -3050,6 +3089,7 @@ void setfruitinfo(void) {
setinfo(P_SPIDER, "Spider", "Spiders will lurk quietly on the ceiling, crawling back and forth. If they notice a player nearby however they will swiftly pounce down onto their prey!", "spider.png"); setinfo(P_SPIDER, "Spider", "Spiders will lurk quietly on the ceiling, crawling back and forth. If they notice a player nearby however they will swiftly pounce down onto their prey!", "spider.png");
setinfo(P_SNAKE, "Snake", "The snake moves in a similar fashion to the rat with one important exception - upon seeing a player they will spit a glob of deadly venom at them!", "snake.png"); setinfo(P_SNAKE, "Snake", "The snake moves in a similar fashion to the rat with one important exception - upon seeing a player they will spit a glob of deadly venom at them!", "snake.png");
setinfo(P_FLY, "Fly", "Annoying pests at the best of times, flies pose additional danger to dwarves. They fly around more erratically than bees and after landing can scurry quickly back and forth.", "fly.png");
setinfo(P_TICK, "Tick", "The tick is small but intelligent - even in its regular placid state it will move in the same manner as an angry rat. Because of their small size, they are also difficult to arget with a slam!", "tick.png"); setinfo(P_TICK, "Tick", "The tick is small but intelligent - even in its regular placid state it will move in the same manner as an angry rat. Because of their small size, they are also difficult to arget with a slam!", "tick.png");