From 1bc25f661f8785460d3e94e88bbd80b76461383d Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Sat, 8 Nov 2008 21:14:10 +0000 Subject: [PATCH] Replaced graphic for platform Tweaked platform acceleration and movement Minor level modifications --- data/levels.dat | 1 + data/sprites/platform.png | Bin 2293 -> 2321 bytes data/world1/level42.dat | 2 +- defs.h | 7 ++++ rc.c | 79 +++++++++++++++++++++++++++++++++----- rc.h | 1 + shared.c | 8 +++- 7 files changed, 87 insertions(+), 11 deletions(-) diff --git a/data/levels.dat b/data/levels.dat index d59c117..18b57da 100644 --- a/data/levels.dat +++ b/data/levels.dat @@ -45,3 +45,4 @@ 405,level405.dat,Pitfalls 109,level109.dat,THE END SO FAR 99,level99.dat,TEST LEVEL +406,level406.dat,NEW LEVEL diff --git a/data/sprites/platform.png b/data/sprites/platform.png index 9ac64ae17291498fa18074c0d0b4460066e8e515..af4aed4d5d1bd424d8ce8bd20ff837afcd411315 100644 GIT binary patch delta 2284 zcmV`6L_t(Y$CZ^?Y*g17$A7ckJNEUR84oja$Kz!dyniK)Q!FrzAtVSDvh;yS zrHV+>O5GQ!YWmPcd8(9`wy*6=RaI(48zNN-T__0@;@_v!n-W8$8MK0jzVapJ@e2L=Yd9}EV24Z}dwG~MBFh$|~A zD2hTNk%*_$>3@nONt2Q!4d1+Zv(xAEVK$qQWtqtC-E-wqX{%f=ccfA&*W&UbCaVdP z$&BCcr>UulVzIa>3C)*8QEUr^LUKz>%cF~ni{+J-m8#e4bqaz&JRUE$x3`al!r_h< zNqSt@btWbzP78uCP^nZla+&NeFJ8ECVRZaz)w&Jv(tk@Y{bp!r=$ng+i-KVogu`JB z!w?IF0>NMqUDpA+91aJyTCM-uwQF>DcXR93EjBhbc=_d*IrH}0eThT@m&-*mndElt z4*J#>M~)of{JR$sMUmsjkGopzO)unfIf}(1u~>|$sVT{7wIT=tGcz-Eb#=+1Q0V!~ zV`F488Gj^6Vq;_D~aq{^*@pv3bk_d%DIGs+C z$t2O)C|^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xE@^cf z&Q8d8hIL_4t$UaToE~B-E3CVt3ETYf_kW1^r$0MpH0tohZU8bw1|E%R2>g)HWq6)u zG(JN4KIQs`MuH5xgi#NhEeXwvRwoACqS)nxogsu^o0`@16`k=L-~`sB6xou-8nQH{ zTu(7ZQl)chT7M{C5%@LjP6w$4+K-X0#55VEE^)d~k%i!L7{NXQt$&3H~lz(D#$Kv`WqPkhZSKj;5*FE0?2bL_8w z#jBBr8}37y;|~u|Nq|-gUwdpaOX0;-nRMpRH7=Wx^q*2C zBgPM(;7P2*nF?Fw>=w5yw=id == P_PLATFORM) { // moving platform + // timer1 tells whether we are at top speed double dstx,dsty; int rv; if (s->numwaypoints > 0) { sprite_t *s2; double oldx,oldy,xdiff,ydiff; + double slowpoint; + + slowpoint = ((double)TILEW*2.5); + //slowpoint = (0.10 * s->dbltimer); // 10% of full distance oldx = s->x; oldy = s->y; // move torwaeds next waypoints + + dstx = s->wayx[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? - if (rv) { + 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]; + 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 for (s2 = sprite ; s2 ; s2 = s2->next) { @@ -4140,7 +4187,7 @@ double getspeed(sprite_t *s ) { } else if (id == P_KINGRAT) { speed = 1.5; } else if (id == P_PLATFORM) { - speed = 2; + speed = PLATFORM_MAXSPEED; } if (isinwater(s) && (s->id != P_FISH)) { @@ -6365,15 +6412,17 @@ void channeldone(int channel) { // 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) { double ang,xs,ys; + int distanceleft; int therex = B_FALSE,therey = B_FALSE; // figure out angle to player ang = atan2(dsty - p->y, dstx - p->x); xs = (cos(ang) * xspeed); ys = (sin(ang) * yspeed); + if (p->x < dstx) { p->x += xs; if (p->x >= dstx) { @@ -6405,9 +6454,12 @@ int moveto(sprite_t *p, int dstx, int dsty, double xspeed, double yspeed) { 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 @@ -9478,3 +9530,12 @@ int easymode(void) { 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)); +} diff --git a/rc.h b/rc.h index b7de957..7fd3005 100644 --- a/rc.h +++ b/rc.h @@ -108,3 +108,4 @@ int easymode(void); int uncaughtmonsters(void); void swimup(sprite_t *pl); void swimdown(sprite_t *pl); +double getdistance(double x1, double y1, double x2, double y2); diff --git a/shared.c b/shared.c index dc80598..4f50d14 100644 --- a/shared.c +++ b/shared.c @@ -612,7 +612,12 @@ void setdefaults(sprite_t *s) { s->armour = B_FALSE; } } else { - s->speed = 1; + if (s->id == P_PLATFORM) { + s->speed = PLATFORM_MAXSPEED; + } else { + s->speed = 1; + } + s->armour = B_FALSE; s->netsticky = B_FALSE; s->doublejump = B_FALSE; @@ -654,6 +659,7 @@ void setdefaults(sprite_t *s) { s->timer2 = 0; s->timer3 = 0; s->timer4 = 0; + s->dbltimer = -1; s->dropping = 0; s->dropx = -1; s->dropy = -1;