From fce56fde09a3ee365283e9b5f09487439364d916 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 30 Apr 2020 14:42:08 -0700 Subject: [PATCH] Move setcol part of drawhuetile() to separate function In order to make sure colors don't update more than 1000/34 frames per second, I'll have to move the color-setting part of this function somewhere else. --- desktop_version/src/Graphics.cpp | 21 +++++++++++++-------- desktop_version/src/Graphics.h | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 4bcb0c72..50db9412 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1610,7 +1610,8 @@ void Graphics::drawentities() } break; case 4: // Small pickups - drawhuetile(xp, yp - yoff, obj.entities[i].tile, obj.entities[i].colour); + huetilesetcol(obj.entities[i].colour); + drawhuetile(xp, yp - yoff, obj.entities[i].tile); break; case 5: //Horizontal Line line_rect.x = xp; @@ -2640,7 +2641,7 @@ void Graphics::menuoffrender() FillRect(backBuffer, 0x000000); } -void Graphics::drawhuetile( int x, int y, int t, int c ) +void Graphics::drawhuetile( int x, int y, int t ) { if (!INBOUNDS(t, tiles)) { @@ -2649,7 +2650,16 @@ void Graphics::drawhuetile( int x, int y, int t, int c ) point tpoint; tpoint.x = x; tpoint.y = y; - switch(c) + + + SDL_Rect rect; + setRect(rect,tpoint.x,tpoint.y,tiles_rect.w, tiles_rect.h); + BlitSurfaceColoured(tiles[t],NULL,backBuffer, &rect, ct); +} + +void Graphics::huetilesetcol(int t) +{ + switch (t) { case 0: setcolreal(getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10)); @@ -2661,11 +2671,6 @@ void Graphics::drawhuetile( int x, int y, int t, int c ) setcolreal(getRGB(250-int(fRandom()*32), 250-int(fRandom()*32), 10)); break; } - - - SDL_Rect rect; - setRect(rect,tpoint.x,tpoint.y,tiles_rect.w, tiles_rect.h); - BlitSurfaceColoured(tiles[t],NULL,backBuffer, &rect, ct); } void Graphics::setwarprect( int a, int b, int c, int d ) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index e8f1423c..0b4cf43c 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -32,7 +32,8 @@ public: void Makebfont(); - void drawhuetile(int x, int y, int t, int c); + void drawhuetile(int x, int y, int t); + void huetilesetcol(int t); void drawgravityline(int t);