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

Move title usages of towerbg to titlebg

With the previous commit in place, we can now simply move some usages of
the previous towerbg to use a separate object instead. That way, we
don't have to mess with a monolithic state, or some better way to phrase
what I just said, and we instead have two separate objects that can
coexist side-by-side.
This commit is contained in:
Misa 2020-11-02 15:23:53 -08:00 committed by Ethan Lee
parent 72c048d71e
commit 70f3d457dd
10 changed files with 54 additions and 44 deletions

View file

@ -1373,7 +1373,7 @@ void Game::updatestate()
gamestate = TITLEMODE; gamestate = TITLEMODE;
graphics.fademode = 4; graphics.fademode = 4;
graphics.backgrounddrawn = true; graphics.backgrounddrawn = true;
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
createmenu(Menu::timetrialcomplete); createmenu(Menu::timetrialcomplete);
state = 0; state = 0;
break; break;
@ -2942,7 +2942,7 @@ void Game::updatestate()
gamestate = TITLEMODE; gamestate = TITLEMODE;
graphics.fademode = 4; graphics.fademode = 4;
graphics.backgrounddrawn = true; graphics.backgrounddrawn = true;
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
music.play(6); music.play(6);
state = 0; state = 0;
break; break;
@ -3278,7 +3278,7 @@ void Game::updatestate()
gamestate = TITLEMODE; gamestate = TITLEMODE;
graphics.fademode = 4; graphics.fademode = 4;
graphics.backgrounddrawn = true; graphics.backgrounddrawn = true;
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
createmenu(Menu::nodeathmodecomplete); createmenu(Menu::nodeathmodecomplete);
state = 0; state = 0;
break; break;
@ -7129,7 +7129,7 @@ void Game::quittomenu()
FILESYSTEM_unmountassets(); // should be before music.play(6) FILESYSTEM_unmountassets(); // should be before music.play(6)
music.play(6); music.play(6);
graphics.backgrounddrawn = false; graphics.backgrounddrawn = false;
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
graphics.flipmode = false; graphics.flipmode = false;
//Don't be stuck on the summary screen, //Don't be stuck on the summary screen,
//or "who do you want to play the level with?" //or "who do you want to play the level with?"
@ -7223,7 +7223,7 @@ void Game::returntoeditor()
ed.level[i+(j*ed.maxwidth)].warpdir=ed.kludgewarpdir[i+(j*ed.maxwidth)]; ed.level[i+(j*ed.maxwidth)].warpdir=ed.kludgewarpdir[i+(j*ed.maxwidth)];
} }
} }
graphics.towerbg.scrolldir = 0; graphics.titlebg.scrolldir = 0;
} }
#endif #endif
@ -7233,7 +7233,7 @@ void Game::returntopausemenu()
returntomenu(kludge_ingametemp); returntomenu(kludge_ingametemp);
gamestate = MAPMODE; gamestate = MAPMODE;
map.kludge_to_bg(); map.kludge_to_bg();
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
graphics.backgrounddrawn = false; graphics.backgrounddrawn = false;
mapheld = true; mapheld = true;
graphics.flipmode = graphics.setflipmode; graphics.flipmode = graphics.setflipmode;

View file

@ -118,6 +118,7 @@ void Graphics::init()
footerbuffer = NULL; footerbuffer = NULL;
ghostbuffer = NULL; ghostbuffer = NULL;
towerbg = TowerBG(); towerbg = TowerBG();
titlebg = TowerBG();
trinketr = 0; trinketr = 0;
trinketg = 0; trinketg = 0;
trinketb = 0; trinketb = 0;

View file

@ -230,6 +230,7 @@ public:
SDL_Surface* tempBuffer; SDL_Surface* tempBuffer;
TowerBG towerbg; TowerBG towerbg;
TowerBG titlebg;
SDL_Rect bfont_rect; SDL_Rect bfont_rect;
SDL_Rect tiles_rect; SDL_Rect tiles_rect;

View file

