From 9449332a9df64f7f2f0ce735b53c1c742c36ca89 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Wed, 19 Nov 2008 02:40:59 +0000 Subject: [PATCH] Added multicoloured score text --- rc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- rc.h | 2 ++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/rc.c b/rc.c index 874b8bb..32e6fad 100644 --- a/rc.c +++ b/rc.c @@ -156,6 +156,8 @@ SDL_Color orange = {255, 167, 88, 1}; SDL_Color black = {0, 0, 0, 0}; SDL_Color blue = {0, 0, 255, 0}; SDL_Color cyan = {0, 255, 255, 0}; +SDL_Color purple = {200, 0, 200, 0}; +SDL_Color brown = {166, 97, 7, 0}; SDL_Color white = {255, 255, 255, 0}; SDL_Color grey = {210, 210, 210, 0}; SDL_Color grey2 = {90, 90, 90, 0}; @@ -8027,6 +8029,7 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) { int gotscore = fruit->score; int modscore = gotscore; // default int i; + SDL_Color *col, *bgcol; /* kill the fruit */ fruit->dead = D_FINAL; @@ -8043,12 +8046,14 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) { /* handle fruit effects */ if (!dofruiteffect(giveto, fruit)) { playfx(FX_FRUIT); + col = getcolour(fruit->id); + bgcol = getbgcolour(fruit->id); if (multiplier <= 1) { sprintf(tempm, "%d", modscore); - addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS, tempm, &white,&black,POINTSDELAY,TT_NORM); + addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS, tempm, col,bgcol,POINTSDELAY,TT_NORM); } else { sprintf(tempm, "%d x %d" , modscore,multiplier); - addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS + 2*multiplier, tempm, &white,&black,POINTSDELAY,TT_NORM); + addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS + 2*multiplier, tempm, col,bgcol,POINTSDELAY,TT_NORM); } } } @@ -10924,3 +10929,43 @@ sprite_t *isplayerright(sprite_t *s) { return NULL; } + +SDL_Color *getcolour(int id) { + switch (id) { + case P_FLOWERYELLOW: + case P_GEMYELLOW: + case P_CHEESE: + case P_PIZZA: + return &yellow; + case P_FLOWERRED: + case P_GEMRED: + case P_CHIPS: + return &red; + case P_FLOWERPURPLE: + case P_GEMPURPLE: + return &purple; + case P_BURGER: + case P_SUNDAE: + case P_CHOCOLATE: + return &brown; + case P_DIAMOND: + return &cyan; + case P_CAKE: + return &blue; + case P_ICECREAM: + return &white; + } + + return &white; +} + +SDL_Color *getbgcolour (int id) { + switch (id) { + case P_PIZZA: + return &red2; + case P_CHIPS: + return &brown; + } + + return &black; +} diff --git a/rc.h b/rc.h index 127cfbf..8886f7b 100644 --- a/rc.h +++ b/rc.h @@ -118,3 +118,5 @@ int playersalive(void); sprite_t *isplayerbelow(sprite_t *s); sprite_t *isplayerabove(sprite_t *s); sprite_t *isplayerright(sprite_t *s); +SDL_Color *getcolour(int id); +SDL_Color *getbgcolour(int id);