[Xmltools-development] xmltools2/xmltools/tests cars.c cars.h
Status: Beta
Brought to you by:
nik_89
|
From: nik_89 <ni...@us...> - 2004-11-11 23:17:42
|
Update of /cvsroot/xmltools/xmltools2/xmltools/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13103 Modified Files: cars.c cars.h Log Message: fixed the spinning off. only thing to do with it is make it transparent when its coming back. Index: cars.h =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/cars.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** cars.h 23 Oct 2004 03:31:38 -0000 1.12 --- cars.h 11 Nov 2004 23:17:33 -0000 1.13 *************** *** 60,63 **** --- 60,64 ---- int lastxpos, lastypos; /* used when spinned off */ int xspeed, yspeed; /* used when spinned off */ + int lastrotation; /* used when spinned off */ double speed; unsigned short angle; Index: cars.c =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/cars.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** cars.c 11 Nov 2004 22:26:56 -0000 1.19 --- cars.c 11 Nov 2004 23:17:33 -0000 1.20 *************** *** 44,48 **** } car[cnum]->speed -= CARS_SPINOFF_BRAKE_OFFSET; ! if (car[cnum]->rotation < 16) car[cnum]->rotation += 1; else --- 44,48 ---- } car[cnum]->speed -= CARS_SPINOFF_BRAKE_OFFSET; ! if (car[cnum]->rotation < 15) car[cnum]->rotation += 1; else *************** *** 52,69 **** { if (car[cnum]->offtrack == 1) car[cnum]->offtrack = 2; /* the replacing part */ int a = abs(car[cnum]->speed / CARS_SPEED_OFFSET); while (a--) ! if (car[cnum]->ypos < YRES - 20) /* to counter off screen gaps */ { ! car[cnum]->xpos -= car[cnum]->xspeed; ! car[cnum]->ypos -= car[cnum]->yspeed; ! if (car[cnum]->xpos == (car[cnum]->lastxpos * car[cnum]->yspeed) ! && car[cnum]->ypos == (car[cnum]->lastypos * car[cnum]->xspeed)) { printf("car back on track\n"); car[cnum]->speed = 0; car[cnum]->offtrack = 0; ! break; } --- 52,77 ---- { if (car[cnum]->offtrack == 1) + { + printf("curx %d cury %d\nlastx %d lasty %d\nxspin %d yspin %d\n", car[cnum]->xpos, car[cnum]->ypos, car[cnum]->lastxpos, car[cnum]->lastypos, car[cnum]->xspeed, car[cnum]->yspeed); car[cnum]->offtrack = 2; /* the replacing part */ + car[cnum]->rotation = car[cnum]->lastrotation; + } int a = abs(car[cnum]->speed / CARS_SPEED_OFFSET); + while (a--) ! if (car[cnum]->ypos < YRES - 19) /* to counter screen gaps */ { ! /* printf("curx %d cury %d\n", car[cnum]->xpos, car[cnum]->ypos); */ ! car[cnum]->xpos += (car[cnum]->xspeed * -1); ! car[cnum]->ypos += (car[cnum]->yspeed * -1); ! if (car[cnum]->xpos == car[cnum]->lastxpos ! || car[cnum]->ypos == car[cnum]->lastypos) { printf("car back on track\n"); + car[cnum]->xpos = car[cnum]->lastxpos; + car[cnum]->ypos = car[cnum]->lastypos; car[cnum]->speed = 0; car[cnum]->offtrack = 0; ! return; } *************** *** 139,142 **** --- 147,151 ---- car[cnum]->lastxpos = car[cnum]->xpos; car[cnum]->lastypos = car[cnum]->ypos; + car[cnum]->lastrotation = car[cnum]->rotation; } car[cnum]->speed -= abs(car[cnum]->speed / 40); *************** *** 223,226 **** --- 232,236 ---- car[cnum]->lastxpos = car[cnum]->xpos; car[cnum]->lastypos = car[cnum]->ypos; + car[cnum]->lastrotation = car[cnum]->rotation; } #endif |