1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 22:18:30 +02: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;
screenbuffer = NULL;
tempBuffer = NULL;
warpbuffer = NULL;
warpbuffer_lerp = NULL;
footerbuffer = NULL;
ghostbuffer = NULL;
towerbg = TowerBG();
@ -736,7 +738,7 @@ void Graphics::drawtowertile( int x, int y, int t )
x += 8;
y += 8;
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)
FillRect(backBuffer, 0x000000);
BlitSurfaceStandard(towerbg.buffer, NULL, towerbg.buffer_lerp, NULL);
ScrollSurface(towerbg.buffer_lerp, lerp(0, -3), 0);
BlitSurfaceStandard(towerbg.buffer_lerp, &towerbuffer_rect, backBuffer, NULL);
BlitSurfaceStandard(warpbuffer, NULL, warpbuffer_lerp, NULL);
ScrollSurface(warpbuffer_lerp, lerp(0, -3), 0);
BlitSurfaceStandard(warpbuffer_lerp, &towerbuffer_rect, backBuffer, NULL);
break;
case 4: //Warp zone (vertical)
FillRect(backBuffer, 0x000000);
SDL_BlitSurface(towerbg.buffer, NULL, towerbg.buffer_lerp, NULL);
ScrollSurface(towerbg.buffer_lerp, 0, lerp(0, -3));
SDL_BlitSurface(towerbg.buffer_lerp, &towerbuffer_rect, backBuffer, NULL);
SDL_BlitSurface(warpbuffer, NULL, warpbuffer_lerp, NULL);
ScrollSurface(warpbuffer_lerp, 0, lerp(0, -3));
SDL_BlitSurface(warpbuffer_lerp, &towerbuffer_rect, backBuffer, NULL);
break;
case 5:
//Warp zone, central
@ -2301,7 +2303,7 @@ void Graphics::updatebackground(int t)
if (backgrounddrawn)
{
ScrollSurface(towerbg.buffer, -3, 0 );
ScrollSurface(warpbuffer, -3, 0 );
for (int j = 0; j < 15; j++)
{
for (int i = 0; i < 2; i++)
@ -2317,7 +2319,7 @@ void Graphics::updatebackground(int t)
{
//draw the whole thing for the first time!
backoffset = 0;
FillRect(towerbg.buffer, 0x000000);
FillRect(warpbuffer, 0x000000);
for (int j = 0; j < 15; j++)
{
for (int i = 0; i < 21; i++)
@ -2340,7 +2342,7 @@ void Graphics::updatebackground(int t)
if (backgrounddrawn)
{
ScrollSurface(towerbg.buffer,0,-3);
ScrollSurface(warpbuffer,0,-3);
for (int j = 0; j < 2; j++)
{
for (int i = 0; i < 21; i++)
@ -2356,7 +2358,7 @@ void Graphics::updatebackground(int t)
{
//draw the whole thing for the first time!
backoffset = 0;
FillRect(towerbg.buffer,0x000000 );
FillRect(warpbuffer,0x000000 );
for (int j = 0; j < 16; j++)
{
for (int i = 0; i < 21; i++)

View File

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

View File

@ -257,6 +257,12 @@ int main(int argc, char *argv[])
graphics.menubuffer = CREATE_SURFACE(320, 240);
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);
SDL_SetSurfaceBlendMode(graphics.towerbg.buffer, SDL_BLENDMODE_NONE);