mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Refactor tower background to use a separate object instead
Previously, the tower background was controlled by a disparate set of attributes on Graphics and mapclass, and wasn't really encapsulated. (If that's what that word means, I don't particularly care about object-oriented lingo.) But now, all relevant things that a tower background has has been put into a TowerBG struct, so it will be easy to make multiple copies without having to duplicate the code that handles it.
This commit is contained in:
@@ -16,7 +16,6 @@ mapclass::mapclass()
|
||||
r = 196;
|
||||
g = 196;
|
||||
b = 196;
|
||||
colstate = 0;
|
||||
colstatedelay = 0;
|
||||
colsuperstate = 0;
|
||||
spikeleveltop = 0;
|
||||
@@ -82,15 +81,11 @@ mapclass::mapclass()
|
||||
|
||||
ypos = 0;
|
||||
oldypos = 0;
|
||||
bypos = 0;
|
||||
|
||||
background = 0;
|
||||
cameramode = 0;
|
||||
cameraseek = 0;
|
||||
minitowermode = false;
|
||||
scrolldir = 0;
|
||||
tdrawback = false;
|
||||
bscroll = 0;
|
||||
roomtexton = false;
|
||||
kludge_bypos = 0;
|
||||
kludge_colstate = 0;
|
||||
@@ -581,15 +576,15 @@ void mapclass::setcol(const int r1, const int g1, const int b1 , const int r2, c
|
||||
b = intpol(b1, b2, c / 5);
|
||||
}
|
||||
|
||||
void mapclass::updatetowerglow()
|
||||
void mapclass::updatetowerglow(TowerBG& bg_obj)
|
||||
{
|
||||
if (colstatedelay <= 0 || colsuperstate > 0)
|
||||
{
|
||||
if (colsuperstate > 0) colstate--;
|
||||
colstate++;
|
||||
if (colstate >= 30) colstate = 0;
|
||||
int check = colstate % 5; //current state of phase
|
||||
int cmode = (colstate - check) / 5; // current colour transition
|
||||
if (colsuperstate > 0) bg_obj.colstate--;
|
||||
bg_obj.colstate++;
|
||||
if (bg_obj.colstate >= 30) bg_obj.colstate = 0;
|
||||
int check = bg_obj.colstate % 5; //current state of phase
|
||||
int cmode = (bg_obj.colstate - check) / 5; // current colour transition
|
||||
|
||||
switch(cmode)
|
||||
{
|
||||
@@ -623,7 +618,7 @@ void mapclass::updatetowerglow()
|
||||
}
|
||||
if (colsuperstate > 0) colstatedelay = 0;
|
||||
|
||||
tdrawback = true;
|
||||
bg_obj.tdrawback = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -633,10 +628,10 @@ void mapclass::updatetowerglow()
|
||||
|
||||
void mapclass::nexttowercolour()
|
||||
{
|
||||
colstate+=5;
|
||||
if (colstate >= 30) colstate = 0;
|
||||
int check = colstate % 5; //current state of phase
|
||||
int cmode = (colstate - check) / 5; // current colour transition
|
||||
graphics.towerbg.colstate+=5;
|
||||
if (graphics.towerbg.colstate >= 30) graphics.towerbg.colstate = 0;
|
||||
int check = graphics.towerbg.colstate % 5; //current state of phase
|
||||
int cmode = (graphics.towerbg.colstate - check) / 5; // current colour transition
|
||||
|
||||
switch(cmode)
|
||||
{
|
||||
@@ -660,15 +655,15 @@ void mapclass::nexttowercolour()
|
||||
break;
|
||||
}
|
||||
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
}
|
||||
|
||||
void mapclass::settowercolour(int t)
|
||||
{
|
||||
colstate=t*5;
|
||||
if (colstate >= 30) colstate = 0;
|
||||
int check = colstate % 5; //current state of phase
|
||||
int cmode = (colstate - check) / 5; // current colour transition
|
||||
graphics.towerbg.colstate=t*5;
|
||||
if (graphics.towerbg.colstate >= 30) graphics.towerbg.colstate = 0;
|
||||
int check = graphics.towerbg.colstate % 5; //current state of phase
|
||||
int cmode = (graphics.towerbg.colstate - check) / 5; // current colour transition
|
||||
|
||||
switch(cmode)
|
||||
{
|
||||
@@ -692,7 +687,7 @@ void mapclass::settowercolour(int t)
|
||||
break;
|
||||
}
|
||||
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
}
|
||||
|
||||
bool mapclass::spikecollide(int x, int y)
|
||||
@@ -849,7 +844,7 @@ void mapclass::resetplayer()
|
||||
ypos = 0;
|
||||
}
|
||||
oldypos = ypos;
|
||||
bypos = ypos / 2;
|
||||
graphics.towerbg.bypos = ypos / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,9 +1256,9 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
|
||||
ypos = (700-29) * 8;
|
||||
oldypos = ypos;
|
||||
bypos = ypos / 2;
|
||||
graphics.towerbg.bypos = ypos / 2;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;
|
||||
}
|
||||
else if (ry == 104)
|
||||
@@ -1271,9 +1266,9 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
//you've entered from the top floor
|
||||
ypos = 0;
|
||||
oldypos = ypos;
|
||||
bypos = 0;
|
||||
graphics.towerbg.bypos = 0;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;
|
||||
}
|
||||
}
|
||||
@@ -1351,17 +1346,17 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
break;
|
||||
}
|
||||
case 3: //The Tower
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
minitowermode = false;
|
||||
tower.minitowermode = false;
|
||||
bscroll = 0;
|
||||
scrolldir = 0;
|
||||
graphics.towerbg.bscroll = 0;
|
||||
graphics.towerbg.scrolldir = 0;
|
||||
|
||||
roomname = "The Tower";
|
||||
tileset = 1;
|
||||
background = 3;
|
||||
towermode = true;
|
||||
//bypos = 0; ypos = 0; cameramode = 0;
|
||||
//graphics.towerbg.bypos = 0; ypos = 0; cameramode = 0;
|
||||
|
||||
//All the entities for here are just loaded here; it's essentially one room after all
|
||||
|
||||
@@ -1450,11 +1445,11 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
break;
|
||||
}
|
||||
case 7: //Final Level, Tower 1
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
minitowermode = true;
|
||||
tower.minitowermode = true;
|
||||
bscroll = 0;
|
||||
scrolldir = 1;
|
||||
graphics.towerbg.bscroll = 0;
|
||||
graphics.towerbg.scrolldir = 1;
|
||||
|
||||
roomname = "Panic Room";
|
||||
tileset = 1;
|
||||
@@ -1465,18 +1460,18 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
|
||||
ypos = 0;
|
||||
oldypos = 0;
|
||||
bypos = 0;
|
||||
graphics.towerbg.bypos = 0;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;
|
||||
break;
|
||||
case 8: //Final Level, Tower 1 (reentered from below)
|
||||
{
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
minitowermode = true;
|
||||
tower.minitowermode = true;
|
||||
bscroll = 0;
|
||||
scrolldir = 1;
|
||||
graphics.towerbg.bscroll = 0;
|
||||
graphics.towerbg.scrolldir = 1;
|
||||
|
||||
roomname = "Panic Room";
|
||||
tileset = 1;
|
||||
@@ -1495,18 +1490,18 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
|
||||
ypos = (100-29) * 8;
|
||||
oldypos = ypos;
|
||||
bypos = ypos/2;
|
||||
graphics.towerbg.bypos = ypos/2;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;}
|
||||
break;
|
||||
case 9: //Final Level, Tower 2
|
||||
{
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
minitowermode = true;
|
||||
tower.minitowermode = true;
|
||||
bscroll = 0;
|
||||
scrolldir = 0;
|
||||
graphics.towerbg.bscroll = 0;
|
||||
graphics.towerbg.scrolldir = 0;
|
||||
final_colorframe = 2;
|
||||
|
||||
roomname = "The Final Challenge";
|
||||
@@ -1540,20 +1535,20 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
|
||||
ypos = (100-29) * 8;
|
||||
oldypos = ypos;
|
||||
bypos = ypos/2;
|
||||
graphics.towerbg.bypos = ypos/2;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;
|
||||
break;
|
||||
}
|
||||
case 10: //Final Level, Tower 2
|
||||
{
|
||||
|
||||
tdrawback = true;
|
||||
graphics.towerbg.tdrawback = true;
|
||||
minitowermode = true;
|
||||
tower.minitowermode = true;
|
||||
bscroll = 0;
|
||||
scrolldir = 0;
|
||||
graphics.towerbg.bscroll = 0;
|
||||
graphics.towerbg.scrolldir = 0;
|
||||
final_colorframe = 2;
|
||||
|
||||
roomname = "The Final Challenge";
|
||||
@@ -1579,9 +1574,9 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
|
||||
ypos = 0;
|
||||
oldypos = 0;
|
||||
bypos = 0;
|
||||
graphics.towerbg.bypos = 0;
|
||||
cameramode = 0;
|
||||
colstate = 0;
|
||||
graphics.towerbg.colstate = 0;
|
||||
colsuperstate = 0;
|
||||
break;
|
||||
}
|
||||
@@ -2114,3 +2109,17 @@ void mapclass::twoframedelayfix()
|
||||
script.dontrunnextframe = true;
|
||||
}
|
||||
}
|
||||
|
||||
void mapclass::bg_to_kludge()
|
||||
{
|
||||
kludge_bypos = graphics.towerbg.bypos;
|
||||
kludge_colstate = graphics.towerbg.colstate;
|
||||
kludge_scrolldir = graphics.towerbg.scrolldir;
|
||||
}
|
||||
|
||||
void mapclass::kludge_to_bg()
|
||||
{
|
||||
graphics.towerbg.bypos = kludge_bypos;
|
||||
graphics.towerbg.colstate = kludge_colstate;
|
||||
graphics.towerbg.scrolldir = kludge_scrolldir;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user