1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Axe Graphics::ct and Graphics::setcolreal

`ct` was used to be a variable that a color was temporarily stored in
before being passed to a draw function. But this is unnecessary and you
might as well just have a temporary of the color directly. I guess this
was the practice used because temporaries were apparently really bad in
Flash.

setcolreal() was added in 2.3 to do basically the same thing (set it
directly from entities' realcol attributes). But it's no longer needed.

Correspondingly, Graphics::setcol has been renamed to Graphics::getcol
and now returns an SDL_Color, and Graphics::huetilesetcol has been
renamed to Graphics::huetilegetcol for the same reason.

Some functions (notably Graphics::drawimagecol and
Graphics::drawhuetile) were relying on the `ct` to be implicitly set and
weren't ever having it passed in directly. They have been corrected
accordingly.
This commit is contained in:
Misa 2023-01-01 20:16:08 -08:00
parent 351a022ebd
commit 8dc088896f
5 changed files with 104 additions and 179 deletions

View file

@ -611,8 +611,7 @@ void editorrender(void)
case 1: //Entities case 1: //Entities
if (custom_gray) if (custom_gray)
{ {
graphics.setcol(18); ed.entcolreal = graphics.getcol(18);
ed.entcolreal = graphics.ct;
} }
graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal); graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal);
if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "V", 255, 255, 255 - help.glow, false); if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "V", 255, 255, 255 - help.glow, false);
@ -932,13 +931,13 @@ void editorrender(void)
point tpoint; point tpoint;
tpoint.x = ed.ghosts[i].x; tpoint.x = ed.ghosts[i].x;
tpoint.y = ed.ghosts[i].y; tpoint.y = ed.ghosts[i].y;
graphics.setcolreal(ed.ghosts[i].realcol); SDL_Color ct = ed.ghosts[i].realcol;
const int alpha = 3 * graphics.ct.a / 4; const int alpha = 3 * ct.a / 4;
graphics.ct.a = (Uint8) alpha; ct.a = (Uint8) alpha;
SDL_Rect drawRect = graphics.sprites_rect; SDL_Rect drawRect = graphics.sprites_rect;
drawRect.x += tpoint.x; drawRect.x += tpoint.x;
drawRect.y += tpoint.y; drawRect.y += tpoint.y;
BlitSurfaceColoured(graphics.sprites[ed.ghosts[i].frame],NULL, graphics.ghostbuffer, &drawRect, graphics.ct); BlitSurfaceColoured(graphics.sprites[ed.ghosts[i].frame],NULL, graphics.ghostbuffer, &drawRect, ct);
} }
} }
SDL_BlitSurface(graphics.ghostbuffer, NULL, graphics.backBuffer, NULL); SDL_BlitSurface(graphics.ghostbuffer, NULL, graphics.backBuffer, NULL);
@ -1604,8 +1603,7 @@ void editorrenderfixed(void)
game.customcol=cl.getlevelcol(room->tileset, room->tilecol)+1; game.customcol=cl.getlevelcol(room->tileset, room->tilecol)+1;
ed.entcol=cl.getenemycol(game.customcol); ed.entcol=cl.getenemycol(game.customcol);
graphics.setcol(ed.entcol); ed.entcolreal = graphics.getcol(ed.entcol);
ed.entcolreal = graphics.ct;
if (game.ghostsenabled) if (game.ghostsenabled)
{ {
@ -1618,8 +1616,7 @@ void editorrenderfixed(void)
continue; continue;
} }
graphics.setcol(ghost.col); ghost.realcol = graphics.getcol(ghost.col);
ghost.realcol = graphics.ct;
} }
if (ed.currentghosts + 1 < (int)ed.ghosts.size()) { if (ed.currentghosts + 1 < (int)ed.ghosts.size()) {

View file

@ -617,41 +617,34 @@ void entclass::updatecolour(void)
case 9: // Really Big Sprite! (2x2) case 9: // Really Big Sprite! (2x2)
case 10: // 2x1 Sprite case 10: // 2x1 Sprite
case 13: // Special for epilogue: huge hero! case 13: // Special for epilogue: huge hero!
graphics.setcol(colour); realcol = graphics.getcol(colour);
realcol = graphics.ct;
break; break;
case 3: // Big chunky pixels! case 3: // Big chunky pixels!
realcol = graphics.bigchunkygetcol(colour); realcol = graphics.bigchunkygetcol(colour);
break; break;
case 4: // Small pickups case 4: // Small pickups
graphics.huetilesetcol(colour); realcol = graphics.huetilegetcol(colour);
realcol = graphics.ct;
break; break;
case 11: // The fucking elephant case 11: // The fucking elephant
if (game.noflashingmode) if (game.noflashingmode)
{ {
graphics.setcol(22); realcol = graphics.getcol(22);
} }
else else
{ {
graphics.setcol(colour); realcol = graphics.getcol(colour);
} }
realcol = graphics.ct;
break; break;
case 12: // Regular sprites that don't wrap case 12: // Regular sprites that don't wrap
// if we're outside the screen, we need to draw indicators // if we're outside the screen, we need to draw indicators
if ((xp < -20 && vx > 0) || (xp > 340 && vx < 0)) if ((xp < -20 && vx > 0) || (xp > 340 && vx < 0))
{ {
graphics.setcol(23); realcol = graphics.getcol(23);
} }
else else
{ {
graphics.setcol(colour); realcol = graphics.getcol(colour);
} }
realcol = graphics.ct;
break;
default:
break;
} }
} }

