mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Fix colors updating too fast in TITLEMODE/MAPMODE/GAMECOMPLETEMODE
These colors were of the colors of each crewmate, the inactive crewmate color, and the color of the trinket and clock on the quicksave/summary screens. These colors all used fRandom() and so kept updating too quickly because they would be recalculated every time the delta-timestep render function got called, which isn't ideal. Thus, I've had to add attributes onto the Graphics class to store these colors and make sure they're only recalculated in logic functions instead. Thankfully, the color used for the sprites on the time trial results screen doesn't use fRandom(), so I don't have to worry about those. There's a new version of Graphics::drawsprite() that takes in a pre-made color already, instead of a color ID. As well, I've also added Graphics::updatetitlecolours() to update these colors on the title screen.
This commit is contained in:
parent
3699adec82
commit
11803b0229
4 changed files with 122 additions and 43 deletions
|
@ -124,6 +124,19 @@ void Graphics::init()
|
|||
|
||||
screenshake_x = 0;
|
||||
screenshake_y = 0;
|
||||
|
||||
col_crewred = 0x00000000;
|
||||
col_crewyellow = 0x00000000;
|
||||
col_crewgreen = 0x00000000;
|
||||
col_crewcyan = 0x00000000;
|
||||
col_crewblue = 0x00000000;
|
||||
col_crewpurple = 0x00000000;
|
||||
col_crewinactive = 0x00000000;
|
||||
col_clock = 0x00000000;
|
||||
col_trinket = 0x00000000;
|
||||
col_tr = 0;
|
||||
col_tg = 0;
|
||||
col_tb = 0;
|
||||
}
|
||||
|
||||
int Graphics::font_idx(uint32_t ch) {
|
||||
|
@ -160,6 +173,29 @@ void Graphics::drawspritesetcol(int x, int y, int t, int c)
|
|||
BlitSurfaceColoured(sprites[t],NULL,backBuffer, &rect, ct);
|
||||
}
|
||||
|
||||
void Graphics::updatetitlecolours()
|
||||
{
|
||||
setcol(15);
|
||||
col_crewred = ct.colour;
|
||||
setcol(14);
|
||||
col_crewyellow = ct.colour;
|
||||
setcol(13);
|
||||
col_crewgreen = ct.colour;
|
||||
setcol(0);
|
||||
col_crewcyan = ct.colour;
|
||||
setcol(16);
|
||||
col_crewblue = ct.colour;
|
||||
setcol(20);
|
||||
col_crewpurple = ct.colour;
|
||||
setcol(19);
|
||||
col_crewinactive = ct.colour;
|
||||
|
||||
setcol(18);
|
||||
col_clock = ct.colour;
|
||||
setcol(18);
|
||||
col_trinket = ct.colour;
|
||||
}
|
||||
|
||||
void Graphics::Makebfont()
|
||||
{
|
||||
for (int j = 0; j < (grphx.im_bfont->h / 8); j++)
|
||||
|
@ -540,6 +576,13 @@ void Graphics::drawsprite( int x, int y, int t, int r, int g, int b )
|
|||
BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct);
|
||||
}
|
||||
|
||||
void Graphics::drawsprite(int x, int y, int t, Uint32 c)
|
||||
{
|
||||
SDL_Rect rect = { Sint16(x), Sint16(y), sprites_rect.w, sprites_rect.h };
|
||||
setcolreal(c);
|
||||
BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct);
|
||||
}
|
||||
|
||||
void Graphics::drawtile( int x, int y, int t )
|
||||
{
|
||||
if (!INBOUNDS(t, tiles))
|
||||
|
@ -890,22 +933,22 @@ void Graphics::drawcrewman( int x, int y, int t, bool act, bool noshift /*=false
|
|||
{
|
||||
if (flipmode)
|
||||
{
|
||||
drawspritesetcol(x, y, 14, 19);
|
||||
drawsprite(x, y, 14, col_crewinactive);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawspritesetcol(x, y, 12, 19);
|
||||
drawsprite(x, y, 12, col_crewinactive);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flipmode)
|
||||
{
|
||||
drawspritesetcol(x - 8, y, 14, 19);
|
||||
drawsprite(x - 8, y, 14, col_crewinactive);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawspritesetcol(x - 8, y, 12, 19);
|
||||
drawsprite(x - 8, y, 12, col_crewinactive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -916,22 +959,22 @@ void Graphics::drawcrewman( int x, int y, int t, bool act, bool noshift /*=false
|
|||
switch(t)
|
||||
{
|
||||
case 0:
|
||||
drawspritesetcol(x, y, crewframe, 0);
|
||||
drawsprite(x, y, crewframe, col_crewcyan);
|
||||
break;
|
||||
case 1:
|
||||
drawspritesetcol(x, y, crewframe, 20);
|
||||
drawsprite(x, y, crewframe, col_crewpurple);
|
||||
break;
|
||||
case 2:
|
||||
drawspritesetcol(x, y, crewframe, 14);
|
||||
drawsprite(x, y, crewframe, col_crewyellow);
|
||||
break;
|
||||
case 3:
|
||||
drawspritesetcol(x, y, crewframe, 15);
|
||||
drawsprite(x, y, crewframe, col_crewred);
|
||||
break;
|
||||
case 4:
|
||||
drawspritesetcol(x, y, crewframe, 13);
|
||||
drawsprite(x, y, crewframe, col_crewgreen);
|
||||
break;
|
||||
case 5:
|
||||
drawspritesetcol(x, y, crewframe, 16);
|
||||
drawsprite(x, y, crewframe, col_crewblue);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
void drawgui();
|
||||
|
||||
void drawsprite(int x, int y, int t, int r, int g, int b);
|
||||
void drawsprite(int x, int y, int t, Uint32 c);
|
||||
|
||||
void printcrewname(int x, int y, int t);
|
||||
|
||||
|
@ -305,6 +306,20 @@ public:
|
|||
return v0 + alpha * (v1 - v0);
|
||||
}
|
||||
float alpha;
|
||||
|
||||
Uint32 col_crewred;
|
||||
Uint32 col_crewyellow;
|
||||
Uint32 col_crewgreen;
|
||||
Uint32 col_crewcyan;
|
||||
Uint32 col_crewblue;
|
||||
Uint32 col_crewpurple; //actually pink
|
||||
Uint32 col_crewinactive;
|
||||
Uint32 col_clock;
|
||||
Uint32 col_trinket;
|
||||
int col_tr;
|
||||
int col_tg;
|
||||
int col_tb;
|
||||
void updatetitlecolours();
|
||||
};
|
||||
|
||||
extern Graphics graphics;
|
||||
|
|
|
@ -17,6 +17,27 @@ void titlelogic()
|
|||
graphics.updatetowerbackground();
|
||||
}
|
||||
|
||||
if (!game.menustart)
|
||||
{
|
||||
graphics.col_tr = (int)(164 - (help.glow / 2) - int(fRandom() * 4));
|
||||
graphics.col_tg = 164 - (help.glow / 2) - int(fRandom() * 4);
|
||||
graphics.col_tb = 164 - (help.glow / 2) - int(fRandom() * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.col_tr = map.r - (help.glow / 4) - int(fRandom() * 4);
|
||||
graphics.col_tg = map.g - (help.glow / 4) - int(fRandom() * 4);
|
||||
graphics.col_tb = map.b - (help.glow / 4) - int(fRandom() * 4);
|
||||
if (graphics.col_tr < 0) graphics.col_tr = 0;
|
||||
if(graphics.col_tr>255) graphics.col_tr=255;
|
||||
if (graphics.col_tg < 0) graphics.col_tg = 0;
|
||||
if(graphics.col_tg>255) graphics.col_tg=255;
|
||||
if (graphics.col_tb < 0) graphics.col_tb = 0;
|
||||
if(graphics.col_tb>255) graphics.col_tb=255;
|
||||
|
||||
graphics.updatetitlecolours();
|
||||
}
|
||||
|
||||
graphics.crewframedelay--;
|
||||
if (graphics.crewframedelay <= 0)
|
||||
{
|
||||
|
@ -51,6 +72,7 @@ void maplogic()
|
|||
//Misc
|
||||
help.updateglow();
|
||||
graphics.updatetextboxes();
|
||||
graphics.updatetitlecolours();
|
||||
|
||||
graphics.crewframedelay--;
|
||||
if (graphics.crewframedelay <= 0)
|
||||
|
@ -103,6 +125,17 @@ void gamecompletelogic()
|
|||
help.updateglow();
|
||||
graphics.crewframe = 0;
|
||||
map.scrolldir = 1;
|
||||
graphics.updatetitlecolours();
|
||||
|
||||
graphics.col_tr = map.r - (help.glow / 4) - fRandom() * 4;
|
||||
graphics.col_tg = map.g - (help.glow / 4) - fRandom() * 4;
|
||||
graphics.col_tb = map.b - (help.glow / 4) - fRandom() * 4;
|
||||
if (graphics.col_tr < 0) graphics.col_tr = 0;
|
||||
if(graphics.col_tr>255) graphics.col_tr=255;
|
||||
if (graphics.col_tg < 0) graphics.col_tg = 0;
|
||||
if(graphics.col_tg>255) graphics.col_tg=255;
|
||||
if (graphics.col_tb < 0) graphics.col_tb = 0;
|
||||
if(graphics.col_tb>255) graphics.col_tb=255;
|
||||
|
||||
game.creditposition--;
|
||||
if (game.creditposition <= -game.creditmaxposition)
|
||||
|
|
|
@ -519,8 +519,8 @@ void menurender()
|
|||
graphics.Print(160 - 84, 132-20, game.tele_gametime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 132-20, help.number(game.tele_trinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 126-20, 50, 18);
|
||||
graphics.drawspritesetcol(175, 126-20, 22, 18);
|
||||
graphics.drawsprite(50, 126-20, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 126-20, 22, graphics.col_trinket);
|
||||
break;
|
||||
case 1:
|
||||
//Show quick save info
|
||||
|
@ -535,8 +535,8 @@ void menurender()
|
|||
graphics.Print(160 - 84, 132-20, game.quick_gametime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 132-20, help.number(game.quick_trinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 126-20, 50, 18);
|
||||
graphics.drawspritesetcol(175, 126-20, 22, 18);
|
||||
graphics.drawsprite(50, 126-20, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 126-20, 22, graphics.col_trinket);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1029,9 +1029,9 @@ void titlerender()
|
|||
|
||||
if (!game.menustart)
|
||||
{
|
||||
tr = (int)(164 - (help.glow / 2) - int(fRandom() * 4));
|
||||
tg = 164 - (help.glow / 2) - int(fRandom() * 4);
|
||||
tb = 164 - (help.glow / 2) - int(fRandom() * 4);
|
||||
tr = graphics.col_tr;
|
||||
tg = graphics.col_tg;
|
||||
tb = graphics.col_tb;
|
||||
|
||||
int temp = 50;
|
||||
graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb);
|
||||
|
@ -1051,15 +1051,9 @@ void titlerender()
|
|||
{
|
||||
if(!game.colourblindmode) graphics.drawtowerbackground();
|
||||
|
||||
tr = map.r - (help.glow / 4) - int(fRandom() * 4);
|
||||
tg = map.g - (help.glow / 4) - int(fRandom() * 4);
|
||||
tb = map.b - (help.glow / 4) - int(fRandom() * 4);
|
||||
if (tr < 0) tr = 0;
|
||||
if(tr>255) tr=255;
|
||||
if (tg < 0) tg = 0;
|
||||
if(tg>255) tg=255;
|
||||
if (tb < 0) tb = 0;
|
||||
if(tb>255) tb=255;
|
||||
tr = graphics.col_tr;
|
||||
tg = graphics.col_tg;
|
||||
tb = graphics.col_tb;
|
||||
|
||||
menurender();
|
||||
|
||||
|
@ -1113,15 +1107,9 @@ void gamecompleterender()
|
|||
|
||||
if(!game.colourblindmode) graphics.drawtowerbackground();
|
||||
|
||||
tr = map.r - (help.glow / 4) - fRandom() * 4;
|
||||
tg = map.g - (help.glow / 4) - fRandom() * 4;
|
||||
tb = map.b - (help.glow / 4) - fRandom() * 4;
|
||||
if (tr < 0) tr = 0;
|
||||
if(tr>255) tr=255;
|
||||
if (tg < 0) tg = 0;
|
||||
if(tg>255) tg=255;
|
||||
if (tb < 0) tb = 0;
|
||||
if(tb>255) tb=255;
|
||||
tr = graphics.col_tr;
|
||||
tg = graphics.col_tg;
|
||||
tb = graphics.col_tb;
|
||||
|
||||
|
||||
//rendering starts... here!
|
||||
|
@ -2193,8 +2181,8 @@ void maprender()
|
|||
graphics.Print(160 - 84, 78, game.savetime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 78, help.number(game.savetrinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 74, 50, 18);
|
||||
graphics.drawspritesetcol(175, 74, 22, 18);
|
||||
graphics.drawsprite(50, 74, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 74, 22, graphics.col_trinket);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2202,8 +2190,8 @@ void maprender()
|
|||
graphics.Print(160 - 84, 132, game.savetime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 132, help.number(game.savetrinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 126, 50, 18);
|
||||
graphics.drawspritesetcol(175, 126, 22, 18);
|
||||
graphics.drawsprite(50, 126, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 126, 22, graphics.col_trinket);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2240,8 +2228,8 @@ void maprender()
|
|||
graphics.Print(160 - 84, 78, game.savetime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 78, help.number(game.savetrinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 74, 50, 18);
|
||||
graphics.drawspritesetcol(175, 74, 22, 18);
|
||||
graphics.drawsprite(50, 74, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 74, 22, graphics.col_trinket);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2253,8 +2241,8 @@ void maprender()
|
|||
graphics.Print(160 - 84, 132, game.savetime, 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
graphics.Print(160 + 40, 132, help.number(game.savetrinkets), 255 - (help.glow / 2), 255 - (help.glow / 2), 255 - (help.glow / 2));
|
||||
|
||||
graphics.drawspritesetcol(50, 126, 50, 18);
|
||||
graphics.drawspritesetcol(175, 126, 22, 18);
|
||||
graphics.drawsprite(50, 126, 50, graphics.col_clock);
|
||||
graphics.drawsprite(175, 126, 22, graphics.col_trinket);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue