1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-04 18:29:41 +01:00

Move horizontal/vertical warp backgrounds to separate buffers

Instead of using the same tower buffer that gets used for towers, use a
separate buffer instead so there's no risk of stepping on the tower
buffer's toes at the wrong point in time.

This commit combined with the previous one fixes #369.
This commit is contained in:
Misa 2020-11-02 16:54:17 -08:00 committed by Ethan Lee
parent 70f3d457dd
commit bda92ad0bd
3 changed files with 21 additions and 11 deletions

View file

@ -115,6 +115,8 @@ void Graphics::init()
menubuffer = NULL; menubuffer = NULL;
screenbuffer = NULL; screenbuffer = NULL;
tempBuffer = NULL; tempBuffer = NULL;
warpbuffer = NULL;
warpbuffer_lerp = NULL;
footerbuffer = NULL; footerbuffer = NULL;
ghostbuffer = NULL; ghostbuffer = NULL;
towerbg = TowerBG(); towerbg = TowerBG();
@ -736,7 +738,7 @@ void Graphics::drawtowertile( int x, int y, int t )
x += 8; x += 8;
y += 8; y += 8;
SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h };
BlitSurfaceStandard(tiles2[t], NULL, towerbg.buffer, &rect); BlitSurfaceStandard(tiles2[t], NULL, warpbuffer, &rect);
} }
@ -2116,15 +2118,15 @@ void Graphics::drawbackground( int t )
} }
case 3: //Warp zone (horizontal) case 3: //Warp zone (horizontal)
FillRect(backBuffer, 0x000000); FillRect(backBuffer, 0x000000);
BlitSurfaceStandard(towerbg.buffer, NULL, towerbg.buffer_lerp, NULL); BlitSurfaceStandard(warpbuffer, NULL, warpbuffer_lerp, NULL);
ScrollSurface(towerbg.buffer_lerp, lerp(0, -3), 0); ScrollSurface(warpbuffer_lerp, lerp(0, -3), 0);
BlitSurfaceStandard(towerbg.buffer_lerp, &towerbuffer_rect, backBuffer, NULL); BlitSurfaceStandard(warpbuffer_lerp, &towerbuffer_rect, backBuffer, NULL);
break; break;
case 4: //Warp zone (vertical) case 4: //Warp zone (vertical)
FillRect(backBuffer, 0x000000); FillRect(backBuffer, 0x000000);
SDL_BlitSurface(towerbg.buffer, NULL, towerbg.buffer_lerp, NULL); SDL_BlitSurface(warpbuffer, NULL, warpbuffer_lerp, NULL);
ScrollSurface(towerbg.buffer_lerp, 0, lerp(0, -3)); ScrollSurface(warpbuffer_lerp, 0, lerp(0, -3));
SDL_BlitSurface(towerbg.buffer_lerp, &towerbuffer_rect, backBuffer, NULL); SDL_BlitSurface(warpbuffer_lerp, &towerbuffer_rect, backBuffer, NULL);
break; break;
case 5: case 5:
//Warp zone, central //Warp zone, central
@ -2301,7 +2303,7 @@ void Graphics::updatebackground(int t)
if (backgrounddrawn) if (backgrounddrawn)
{ {
ScrollSurface(towerbg.buffer, -3, 0 ); ScrollSurface(warpbuffer, -3, 0 );
for (int j = 0; j < 15; j++) for (int j = 0; j < 15; j++)
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
@ -2317,7 +2319,7 @@ void Graphics::updatebackground(int t)
{ {
//draw the whole thing for the first time! //draw the whole thing for the first time!
backoffset = 0; backoffset = 0;
FillRect(towerbg.buffer, 0x000000); FillRect(warpbuffer, 0x000000);
for (int j = 0; j < 15; j++) for (int j = 0; j < 15; j++)
{ {
for (int i = 0; i < 21; i++) for (int i = 0; i < 21; i++)
@ -2340,7 +2342,7 @@ void Graphics::updatebackground(int t)
if (backgrounddrawn) if (backgrounddrawn)
{ {
ScrollSurface(towerbg.buffer,0,-3); ScrollSurface(warpbuffer,0,-3);
for (int j = 0; j < 2; j++) for (int j = 0; j < 2; j++)
{ {
for (int i = 0; i < 21; i++) for (int i = 0; i < 21; i++)
@ -2356,7 +2358,7 @@ void Graphics::updatebackground(int t)
{ {
//draw the whole thing for the first time! //draw the whole thing for the first time!
backoffset = 0; backoffset = 0;
FillRect(towerbg.buffer,0x000000 ); FillRect(warpbuffer,0x000000 );
for (int j = 0; j < 16; j++) for (int j = 0; j < 16; j++)
{ {
for (int i = 0; i < 21; i++) for (int i = 0; i < 21; i++)

View file

@ -228,6 +228,8 @@ public:
SDL_Surface* menubuffer; SDL_Surface* menubuffer;
SDL_Surface* foregroundBuffer; SDL_Surface* foregroundBuffer;
SDL_Surface* tempBuffer; SDL_Surface* tempBuffer;
SDL_Surface* warpbuffer;
SDL_Surface* warpbuffer_lerp;
TowerBG towerbg; TowerBG towerbg;
TowerBG titlebg; TowerBG titlebg;

View file

@ -257,6 +257,12 @@ int main(int argc, char *argv[])
graphics.menubuffer = CREATE_SURFACE(320, 240); graphics.menubuffer = CREATE_SURFACE(320, 240);
SDL_SetSurfaceBlendMode(graphics.menubuffer, SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(graphics.menubuffer, SDL_BLENDMODE_NONE);
graphics.warpbuffer = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.warpbuffer, SDL_BLENDMODE_NONE);
graphics.warpbuffer_lerp = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.warpbuffer_lerp, SDL_BLENDMODE_NONE);
graphics.towerbg.buffer = CREATE_SURFACE(320 + 16, 240 + 16); graphics.towerbg.buffer = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.towerbg.buffer, SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(graphics.towerbg.buffer, SDL_BLENDMODE_NONE);