[Xmltools-development] xmltools2/xmltools/tests graphics.c
Status: Beta
Brought to you by:
nik_89
|
From: um, r. <sm...@us...> - 2004-11-14 14:49:58
|
Update of /cvsroot/xmltools/xmltools2/xmltools/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9261 Modified Files: graphics.c Log Message: returned graphics.c back to it's passive state. it shouldn't have to call other modules to find out what to draw and how. Index: graphics.c =================================================================== RCS file: /cvsroot/xmltools/xmltools2/xmltools/tests/graphics.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** graphics.c 12 Nov 2004 02:26:34 -0000 1.10 --- graphics.c 14 Nov 2004 14:49:50 -0000 1.11 *************** *** 16,20 **** static SDL_Surface *cars = NULL; ! static void drawpixel(int x, int y, int color); /* methods */ --- 16,20 ---- static SDL_Surface *cars = NULL; ! static void draw_pixel(int x, int y, int color); /* methods */ *************** *** 41,45 **** ypos += (y * TILE_HEIGHT) + extra_y; ! drawpixel(xpos, ypos, 0); angle++; } --- 41,45 ---- ypos += (y * TILE_HEIGHT) + extra_y; ! draw_pixel(xpos, ypos, 0); angle++; } *************** *** 63,67 **** ypos += (y * TILE_HEIGHT) + extra_y; ! drawpixel(xpos, ypos, 0); angle++; } --- 63,67 ---- ypos += (y * TILE_HEIGHT) + extra_y; ! draw_pixel(xpos, ypos, 0); angle++; } *************** *** 85,89 **** ypos += (y * TILE_HEIGHT) + extra_y; ! drawpixel(xpos, ypos, 0); angle++; } --- 85,89 ---- ypos += (y * TILE_HEIGHT) + extra_y; ! draw_pixel(xpos, ypos, 0); angle++; } *************** *** 107,111 **** ypos += (y * TILE_HEIGHT) + extra_y; ! drawpixel(xpos, ypos, 0); angle++; } --- 107,111 ---- ypos += (y * TILE_HEIGHT) + extra_y; ! draw_pixel(xpos, ypos, 0); angle++; } *************** *** 115,123 **** } - int Graphics_SetCarColor(int R, int G, int B) - { - return SDL_MapRGB(screen->format, R, G, B); - } - void Graphics_DrawTile(int x, int y, int index) { --- 115,118 ---- *************** *** 140,167 **** } ! void Graphics_DrawCar(int x, int y, int car, int rotation, int color) { ! #if CARS_GFX ! CARS_DATA *buf = Cars_GetCarData(car); ! if (buf->offtrack == 2) ! { ! /* we make the car be semi apparent */ ! /* printf("car is coming back from a spinoff (spam)\n"); */ ! SDL_SetAlpha(cars, SDL_SRCALPHA, 100); ! } ! SDL_Rect rec1 = {rotation * CARS_GFX_OFFSETX, color * CARS_GFX_OFFSETX, CARS_GFX_OFFSETX, CARS_GFX_OFFSETY }; ! SDL_Rect rec2 = { x, y, CARS_GFX_OFFSETX, CARS_GFX_OFFSETY}; ! SDL_BlitSurface(cars, &rec1, screen, &rec2); ! if (buf->offtrack == 2) { ! /* we bring back the cars as opaque */ ! ! SDL_SetAlpha(cars, 0, SDL_ALPHA_OPAQUE); ! } ! #else ! drawpixel(x, y, color); #endif - return; } --- 135,169 ---- } ! void Graphics_DrawCar(int x, int y, int player, int rotation, ! int transparent) { ! #ifdef DRAW_CARS_AS_PIXELS ! if (player) ! draw_pixel(x, y, SDL_MapRGB(screen->format, 255, 0, 0)); ! else ! draw_pixel(x, y, SDL_MapRGB(screen->format, 0, 0, 255)); ! #else ! SDL_Rect src, dest; ! ! if (screen && cars) { ! src.w = cars->w / CARS_TILES_WIDE; ! src.h = cars->h / CARS_TILES_HIGH; ! src.x = rotation * src.w; ! src.y = player * src.h; ! if (transparent) ! SDL_SetAlpha(cars, SDL_SRCALPHA, 192); ! else ! SDL_SetAlpha(cars, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); ! ! /* draw centered. fx: (x, y) is the mid point of the car, in ! * this program most likely between the front wheels */ ! /* fixme: go into cars.c and fix the offsets so this works */ ! dest.x = x; // - src.w / 2; ! dest.y = y; // - src.h / 2; ! SDL_BlitSurface(cars, &src, screen, &dest); ! } #endif } *************** *** 209,213 **** /* local */ ! static void drawpixel(int x, int y, int color) { SDL_LockSurface(screen); --- 211,215 ---- /* local */ ! static void draw_pixel(int x, int y, int color) { SDL_LockSurface(screen); |