@ -580,6 +580,7 @@ void menuactionpress()
game.colourblindmode = !game.colourblindmode; game.colourblindmode = !game.colourblindmode;
game.savestats(); game.savestats();
graphics.towerbg.tdrawback = true; graphics.towerbg.tdrawback = true;
graphics.titlebg.tdrawback = true;
music.playef(11); music.playef(11);
break; break;
case 1: case 1:
@ -1683,7 +1684,7 @@ void titleinput()
music.playef(18); music.playef(18);
game.screenshake = 10; game.screenshake = 10;
game.flashlight = 5; game.flashlight = 5;
graphics.towerbg.colstate = 10; graphics.titlebg.colstate = 10;
map.nexttowercolour(); map.nexttowercolour();
} }
else else
@ -2381,13 +2382,13 @@ void mapmenuactionpress()
map.bg_to_kludge(); map.bg_to_kludge();
game.kludge_ingametemp = game.currentmenuname; game.kludge_ingametemp = game.currentmenuname;
graphics.towerbg.scrolldir = 0; graphics.titlebg.scrolldir = 0;
graphics.towerbg.colstate = ((int) (graphics.towerbg.colstate / 5)) * 5; graphics.titlebg.colstate = ((int) (graphics.titlebg.colstate / 5)) * 5;
graphics.towerbg.bypos = 0; graphics.titlebg.bypos = 0;
map.nexttowercolour(); map.nexttowercolour();
// Fix delta rendering glitch // Fix delta rendering glitch
graphics.updatetowerbackground(graphics.towerbg); graphics.updatetowerbackground(graphics.titlebg);
titleupdatetextcol(); titleupdatetextcol();
break; break;
} }
@ -2536,11 +2537,11 @@ void gamecompleteinput()
//Do this before we update map.bypos //Do this before we update map.bypos
if (!game.colourblindmode) if (!game.colourblindmode)
{ {
graphics.updatetowerbackground(graphics.towerbg); graphics.updatetowerbackground(graphics.titlebg);
} }
//Do these here because input comes first //Do these here because input comes first
graphics.towerbg.bypos += graphics.towerbg.bscroll; graphics.titlebg.bypos += graphics.titlebg.bscroll;
game.oldcreditposition = game.creditposition; game.oldcreditposition = game.creditposition;
if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip)) if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip))
@ -2556,7 +2557,7 @@ void gamecompleteinput()
} }
else else
{ {
graphics.towerbg.bscroll = +7; graphics.titlebg.bscroll = +7;
} }
game.press_action = true; game.press_action = true;
} }

View file

