1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 15:38:30 +02:00

Turn star and backbox vectors into arrays

There's always 50 stars and always 18 backboxes, there's no reason to
have them be vectors.
This commit is contained in:
Misa 2020-07-03 02:31:13 -07:00 committed by Ethan Lee
parent 4c6ab6e6b7
commit 450cf1a31e
2 changed files with 24 additions and 19 deletions

View File

@ -39,13 +39,16 @@ void Graphics::init()
setflipmode = false; setflipmode = false;
//Background inits //Background inits
for (int i = 0; i < 50; i++) for (int i = 0; i < numstars; i++)
{ {
SDL_Rect s = {Sint16(fRandom() * 320), Sint16(fRandom() * 240), 2, 2}; SDL_Rect s = {Sint16(fRandom() * 320), Sint16(fRandom() * 240), 2, 2};
int s2 = 4+(fRandom()*4); int s2 = 4+(fRandom()*4);
stars.push_back(s); stars[i] = s;
starsspeed.push_back(s2); starsspeed[i] = s2;
}
for (int i = 0; i < numbackboxes; i++)
{
SDL_Rect bb; SDL_Rect bb;
int bvx = 0; int bvx = 0;
int bvy = 0; int bvy = 0;
@ -64,10 +67,10 @@ void Graphics::init()
setRect(bb, fRandom() * 320, fRandom() * 240, 12, 32) ; setRect(bb, fRandom() * 320, fRandom() * 240, 12, 32) ;
} }
float bint = 0.5 + ((fRandom() * 100) / 200); float bint = 0.5 + ((fRandom() * 100) / 200);
backboxes.push_back(bb); backboxes[i] = bb;
backboxvx.push_back(bvx); backboxvx[i] = bvx;
backboxvy.push_back(bvy); backboxvy[i] = bvy;
backboxint.push_back(bint); backboxint[i] = bint;
} }
backoffset = 0; backoffset = 0;
backgrounddrawn = false; backgrounddrawn = false;
@ -1938,7 +1941,7 @@ void Graphics::drawbackground( int t )
case 1: case 1:
//Starfield //Starfield
FillRect(backBuffer,0x00000); FillRect(backBuffer,0x00000);
for (int i = 0; i < 50; i++) for (int i = 0; i < numstars; i++)
{ {
stars[i].w = 2; stars[i].w = 2;
stars[i].h = 2; stars[i].h = 2;
@ -2022,7 +2025,7 @@ void Graphics::drawbackground( int t )
} }
FillRect(backBuffer,bcol2); FillRect(backBuffer,bcol2);
for (int i = 0; i < 18; i++) for (int i = 0; i < numbackboxes; i++)
{ {
switch(rcol) switch(rcol)
{ {
@ -2168,7 +2171,7 @@ void Graphics::drawbackground( int t )
case 6: case 6:
//Final Starfield //Final Starfield
FillRect(backBuffer,0x000000); FillRect(backBuffer,0x000000);
for (int i = 0; i < 50; i++) for (int i = 0; i < numstars; i++)
{ {
stars[i].w = 2; stars[i].w = 2;
stars[i].h = 2; stars[i].h = 2;
@ -2227,7 +2230,7 @@ void Graphics::updatebackground(int t)
{ {
case 1: case 1:
//Starfield //Starfield
for (int i = 0; i < 50; i++) for (int i = 0; i < numstars; i++)
{ {
stars[i].w = 2; stars[i].w = 2;
stars[i].h = 2; stars[i].h = 2;
@ -2254,7 +2257,7 @@ void Graphics::updatebackground(int t)
if (spcol >= 12) spcol = 0; if (spcol >= 12) spcol = 0;
} }
} }
for (int i = 0; i < 18; i++) for (int i = 0; i < numbackboxes; i++)
{ {
backboxes[i].x += backboxvx[i]; backboxes[i].x += backboxvx[i];
backboxes[i].y += backboxvy[i]; backboxes[i].y += backboxvy[i];
@ -2370,7 +2373,7 @@ void Graphics::updatebackground(int t)
break; break;
case 6: case 6:
//Final Starfield //Final Starfield
for (int i = 0; i < 50; i++) for (int i = 0; i < numstars; i++)
{ {
stars[i].w = 2; stars[i].w = 2;
stars[i].h = 2; stars[i].h = 2;

View File

@ -280,14 +280,16 @@ public:
int cutscenebarspos; int cutscenebarspos;
int oldcutscenebarspos; int oldcutscenebarspos;
std::vector<SDL_Rect> stars; static const int numstars = 50;
std::vector<int> starsspeed; SDL_Rect stars[numstars];
int starsspeed[numstars];
static const int numbackboxes = 18;
int spcol, spcoldel; int spcol, spcoldel;
std::vector<SDL_Rect> backboxes; SDL_Rect backboxes[numbackboxes];
std::vector<int> backboxvx; int backboxvx[numbackboxes];
std::vector<int> backboxvy; int backboxvy[numbackboxes];
std::vector<float> backboxint; float backboxint[numbackboxes];
int warpskip, warpfcol, warpbcol; int warpskip, warpfcol, warpbcol;