author | ecalot
<ecalot> 2005-02-22 03:11:59 UTC |
committer | ecalot
<ecalot> 2005-02-22 03:11:59 UTC |
parent | 10427ca9559fd496f822c398b04f062fe25133ba |
FP/src/include/output.h | +1 | -0 |
FP/src/ker/kid.c | +2 | -0 |
FP/src/out/output.c | +38 | -1 |
diff --git a/FP/src/include/output.h b/FP/src/include/output.h index 175d00e..5d5f43c 100644 --- a/FP/src/include/output.h +++ b/FP/src/include/output.h @@ -103,6 +103,7 @@ int outputGetHeight(void* image); int outputGetWidth(void* image); void outputRaiseBitmap(void* image, int h); +void outputBlinkScreen (int times, int color); #endif diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index 8f4e082..2114de0 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -78,8 +78,10 @@ int kidDrinkPotion(tObject* kid,tTile tile) { if (isIn(tile,TILE_SWORD)) { } else if (isIn(tile,TILES_HITPOINT)) { kidGetHitPoint(kid); + outputBlinkScreen(3,1); } else if (isIn(tile,TILES_LIFE)) { kidGetLife(kid); + outputBlinkScreen(3,1); } else if (isIn(tile,TILES_POISON)) { return kidTakeHitPoint(kid); } diff --git a/FP/src/out/output.c b/FP/src/out/output.c index 43dca56..de3fcd9 100644 --- a/FP/src/out/output.c +++ b/FP/src/out/output.c @@ -55,6 +55,11 @@ typedef struct { SDL_Surface* surface; } tSurface; +typedef struct { + int frame; + SDL_Color color; +} tBlink; + /* Main screen object */ static SDL_Surface* screen; @@ -107,6 +112,33 @@ void initText () font_init = 1; } +static tBlink blinkState; + +void outputBlinkScreen (int times, int color) { + register int r,g,b; + switch (color) { + case 1: + r=63; + g=b=0; + break; + case 2: + g=63; + r=b=0; + break; + case 3: + r=g=b=63; + break; + default: + case 0: + r=g=b=0; + break; + } + blinkState.frame=times<<1; + blinkState.color.r=r<<2; + blinkState.color.g=g<<2; + blinkState.color.b=b<<2; +} + unsigned int outputGetTextWidth (const char *txt) { const unsigned char *s; @@ -341,7 +373,12 @@ void outputRaiseBitmap(void* image, int h) { void outputClearScreen() { - SDL_FillRect(screen, NULL, 0); + if (blinkState.frame) blinkState.frame--; + if ((blinkState.frame%2)) { + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,blinkState.color.r,blinkState.color.g,blinkState.color.b)); + } else { + SDL_FillRect(screen, NULL, 0); + } } void outputUpdateScreen()