View file

@ -106,7 +106,6 @@ void Graphics::init(void)
// initialize everything else to zero // initialize everything else to zero
backBuffer = NULL; backBuffer = NULL;
SDL_zero(ct);
foregrounddrawn = false; foregrounddrawn = false;
foregroundBuffer = NULL; foregroundBuffer = NULL;
backgrounddrawn = false; backgrounddrawn = false;
@ -291,32 +290,23 @@ void Graphics::drawspritesetcol(int x, int y, int t, int c)
} }
SDL_Rect rect; SDL_Rect rect;
setRect(rect,x,y,sprites_rect.w,sprites_rect.h); setRect(rect,x,y,sprites_rect.w,sprites_rect.h);
setcol(c); const SDL_Color ct = getcol(c);
BlitSurfaceColoured(sprites[t],NULL,backBuffer, &rect, ct); BlitSurfaceColoured(sprites[t],NULL,backBuffer, &rect, ct);
} }
void Graphics::updatetitlecolours(void) void Graphics::updatetitlecolours(void)
{ {
setcol(15); col_crewred = getcol(15);
col_crewred = ct; col_crewyellow = getcol(14);
setcol(14); col_crewgreen = getcol(13);
col_crewyellow = ct; col_crewcyan = getcol(0);
setcol(13); col_crewblue = getcol(16);
col_crewgreen = ct; col_crewpurple = getcol(20);
setcol(0); col_crewinactive = getcol(19);
col_crewcyan = ct;
setcol(16);
col_crewblue = ct;
setcol(20);
col_crewpurple = ct;
setcol(19);
col_crewinactive = ct;
setcol(18); col_clock = getcol(18);
col_clock = ct; col_trinket = getcol(18);
setcol(18);
col_trinket = ct;
} }
#define PROCESS_TILESHEET_CHECK_ERROR(tilesheet, tile_square) \ #define PROCESS_TILESHEET_CHECK_ERROR(tilesheet, tile_square) \
@ -542,7 +532,7 @@ void Graphics::do_print(
b = SDL_clamp(b, 0, 255); b = SDL_clamp(b, 0, 255);
a = SDL_clamp(a, 0, 255); a = SDL_clamp(a, 0, 255);
ct = getRGBA(r, g, b, a); const SDL_Color ct = getRGBA(r, g, b, a);
while (iter != text.end()) while (iter != text.end())
{ {
@ -1029,8 +1019,7 @@ void Graphics::drawsprite( int x, int y, int t, int r, int g, int b )
} }
SDL_Rect rect = {x, y, sprites_rect.w, sprites_rect.h}; SDL_Rect rect = {x, y, sprites_rect.w, sprites_rect.h};
setcolreal(getRGB(r,g,b)); BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, getRGB(r, g, b));
BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct);
} }
void Graphics::drawsprite(int x, int y, int t, const SDL_Color color) void Graphics::drawsprite(int x, int y, int t, const SDL_Color color)
@ -1042,8 +1031,7 @@ void Graphics::drawsprite(int x, int y, int t, const SDL_Color color)
} }
SDL_Rect rect = {x, y, sprites_rect.w, sprites_rect.h}; SDL_Rect rect = {x, y, sprites_rect.w, sprites_rect.h};
setcolreal(color); BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, color);
BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct);
} }
#ifndef NO_CUSTOM_LEVELS #ifndef NO_CUSTOM_LEVELS
@ -1343,7 +1331,7 @@ void Graphics::updatetextboxes(void)
} }
} }
void Graphics::drawimagecol( int t, int xp, int yp, bool cent/*= false*/ ) void Graphics::drawimagecol( int t, int xp, int yp, const SDL_Color ct, bool cent/*= false*/ )
{ {
if (!INBOUNDS_VEC(t, images) || images[t] == NULL) if (!INBOUNDS_VEC(t, images) || images[t] == NULL)
{ {
@ -1887,9 +1875,8 @@ void Graphics::drawcoloredtile(
return; return;
} }
setcolreal(getRGB(r, g, b));
setRect(rect, x, y, tiles_rect.w, tiles_rect.h); setRect(rect, x, y, tiles_rect.w, tiles_rect.h);
BlitSurfaceColoured(tiles[t], NULL, backBuffer, &rect, ct); BlitSurfaceColoured(tiles[t], NULL, backBuffer, &rect, getRGB(r, g, b));
} }
@ -2172,7 +2159,7 @@ void Graphics::drawentity(const int i, const int yoff)
} }
tpoint.x = xp; tpoint.x = xp;
tpoint.y = yp - yoff; tpoint.y = yp - yoff;
setcolreal(obj.entities[i].realcol); const SDL_Color ct = obj.entities[i].realcol;
drawRect = sprites_rect; drawRect = sprites_rect;
drawRect.x += tpoint.x; drawRect.x += tpoint.x;
@ -2284,8 +2271,7 @@ void Graphics::drawentity(const int i, const int yoff)
FillRect(backBuffer, prect, obj.entities[i].realcol); FillRect(backBuffer, prect, obj.entities[i].realcol);
break; break;
case 4: // Small pickups case 4: // Small pickups
setcolreal(obj.entities[i].realcol); drawhuetile(xp, yp - yoff, obj.entities[i].tile, obj.entities[i].realcol);
drawhuetile(xp, yp - yoff, obj.entities[i].tile);
break; break;
case 5: //Horizontal Line case 5: //Horizontal Line
{ {
@ -2315,7 +2301,8 @@ void Graphics::drawentity(const int i, const int yoff)
// Note: This code is in the 4-tile code // Note: This code is in the 4-tile code
break; break;
case 9: // Really Big Sprite! (2x2) case 9: // Really Big Sprite! (2x2)
setcolreal(obj.entities[i].realcol); {
const SDL_Color ct = obj.entities[i].realcol;
tpoint.x = xp; tpoint.x = xp;
tpoint.y = yp - yoff; tpoint.y = yp - yoff;
@ -2361,8 +2348,10 @@ void Graphics::drawentity(const int i, const int yoff)
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct); BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
} }
break; break;
}
case 10: // 2x1 Sprite case 10: // 2x1 Sprite
setcolreal(obj.entities[i].realcol); {
const SDL_Color ct = obj.entities[i].realcol;
tpoint.x = xp; tpoint.x = xp;
tpoint.y = yp - yoff; tpoint.y = yp - yoff;
@ -2386,14 +2375,15 @@ void Graphics::drawentity(const int i, const int yoff)
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct); BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
} }
break; break;
}
case 11: //The fucking elephant case 11: //The fucking elephant
setcolreal(obj.entities[i].realcol); drawimagecol(3, xp, yp - yoff, obj.entities[i].realcol);
drawimagecol(3, xp, yp - yoff);
break; break;
case 12: // Regular sprites that don't wrap case 12: // Regular sprites that don't wrap
{
tpoint.x = xp; tpoint.x = xp;
tpoint.y = yp - yoff; tpoint.y = yp - yoff;
setcolreal(obj.entities[i].realcol); const SDL_Color ct = obj.entities[i].realcol;
// //
drawRect = sprites_rect; drawRect = sprites_rect;
drawRect.x += tpoint.x; drawRect.x += tpoint.x;
@ -2452,6 +2442,7 @@ void Graphics::drawentity(const int i, const int yoff)
} }
} }
break; break;
}
case 13: case 13:
{ {
//Special for epilogue: huge hero! //Special for epilogue: huge hero!
@ -2461,10 +2452,9 @@ void Graphics::drawentity(const int i, const int yoff)
} }
tpoint.x = xp; tpoint.y = yp - yoff; tpoint.x = xp; tpoint.y = yp - yoff;
setcolreal(obj.entities[i].realcol);
setRect(drawRect, xp, yp - yoff, sprites_rect.x * 6, sprites_rect.y * 6); setRect(drawRect, xp, yp - yoff, sprites_rect.x * 6, sprites_rect.y * 6);
SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h ); SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct ); BlitSurfaceColoured(TempSurface, NULL, backBuffer, &drawRect, obj.entities[i].realcol);
VVV_freefunc(SDL_FreeSurface, TempSurface); VVV_freefunc(SDL_FreeSurface, TempSurface);
@ -3090,23 +3080,20 @@ void Graphics::updatetowerbackground(TowerBG& bg_obj)
} }
} }
void Graphics::setcol( int t ) SDL_Color Graphics::getcol( int t )
{ {
//Setup predefinied colours as per our zany palette //Setup predefinied colours as per our zany palette
switch(t) switch(t)
{ {
//Player Normal //Player Normal
case 0: case 0:
ct = getRGB(160 - help.glow/2 - (fRandom() * 20), 200 - help.glow/2, 220 - help.glow); return getRGB(160 - help.glow/2 - (fRandom() * 20), 200 - help.glow/2, 220 - help.glow);
break;
//Player Hurt //Player Hurt
case 1: case 1:
ct = getRGB(196 - (fRandom() * 64), 10, 10); return getRGB(196 - (fRandom() * 64), 10, 10);
break;
//Enemies and stuff //Enemies and stuff
case 2: case 2:
ct = getRGB(225 - (help.glow / 2), 75, 30); return getRGB(225 - (help.glow / 2), 75, 30);
break;
case 3: //Trinket case 3: //Trinket
if (!trinketcolset) if (!trinketcolset)
{ {
@ -3115,110 +3102,82 @@ void Graphics::setcol( int t )
trinketb = 164 + (fRandom() * 60); trinketb = 164 + (fRandom() * 60);
trinketcolset = true; trinketcolset = true;
} }
ct = getRGB(trinketr, trinketg, trinketb); return getRGB(trinketr, trinketg, trinketb);
break;
case 4: //Inactive savepoint case 4: //Inactive savepoint
{ {
const int temp = (help.glow / 2) + (fRandom() * 8); const int temp = (help.glow / 2) + (fRandom() * 8);
ct = getRGB(80 + temp, 80 + temp, 80 + temp); return getRGB(80 + temp, 80 + temp, 80 + temp);
break;
} }
case 5: //Active savepoint case 5: //Active savepoint
ct = getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64)); return getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64));
break;
case 6: //Enemy : Red case 6: //Enemy : Red
ct = getRGB(250 - help.glow/2, 60- help.glow/2, 60 - help.glow/2); return getRGB(250 - help.glow/2, 60- help.glow/2, 60 - help.glow/2);
break;
case 7: //Enemy : Green case 7: //Enemy : Green
ct = getRGB(100 - help.glow/2 - (fRandom() * 30), 250 - help.glow/2, 100 - help.glow/2 - (fRandom() * 30)); return getRGB(100 - help.glow/2 - (fRandom() * 30), 250 - help.glow/2, 100 - help.glow/2 - (fRandom() * 30));
break;
case 8: //Enemy : Purple case 8: //Enemy : Purple
ct = getRGB(250 - help.glow/2, 20, 128 - help.glow/2 + (fRandom() * 30)); return getRGB(250 - help.glow/2, 20, 128 - help.glow/2 + (fRandom() * 30));
break;
case 9: //Enemy : Yellow case 9: //Enemy : Yellow
ct = getRGB(250 - help.glow/2, 250 - help.glow/2, 20); return getRGB(250 - help.glow/2, 250 - help.glow/2, 20);
break;
case 10: //Warp point (white) case 10: //Warp point (white)
ct = getRGB(255 - (fRandom() * 64), 255 - (fRandom() * 64), 255 - (fRandom() * 64)); return getRGB(255 - (fRandom() * 64), 255 - (fRandom() * 64), 255 - (fRandom() * 64));
break;
case 11: //Enemy : Cyan case 11: //Enemy : Cyan
ct = getRGB(20, 250 - help.glow/2, 250 - help.glow/2); return getRGB(20, 250 - help.glow/2, 250 - help.glow/2);
break;
case 12: //Enemy : Blue case 12: //Enemy : Blue
ct = getRGB(90 - help.glow/2, 90 - help.glow/2, 250 - help.glow/2); return getRGB(90 - help.glow/2, 90 - help.glow/2, 250 - help.glow/2);
break;
//Crew Members //Crew Members
//green //green
case 13: case 13:
ct = getRGB(120 - help.glow/4 - (fRandom() * 20), 220 - help.glow/4, 120 - help.glow/4); return getRGB(120 - help.glow/4 - (fRandom() * 20), 220 - help.glow/4, 120 - help.glow/4);
break;
//Yellow //Yellow
case 14: case 14:
ct = getRGB(220 - help.glow/4 - (fRandom() * 20), 210 - help.glow/4, 120 - help.glow/4); return getRGB(220 - help.glow/4 - (fRandom() * 20), 210 - help.glow/4, 120 - help.glow/4);
break;
//pink //pink
case 15: case 15:
ct = getRGB(255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4); return getRGB(255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4);
break;
//Blue //Blue
case 16: case 16:
ct = getRGB(75, 75, 255 - help.glow/4 - (fRandom() * 20)); return getRGB(75, 75, 255 - help.glow/4 - (fRandom() * 20));
break;
case 17: //Enemy : Orange case 17: //Enemy : Orange
ct = getRGB(250 - help.glow/2, 130 - help.glow/2, 20); return getRGB(250 - help.glow/2, 130 - help.glow/2, 20);
break;
case 18: //Enemy : Gray case 18: //Enemy : Gray
ct = getRGB(130 - help.glow/2, 130 - help.glow/2, 130 - help.glow/2); return getRGB(130 - help.glow/2, 130 - help.glow/2, 130 - help.glow/2);
break;
case 19: //Enemy : Dark gray case 19: //Enemy : Dark gray
ct = getRGB(60 - help.glow/8, 60 - help.glow/8, 60 - help.glow/8); return getRGB(60 - help.glow/8, 60 - help.glow/8, 60 - help.glow/8);
break;
//Purple //Purple
case 20: case 20:
ct = getRGB(220 - help.glow/4 - (fRandom() * 20), 120 - help.glow/4, 210 - help.glow/4); return getRGB(220 - help.glow/4 - (fRandom() * 20), 120 - help.glow/4, 210 - help.glow/4);
break;
case 21: //Enemy : Light Gray case 21: //Enemy : Light Gray
ct = getRGB(180 - help.glow/2, 180 - help.glow/2, 180 - help.glow/2); return getRGB(180 - help.glow/2, 180 - help.glow/2, 180 - help.glow/2);
break;
case 22: //Enemy : Indicator Gray case 22: //Enemy : Indicator Gray
ct = getRGB(230 - help.glow/2, 230- help.glow/2, 230 - help.glow/2); return getRGB(230 - help.glow/2, 230- help.glow/2, 230 - help.glow/2);
break;
case 23: //Enemy : Indicator Gray case 23: //Enemy : Indicator Gray
ct = getRGB(255 - help.glow/2 - (fRandom() * 40) , 255 - help.glow/2 - (fRandom() * 40), 255 - help.glow/2 - (fRandom() * 40)); return getRGB(255 - help.glow/2 - (fRandom() * 40) , 255 - help.glow/2 - (fRandom() * 40), 255 - help.glow/2 - (fRandom() * 40));
break;
//Trophies //Trophies
//cyan //cyan
case 30: case 30:
ct = RGBf(160, 200, 220); return RGBf(160, 200, 220);
break;
//Purple //Purple
case 31: case 31:
ct = RGBf(220, 120, 210); return RGBf(220, 120, 210);
break;
//Yellow //Yellow
case 32: case 32:
ct = RGBf(220, 210, 120); return RGBf(220, 210, 120);
break;
//red //red
case 33: case 33:
ct = RGBf(255, 70, 70); return RGBf(255, 70, 70);
break;
//green //green
case 34: case 34:
ct = RGBf(120, 220, 120); return RGBf(120, 220, 120);
break;
//Blue //Blue
case 35: case 35:
ct = RGBf(75, 75, 255); return RGBf(75, 75, 255);
break;
//Gold //Gold
case 36: case 36:
ct = getRGB(180, 120, 20); return getRGB(180, 120, 20);
break;
case 37: //Trinket case 37: //Trinket
if (!trinketcolset) if (!trinketcolset)
{ {
@ -3227,74 +3186,65 @@ void Graphics::setcol( int t )
trinketb = 164 + (fRandom() * 60); trinketb = 164 + (fRandom() * 60);
trinketcolset = true; trinketcolset = true;
} }
ct = RGBf(trinketr, trinketg, trinketb); return RGBf(trinketr, trinketg, trinketb);
break;
//Silver //Silver
case 38: case 38:
ct = RGBf(196, 196, 196); return RGBf(196, 196, 196);
break;
//Bronze //Bronze
case 39: case 39:
ct = RGBf(128, 64, 10); return RGBf(128, 64, 10);
break;
//Awesome //Awesome
case 40: //Teleporter in action! case 40: //Teleporter in action!
{ {
const int temp = fRandom() * 150; const int temp = fRandom() * 150;
if(temp<33) if(temp<33)
{ {
ct = RGBf(255 - (fRandom() * 64), 64 + (fRandom() * 64), 64 + (fRandom() * 64)); return RGBf(255 - (fRandom() * 64), 64 + (fRandom() * 64), 64 + (fRandom() * 64));
} }
else if (temp < 66) else if (temp < 66)
{ {
ct = RGBf(64 + (fRandom() * 64), 255 - (fRandom() * 64), 64 + (fRandom() * 64)); return RGBf(64 + (fRandom() * 64), 255 - (fRandom() * 64), 64 + (fRandom() * 64));
} }
else if (temp < 100) else if (temp < 100)
{ {
ct = RGBf(64 + (fRandom() * 64), 64 + (fRandom() * 64), 255 - (fRandom() * 64)); return RGBf(64 + (fRandom() * 64), 64 + (fRandom() * 64), 255 - (fRandom() * 64));
} }
else else
{ {
ct = RGBf(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64)); return RGBf(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64));
} }
break;
} }
case 100: //Inactive Teleporter case 100: //Inactive Teleporter
{ {
const int temp = (help.glow / 2) + (fRandom() * 8); const int temp = (help.glow / 2) + (fRandom() * 8);
ct = getRGB(42 + temp, 42 + temp, 42 + temp); return getRGB(42 + temp, 42 + temp, 42 + temp);
break;
} }
case 101: //Active Teleporter case 101: //Active Teleporter
ct = getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64)); return getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64));
break;
case 102: //Teleporter in action! case 102: //Teleporter in action!
{ {
const int temp = fRandom() * 150; const int temp = fRandom() * 150;
if (temp < 33) if (temp < 33)
{ {
ct = getRGB(255 - (fRandom() * 64), 64 + (fRandom() * 64), 64 + (fRandom() * 64)); return getRGB(255 - (fRandom() * 64), 64 + (fRandom() * 64), 64 + (fRandom() * 64));
} }
else if (temp < 66) else if (temp < 66)
{ {
ct = getRGB(64 + (fRandom() * 64), 255 - (fRandom() * 64), 64 + (fRandom() * 64)); return getRGB(64 + (fRandom() * 64), 255 - (fRandom() * 64), 64 + (fRandom() * 64));
} }
else if (temp < 100) else if (temp < 100)
{ {
ct = getRGB(64 + (fRandom() * 64), 64 + (fRandom() * 64), 255 - (fRandom() * 64)); return getRGB(64 + (fRandom() * 64), 64 + (fRandom() * 64), 255 - (fRandom() * 64));
} }
else else
{ {
ct = getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64)); return getRGB(164 + (fRandom() * 64), 164 + (fRandom() * 64), 255 - (fRandom() * 64));
}
} }
break;
} }
default: return getRGB(255, 255, 255);
ct = getRGB(255, 255, 255);
break;
}
} }
void Graphics::menuoffrender(void) void Graphics::menuoffrender(void)
@ -3310,9 +3260,9 @@ void Graphics::menuoffrender(void)
ClearSurface(backBuffer); ClearSurface(backBuffer);
} }
void Graphics::drawhuetile( int x, int y, int t ) void Graphics::drawhuetile(const int x, const int y, const int tile, const SDL_Color ct)
{ {
if (!INBOUNDS_VEC(t, tiles)) if (!INBOUNDS_VEC(tile, tiles))
{ {
return; return;
} }
@ -3323,22 +3273,19 @@ void Graphics::drawhuetile( int x, int y, int t )
SDL_Rect rect; SDL_Rect rect;
setRect(rect,tpoint.x,tpoint.y,tiles_rect.w, tiles_rect.h); setRect(rect,tpoint.x,tpoint.y,tiles_rect.w, tiles_rect.h);
BlitSurfaceColoured(tiles[t],NULL,backBuffer, &rect, ct); BlitSurfaceColoured(tiles[tile], NULL, backBuffer, &rect, ct);
} }
void Graphics::huetilesetcol(int t) SDL_Color Graphics::huetilegetcol(const int t)
{ {
switch (t) switch (t)
{ {
case 0: case 0:
setcolreal(getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10)); return getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10);
break;
case 1: case 1:
setcolreal(getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10)); return getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10);
break;
default: default:
setcolreal(getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10)); return getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10);
break;
} }
} }
@ -3612,23 +3559,20 @@ void Graphics::bigbrprint(int x, int y, const std::string& s, int r, int g, int
void Graphics::drawtele(int x, int y, int t, const SDL_Color color) void Graphics::drawtele(int x, int y, int t, const SDL_Color color)
{ {
setcolreal(getRGB(16,16,16));
SDL_Rect telerect; SDL_Rect telerect;
setRect(telerect, x , y, tele_rect.w, tele_rect.h ); setRect(telerect, x , y, tele_rect.w, tele_rect.h );
if (INBOUNDS_VEC(0, tele)) if (INBOUNDS_VEC(0, tele))
{ {
BlitSurfaceColoured(tele[0], NULL, backBuffer, &telerect, ct); BlitSurfaceColoured(tele[0], NULL, backBuffer, &telerect, getRGB(16, 16, 16));
} }
setcolreal(color);
if (t > 9) t = 8; if (t > 9) t = 8;
if (t < 1) t = 1; if (t < 1) t = 1;
setRect(telerect, x , y, tele_rect.w, tele_rect.h ); setRect(telerect, x , y, tele_rect.w, tele_rect.h );
if (INBOUNDS_VEC(t, tele)) if (INBOUNDS_VEC(t, tele))
{ {
BlitSurfaceColoured(tele[t], NULL, backBuffer, &telerect, ct); BlitSurfaceColoured(tele[t], NULL, backBuffer, &telerect, color);
} }
} }
@ -3653,11 +3597,6 @@ SDL_Color Graphics::RGBf(int r, int g, int b)
return color; return color;
} }
void Graphics::setcolreal(const SDL_Color color)
{
ct = color;
}
void Graphics::drawforetile(int x, int y, int t) void Graphics::drawforetile(int x, int y, int t)
{ {
if (!INBOUNDS_VEC(t, tiles)) if (!INBOUNDS_VEC(t, tiles))

View file

@ -39,8 +39,8 @@ public:
bool Makebfont(void); bool Makebfont(void);
void drawhuetile(int x, int y, int t); void drawhuetile(int x, int y, int t, SDL_Color ct);
void huetilesetcol(int t); SDL_Color huetilegetcol(int t);
SDL_Color bigchunkygetcol(int t); SDL_Color bigchunkygetcol(int t);
void drawgravityline(int t); void drawgravityline(int t);
@ -134,7 +134,7 @@ public:
void drawimage(int t, int xp, int yp, bool cent=false); void drawimage(int t, int xp, int yp, bool cent=false);
void drawimagecol(int t, int xp, int yp, bool cent= false); void drawimagecol(int t, int xp, int yp, SDL_Color ct, bool cent= false);
void updatetextboxes(void); void updatetextboxes(void);
void drawgui(void); void drawgui(void);
@ -209,8 +209,6 @@ public:
SDL_Color RGBf(int r, int g, int b); SDL_Color RGBf(int r, int g, int b);
void setcolreal(SDL_Color color);
void drawbackground(int t); void drawbackground(int t);
void updatebackground(int t); void updatebackground(int t);
#ifndef NO_CUSTOM_LEVELS #ifndef NO_CUSTOM_LEVELS
@ -256,11 +254,9 @@ public:
void drawtowerbackground(const TowerBG& bg_obj); void drawtowerbackground(const TowerBG& bg_obj);
void updatetowerbackground(TowerBG& bg_obj); void updatetowerbackground(TowerBG& bg_obj);
void setcol(int t); SDL_Color getcol(int t);
void drawfinalmap(void); void drawfinalmap(void);
SDL_Color ct;
int rcol; int rcol;

View file

@ -434,16 +434,16 @@ static void menurender(void)
graphics.Print( -1, 50, loc::gettext("VVVVVV is a game by"), tr, tg, tb, true); graphics.Print( -1, 50, loc::gettext("VVVVVV is a game by"), tr, tg, tb, true);
graphics.bigprint( 40, 65, "Terry Cavanagh", tr, tg, tb, true, 2); graphics.bigprint( 40, 65, "Terry Cavanagh", tr, tg, tb, true, 2);
graphics.drawimagecol(7, -1, 86, true); graphics.drawimagecol(7, -1, 86, graphics.getRGB(tr, tg, tb), true);
graphics.Print( -1, 120, loc::gettext("and features music by"), tr, tg, tb, true); graphics.Print( -1, 120, loc::gettext("and features music by"), tr, tg, tb, true);
graphics.bigprint( 40, 135, "Magnus Pålsson", tr, tg, tb, true, 2); graphics.bigprint( 40, 135, "Magnus Pålsson", tr, tg, tb, true, 2);
graphics.drawimagecol(8, -1, 156, true); graphics.drawimagecol(8, -1, 156, graphics.getRGB(tr, tg, tb), true);
break; break;
case Menu::credits2: case Menu::credits2:
graphics.Print( -1, 50, loc::gettext("Roomnames are by"), tr, tg, tb, true); graphics.Print( -1, 50, loc::gettext("Roomnames are by"), tr, tg, tb, true);
graphics.bigprint( 40, 65, "Bennett Foddy", tr, tg, tb, true); graphics.bigprint( 40, 65, "Bennett Foddy", tr, tg, tb, true);
graphics.drawimagecol(9, -1, 86, true); graphics.drawimagecol(9, -1, 86, graphics.getRGB(tr, tg, tb), true);
graphics.Print( -1, 110, loc::gettext("C++ version by"), tr, tg, tb, true); graphics.Print( -1, 110, loc::gettext("C++ version by"), tr, tg, tb, true);
graphics.bigprint( 40, 125, "Simon Roth", tr, tg, tb, true); graphics.bigprint( 40, 125, "Simon Roth", tr, tg, tb, true);
graphics.bigprint( 40, 145, "Ethan Lee", tr, tg, tb, true); graphics.bigprint( 40, 145, "Ethan Lee", tr, tg, tb, true);