[Xmltools-development] xmltools2/xmltools/tests cars.c cars.h events.c
Status: Beta
Brought to you by:
nik_89
|
From: um, r. <sm...@us...> - 2004-11-14 14:48:27
|
Update of /cvsroot/xmltools/xmltools2/xmltools/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8365 Modified Files: cars.c cars.h events.c Log Message: cars.c changed cars to mycars. no longer dynamically allocated changed num/cnum parameters to a pointer to the car to be worked on removed get/set car, bad way of doing things added plunger up/down to replace what get/set car was being used for removed some unused variables cleaned up the code a bit (i found several 'blank lines' with loads of tabs in them) cars.h commented out some unused variables added prototypes for plunger up/down removed prototypes for get/set car events.c made the changes for the set/get plunger up/down stuff Index: cars.h =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/cars.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** cars.h 14 Nov 2004 00:44:12 -0000 1.14 --- cars.h 14 Nov 2004 14:48:19 -0000 1.15 *************** *** 8,15 **** #define __CARS_H ! /* if set to 0, the cars will be dots instead of ! * images ! */ ! #define CARS_GFX 1 /* to fix the cars positionning on the track */ #define CARS_GFX_FIX_X 8 --- 8,16 ---- #define __CARS_H ! #define NUM_PLAYERS 2 ! ! /* the cars will be dots instead of images */ ! /* #define DRAW_CARS_AS_PIXELS */ ! /* to fix the cars positionning on the track */ #define CARS_GFX_FIX_X 8 *************** *** 17,51 **** #define CARS_GFX_ANGLE_OFFSET 22.5; ! /* normal value = 3 ! * ! * The higher this value, the slower the cars ! * will go ! * ! */ #define CARS_SPEED_OFFSET 4 ! /* normal value = 2 ! * ! * the higher this value, the faster the cars ! * will brake ! * ! */ #define CARS_BRAKE_OFFSET 1 ! /* normal value = 46 ! * ! * the higher this value, the less likely to spin * off (min = 0(instant spin off), max = 50) ! * ! */ #define CARS_SPINOFF_OFFSET 46 - /* normal value = 2 - * - * the lower this value, the longer the spinoff * will last. - */ - #define CARS_SPINOFF_BRAKE_OFFSET 2 ! /* Start coordinates coding */ ! #define CARS_START_X car[num]->xpos = (TRACK_XOFFSET + (car[num]->current.x * TILE_WIDTH) + TILE_WIDTH / 2) ! #define CARS_START_Y car[num]->ypos = (TRACK_YOFFSET + (car[num]->current.y * TILE_HEIGHT) + (car[num]->lane ? OFFSET_RAIL2 : OFFSET_RAIL1)) ! /* Cars gfx Offsets */ #define CARS_GFX_OFFSETX 28 #define CARS_GFX_OFFSETY 28 --- 18,38 ---- #define CARS_GFX_ANGLE_OFFSET 22.5; ! /* def: 3 ! * the higher this value, the slower the cars will go */ #define CARS_SPEED_OFFSET 4 ! ! /* def: 2 ! * the higher this value, the faster the cars will brake */ #define CARS_BRAKE_OFFSET 1 ! ! /* def: 46 min: 0 max: 50 ! * the higher this value, the less likely to spin off, 0 for instant spin off */ #define CARS_SPINOFF_OFFSET 46 ! /* def: 2 ! * the lower this value, the longer the spinoff will last */ ! #define CARS_SPINOFF_BRAKE_OFFSET 2 ! /* cars gfx offsets */ #define CARS_GFX_OFFSETX 28 #define CARS_GFX_OFFSETY 28 *************** *** 53,67 **** #define CARS_GFX_TOTALY 56 ! /* the counter clockwise * track turn starting angle offset ! * default is 8 and is jerky ! * 15 is jerky on top left and top right ! */ #define CARS_CCTURNSTART_OFFSET 15 ! /* the clockwise ! * track turn starting angle offset ! * default is 8 ! */ #define CARS_CTURNSTART_OFFSET 8 --- 40,53 ---- #define CARS_GFX_TOTALY 56 ! /* def: 8 ! * the counter clockwise * track turn starting angle offset ! * the default (8) is jerky ! * 15 is jerky on top left and top right */ #define CARS_CCTURNSTART_OFFSET 15 ! /* def: 8 ! * the clockwise ! * track turn starting angle offset */ #define CARS_CTURNSTART_OFFSET 8 *************** *** 76,80 **** unsigned short angle; unsigned short rotation; ! unsigned int color; unsigned short lap; int direction; --- 62,66 ---- unsigned short angle; unsigned short rotation; ! //unsigned int color; unsigned short lap; int direction; *************** *** 89,98 **** unsigned char racing; unsigned char offtrack; ! unsigned char visible; ! } CARS_DATA; enum { ! CARS_UP, /* 0 */ CARS_RIGHT, CARS_DOWN, --- 75,84 ---- unsigned char racing; unsigned char offtrack; ! //unsigned char visible; ! } CAR_DATA; enum { ! CARS_UP = 0, CARS_RIGHT, CARS_DOWN, *************** *** 100,118 **** }; - extern int Cars_Move(int num); - extern int Cars_Poll(); - extern void Cars_Draw(); - extern CARS_DATA *Cars_GetCarData(int num); ! extern void Cars_SetCarData(int num, CARS_DATA *buf); extern int Cars_Init(void); extern int Cars_Cleanup(void); - extern const float xtable[361]; - extern const float ytable[361]; - #endif --- 86,104 ---- }; + extern const float xtable[361]; + extern const float ytable[361]; ! extern void Cars_PlungerDown(int carid); ! extern void Cars_PlungerUp(int carid); + extern void Cars_Move(CAR_DATA *car); + extern int Cars_Poll(void); + extern void Cars_Draw(void); extern int Cars_Init(void); extern int Cars_Cleanup(void); #endif + Index: events.c =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/events.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** events.c 20 Oct 2004 00:24:57 -0000 1.9 --- events.c 14 Nov 2004 14:48:19 -0000 1.10 *************** *** 31,34 **** --- 31,39 ---- break; + case SDLK_3: + if (Track_IsValid()) + state = STATE_RACING; + break; + case SDLK_ESCAPE: quit = 1; *************** *** 36,52 **** case SDLK_d: ! { ! CARS_DATA *buf = Cars_GetCarData(1); ! buf->plunger = 1; ! Cars_SetCarData(1, (CARS_DATA*)buf); ! } break; case SDLK_k: ! { ! CARS_DATA *buf = Cars_GetCarData(2); ! buf->plunger = 1; ! Cars_SetCarData(2, (CARS_DATA*)buf); ! } break; --- 41,49 ---- case SDLK_d: ! Cars_PlungerDown(0); break; case SDLK_k: ! Cars_PlungerDown(1); break; *************** *** 65,81 **** { case SDLK_d: ! { ! CARS_DATA *buf = Cars_GetCarData(1); ! buf->plunger = 0; ! Cars_SetCarData(1, (CARS_DATA*)buf); ! } break; case SDLK_k: ! { ! CARS_DATA *buf = Cars_GetCarData(2); ! buf->plunger = 0; ! Cars_SetCarData(2, (CARS_DATA*)buf); ! } break; --- 62,70 ---- { case SDLK_d: ! Cars_PlungerUp(0); break; case SDLK_k: ! Cars_PlungerUp(1); break; Index: cars.c =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/cars.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** cars.c 14 Nov 2004 00:44:12 -0000 1.22 --- cars.c 14 Nov 2004 14:48:19 -0000 1.23 *************** *** 12,237 **** #include "table.inc" ! #define debug 0 #define set_clockwise_offtrack 1 ! static int cars_movetrack(int cnum); ! static void cars_turn_cc(int cnum, int from_angle, ! int to_angle, int extra_x, int extra_y, int extra_fix); ! static void cars_turn_c(int cnum, int from_angle, [...1213 lines suppressed...] ! set_cartwo(); return 0; } --- 598,603 ---- int Cars_Init() { ! init_car(&mycars[0], 0); ! init_car(&mycars[1], 1); return 0; } *************** *** 662,668 **** int Cars_Cleanup() { - free(car); return 0; } - --- 605,609 ---- |