Replaced graphic for platform

Tweaked platform acceleration and movement

Minor level modifications
This commit is contained in:
Rob Pearce 2008-11-08 21:14:10 +00:00
parent 02d2c2ef3b
commit 1bc25f661f
7 changed files with 87 additions and 11 deletions

View File

@ -45,3 +45,4 @@
405,level405.dat,Pitfalls 405,level405.dat,Pitfalls
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

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

7
defs.h
View File

@ -465,6 +465,12 @@
#define P_RANDOM 131 #define P_RANDOM 131
#define P_PLATFORM 132 #define P_PLATFORM 132
#define PLATFORMDELAY 4
#define PLATFORM_ACCEL 0.5 // how fast platforms accelerate/decellerate
#define PLATFORM_MINSPEED 0.3
#define PLATFORM_MAXSPEED 3
// cards // cards
#define CARDFONTX 4 #define CARDFONTX 4
#define CARDFONTY 6 #define CARDFONTY 6
@ -823,6 +829,7 @@ typedef struct sprite_s {
int timer3; // int timer3; //
int timer4; // int timer4; //
int watertimer; // int watertimer; //
double dbltimer;
int frame; int frame;

79
rc.c
View File

@ -2972,32 +2972,79 @@ int movesprite(sprite_t *s) {
} }
} else if (s->id == P_PLATFORM) { // moving platform } else if (s->id == P_PLATFORM) { // moving platform
// timer1 tells whether we are at top speed
double dstx,dsty; double dstx,dsty;
int rv; int rv;
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);
//slowpoint = (0.10 * s->dbltimer); // 10% of full distance
oldx = s->x; oldx = s->x;
oldy = s->y; oldy = s->y;
// move torwaeds next waypoints // move torwaeds next waypoints
dstx = s->wayx[s->curwaypoint]; dstx = s->wayx[s->curwaypoint];
dsty = s->wayy[s->curwaypoint]; dsty = s->wayy[s->curwaypoint];
rv = moveto(s,dstx,dsty,getspeed(s),getspeed(s));
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? // got there?
if (rv) { if (rv == 0) {
// go to next waypoint // go to next waypoint
s->curwaypoint++; s->curwaypoint++;
if (s->curwaypoint >= s->numwaypoints) { if (s->curwaypoint >= s->numwaypoints) {
s->curwaypoint = 0; s->curwaypoint = 0;
} }
// recalc total distance
dstx = s->wayx[s->curwaypoint];
dsty = s->wayy[s->curwaypoint];
s->dbltimer = getdistance(s->x,s->y,dstx,dsty);
} else {
// adjust speed
if (timer % PLATFORMDELAY == 0) {
double maxspeed = getspeed(s);
if ((rv <= slowpoint) && (s->timer1 <= 0)) { // getting close...
// slow down
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
}
}
}
} }
// remember how far we moved
xdiff = s->x - oldx;
ydiff = s->y - oldy;
// move anything on top of us by the same amount // move anything on top of us by the same amount
for (s2 = sprite ; s2 ; s2 = s2->next) { for (s2 = sprite ; s2 ; s2 = s2->next) {
@ -4140,7 +4187,7 @@ double getspeed(sprite_t *s ) {
} else if (id == P_KINGRAT) { } else if (id == P_KINGRAT) {
speed = 1.5; speed = 1.5;
} else if (id == P_PLATFORM) { } else if (id == P_PLATFORM) {
speed = 2; speed = PLATFORM_MAXSPEED;
} }
if (isinwater(s) && (s->id != P_FISH)) { if (isinwater(s) && (s->id != P_FISH)) {
@ -6365,15 +6412,17 @@ void channeldone(int channel) {
// move player towards new position // move player towards new position
// return true if we're there // return distance left
int moveto(sprite_t *p, int dstx, int dsty, double xspeed, double yspeed) { int moveto(sprite_t *p, int dstx, int dsty, double xspeed, double yspeed) {
double ang,xs,ys; double ang,xs,ys;
int distanceleft;
int therex = B_FALSE,therey = B_FALSE; int therex = B_FALSE,therey = B_FALSE;
// figure out angle to player // figure out angle to player
ang = atan2(dsty - p->y, dstx - p->x); ang = atan2(dsty - p->y, dstx - p->x);
xs = (cos(ang) * xspeed); xs = (cos(ang) * xspeed);
ys = (sin(ang) * yspeed); ys = (sin(ang) * yspeed);
if (p->x < dstx) { if (p->x < dstx) {
p->x += xs; p->x += xs;
if (p->x >= dstx) { if (p->x >= dstx) {
@ -6405,9 +6454,12 @@ int moveto(sprite_t *p, int dstx, int dsty, double xspeed, double yspeed) {
therey = B_TRUE; therey = B_TRUE;
} }
if (therex && therey) return B_TRUE; // figure out distance to target
distanceleft = getdistance(p->x,p->y,dstx,dsty);
return B_FALSE; if (therex && therey) return 0;
return distanceleft;
} }
// grabs area behind a sprite into a temp buffer // grabs area behind a sprite into a temp buffer
@ -9478,3 +9530,12 @@ int easymode(void) {
return B_FALSE; return B_FALSE;
} }
double getdistance(double x1, double y1, double x2, double y2) {
double xdis,ydis;
xdis = abs(x1 - x2);
ydis = abs(y1 - y2);
if ((xdis == 0) && (ydis == 0)) {
return 0;
} else return sqrt((xdis*xdis) + (ydis*ydis));
}

1
rc.h
View File

@ -108,3 +108,4 @@ int easymode(void);
int uncaughtmonsters(void); int uncaughtmonsters(void);
void swimup(sprite_t *pl); void swimup(sprite_t *pl);
void swimdown(sprite_t *pl); void swimdown(sprite_t *pl);
double getdistance(double x1, double y1, double x2, double y2);

View File

@ -612,7 +612,12 @@ void setdefaults(sprite_t *s) {
s->armour = B_FALSE; s->armour = B_FALSE;
} }
} else { } else {
s->speed = 1; if (s->id == P_PLATFORM) {
s->speed = PLATFORM_MAXSPEED;
} else {
s->speed = 1;
}
s->armour = B_FALSE; s->armour = B_FALSE;
s->netsticky = B_FALSE; s->netsticky = B_FALSE;
s->doublejump = B_FALSE; s->doublejump = B_FALSE;
@ -654,6 +659,7 @@ void setdefaults(sprite_t *s) {
s->timer2 = 0; s->timer2 = 0;
s->timer3 = 0; s->timer3 = 0;
s->timer4 = 0; s->timer4 = 0;
s->dbltimer = -1;
s->dropping = 0; s->dropping = 0;
s->dropx = -1; s->dropx = -1;
s->dropy = -1; s->dropy = -1;