@ -27,15 +27,15 @@ void titleupdatetextcol()
void titlelogic() void titlelogic()
{ {
//Misc //Misc
//map.updatetowerglow(graphics.towerbg); //map.updatetowerglow(graphics.titlebg);
help.updateglow(); help.updateglow();
graphics.towerbg.bypos -= 2; graphics.titlebg.bypos -= 2;
graphics.towerbg.bscroll = -2; graphics.titlebg.bscroll = -2;
if (!game.colourblindmode) if (!game.colourblindmode)
{ {
graphics.updatetowerbackground(graphics.towerbg); graphics.updatetowerbackground(graphics.titlebg);
} }
if (!game.menustart) if (!game.menustart)
@ -149,10 +149,10 @@ void maplogic()
void gamecompletelogic() void gamecompletelogic()
{ {
//Misc //Misc
map.updatetowerglow(graphics.towerbg); map.updatetowerglow(graphics.titlebg);
help.updateglow(); help.updateglow();
graphics.crewframe = 0; graphics.crewframe = 0;
graphics.towerbg.scrolldir = 1; graphics.titlebg.scrolldir = 1;
graphics.updatetitlecolours(); graphics.updatetitlecolours();
graphics.col_tr = map.r - (help.glow / 4) - fRandom() * 4; graphics.col_tr = map.r - (help.glow / 4) - fRandom() * 4;
@ -169,11 +169,11 @@ void gamecompletelogic()
if (game.creditposition <= -Credits::creditmaxposition) if (game.creditposition <= -Credits::creditmaxposition)
{ {
game.creditposition = -Credits::creditmaxposition; game.creditposition = -Credits::creditmaxposition;
graphics.towerbg.bscroll = 0; graphics.titlebg.bscroll = 0;
} }
else if (!game.press_action) else if (!game.press_action)
{ {
graphics.towerbg.bscroll = +1; graphics.titlebg.bscroll = +1;
} }
if (graphics.fademode == 1) if (graphics.fademode == 1)
@ -182,8 +182,8 @@ void gamecompletelogic()
graphics.showcutscenebars = false; graphics.showcutscenebars = false;
graphics.cutscenebarspos = 0; graphics.cutscenebarspos = 0;
graphics.oldcutscenebarspos = 0; graphics.oldcutscenebarspos = 0;
graphics.towerbg.scrolldir = 0; graphics.titlebg.scrolldir = 0;
graphics.towerbg.bypos = 0; graphics.titlebg.bypos = 0;
//Return to game //Return to game
game.gamestate = GAMECOMPLETE2; game.gamestate = GAMECOMPLETE2;
graphics.fademode = 4; graphics.fademode = 4;
@ -193,7 +193,7 @@ void gamecompletelogic()
void gamecompletelogic2() void gamecompletelogic2()
{ {
//Misc //Misc
map.updatetowerglow(graphics.towerbg); map.updatetowerglow(graphics.titlebg);
help.updateglow(); help.updateglow();
game.creditposdelay--; game.creditposdelay--;
@ -222,7 +222,7 @@ void gamecompletelogic2()
game.savetele(); game.savetele();
music.currentsong=tmp; music.currentsong=tmp;
//Return to game //Return to game
graphics.towerbg.colstate = 10; graphics.titlebg.colstate = 10;
game.gamestate = TITLEMODE; game.gamestate = TITLEMODE;
graphics.fademode = 4; graphics.fademode = 4;
FILESYSTEM_unmountassets(); // should be before music.playef(18) FILESYSTEM_unmountassets(); // should be before music.playef(18)

View file

@ -628,10 +628,10 @@ void mapclass::updatetowerglow(TowerBG& bg_obj)
void mapclass::nexttowercolour() void mapclass::nexttowercolour()
{ {
graphics.towerbg.colstate+=5; graphics.titlebg.colstate+=5;
if (graphics.towerbg.colstate >= 30) graphics.towerbg.colstate = 0; if (graphics.titlebg.colstate >= 30) graphics.titlebg.colstate = 0;
int check = graphics.towerbg.colstate % 5; //current state of phase int check = graphics.titlebg.colstate % 5; //current state of phase
int cmode = (graphics.towerbg.colstate - check) / 5; // current colour transition int cmode = (graphics.titlebg.colstate - check) / 5; // current colour transition
switch(cmode) switch(cmode)
{ {
@ -655,15 +655,15 @@ void mapclass::nexttowercolour()
break; break;
} }
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
} }
void mapclass::settowercolour(int t) void mapclass::settowercolour(int t)
{ {
graphics.towerbg.colstate=t*5; graphics.titlebg.colstate=t*5;
if (graphics.towerbg.colstate >= 30) graphics.towerbg.colstate = 0; if (graphics.titlebg.colstate >= 30) graphics.titlebg.colstate = 0;
int check = graphics.towerbg.colstate % 5; //current state of phase int check = graphics.titlebg.colstate % 5; //current state of phase
int cmode = (graphics.towerbg.colstate - check) / 5; // current colour transition int cmode = (graphics.titlebg.colstate - check) / 5; // current colour transition
switch(cmode) switch(cmode)
{ {
@ -687,7 +687,7 @@ void mapclass::settowercolour(int t)
break; break;
} }
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
} }
bool mapclass::spikecollide(int x, int y) bool mapclass::spikecollide(int x, int y)

View file

@ -1182,7 +1182,7 @@ void titlerender()
} }
else else
{ {
if(!game.colourblindmode) graphics.drawtowerbackground(graphics.towerbg); if(!game.colourblindmode) graphics.drawtowerbackground(graphics.titlebg);
tr = graphics.col_tr; tr = graphics.col_tr;
tg = graphics.col_tg; tg = graphics.col_tg;
@ -1211,7 +1211,7 @@ void gamecompleterender()
{ {
FillRect(graphics.backBuffer, 0x000000); FillRect(graphics.backBuffer, 0x000000);
if(!game.colourblindmode) graphics.drawtowerbackground(graphics.towerbg); if(!game.colourblindmode) graphics.drawtowerbackground(graphics.titlebg);
tr = graphics.col_tr; tr = graphics.col_tr;
tg = graphics.col_tg; tg = graphics.col_tg;

View file

@ -2642,7 +2642,7 @@ void scriptclass::resetgametomenu()
graphics.flipmode = false; graphics.flipmode = false;
obj.entities.clear(); obj.entities.clear();
graphics.fademode = 4; graphics.fademode = 4;
graphics.towerbg.tdrawback = true; graphics.titlebg.tdrawback = true;
game.createmenu(Menu::gameover); game.createmenu(Menu::gameover);
} }

View file

@ -3292,7 +3292,7 @@ void editorrender()
{ {
if(!game.colourblindmode) if(!game.colourblindmode)
{ {
graphics.drawtowerbackground(graphics.towerbg); graphics.drawtowerbackground(graphics.titlebg);
} }
else else
{ {
@ -3679,8 +3679,8 @@ void editorlogic()
game.shouldreturntoeditor = false; game.shouldreturntoeditor = false;
} }
graphics.towerbg.bypos -= 2; graphics.titlebg.bypos -= 2;
graphics.towerbg.bscroll = -2; graphics.titlebg.bscroll = -2;
ed.entframedelay--; ed.entframedelay--;
if(ed.entframedelay<=0) if(ed.entframedelay<=0)
@ -3740,14 +3740,14 @@ void editorlogic()
} }
else if (!game.colourblindmode) else if (!game.colourblindmode)
{ {
graphics.updatetowerbackground(graphics.towerbg); graphics.updatetowerbackground(graphics.titlebg);
} }
if (graphics.fademode == 1) if (graphics.fademode == 1)
{ {
//Return to game //Return to game
map.nexttowercolour(); map.nexttowercolour();
graphics.towerbg.colstate = 10; graphics.titlebg.colstate = 10;
game.gamestate = TITLEMODE; game.gamestate = TITLEMODE;
script.hardreset(); script.hardreset();
graphics.fademode = 4; graphics.fademode = 4;

View file

@ -211,6 +211,7 @@ int main(int argc, char *argv[])
map.ypos = (700-29) * 8; map.ypos = (700-29) * 8;
graphics.towerbg.bypos = map.ypos / 2; graphics.towerbg.bypos = map.ypos / 2;
graphics.titlebg.bypos = map.ypos / 2;
//Moved screensetting init here from main menu V2.1 //Moved screensetting init here from main menu V2.1
int width = 320; int width = 320;
@ -262,6 +263,12 @@ int main(int argc, char *argv[])
graphics.towerbg.buffer_lerp = CREATE_SURFACE(320 + 16, 240 + 16); graphics.towerbg.buffer_lerp = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.towerbg.buffer_lerp, SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(graphics.towerbg.buffer_lerp, SDL_BLENDMODE_NONE);
graphics.titlebg.buffer = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.titlebg.buffer, SDL_BLENDMODE_NONE);
graphics.titlebg.buffer_lerp = CREATE_SURFACE(320 + 16, 240 + 16);
SDL_SetSurfaceBlendMode(graphics.titlebg.buffer_lerp, SDL_BLENDMODE_NONE);
graphics.tempBuffer = CREATE_SURFACE(320, 240); graphics.tempBuffer = CREATE_SURFACE(320, 240);
SDL_SetSurfaceBlendMode(graphics.tempBuffer, SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(graphics.tempBuffer, SDL_BLENDMODE_NONE);