1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01: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;
//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};
int s2 = 4+(fRandom()*4);
stars.push_back(s);
starsspeed.push_back(s2);
stars[i] = s;
starsspeed[i] = s2;
}
for (int i = 0; i < numbackboxes; i++)
{
SDL_Rect bb;
int bvx = 0;
int bvy = 0;
@ -64,10 +67,10 @@ void Graphics::init()
setRect(bb, fRandom() * 320, fRandom() * 240, 12, 32) ;
}
float bint = 0.5 + ((fRandom() * 100) / 200);
backboxes.push_back(bb);
backboxvx.push_back(bvx);
backboxvy.push_back(bvy);
backboxint.push_back(bint);
backboxes[i] = bb;
backboxvx[i] = bvx;
backboxvy[i] = bvy;
backboxint[i] = bint;
}
backoffset = 0;
backgrounddrawn = false;
@ -1938,7 +1941,7 @@ void Graphics::drawbackground( int t )
case 1:
//Starfield
FillRect(backBuffer,0x00000);
for (int i = 0; i < 50; i++)
for (int i = 0; i < numstars; i++)
{
stars[i].w = 2;
stars[i].h = 2;
@ -2022,7 +2025,7 @@ void Graphics::drawbackground( int t )
}
FillRect(backBuffer,bcol2);
for (int i = 0; i < 18; i++)
for (int i = 0; i < numbackboxes; i++)
{
switch(rcol)
{
@ -2168,7 +2171,7 @@ void Graphics::drawbackground( int t )
case 6:
//Final Starfield
FillRect(backBuffer,0x000000);
for (int i = 0; i < 50; i++)
for (int i = 0; i < numstars; i++)
{
stars[i].w = 2;
stars[i].h = 2;
@ -2227,7 +2230,7 @@ void Graphics::updatebackground(int t)
{
case 1:
//Starfield
for (int i = 0; i < 50; i++)
for (int i = 0; i < numstars; i++)
{
stars[i].w = 2;
stars[i].h = 2;
@ -2254,7 +2257,7 @@ void Graphics::updatebackground(int t)
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].y += backboxvy[i];
@ -2370,7 +2373,7 @@ void Graphics::updatebackground(int t)
break;
case 6:
//Final Starfield
for (int i = 0; i < 50; i++)
for (int i = 0; i < numstars; i++)
{
stars[i].w = 2;
stars[i].h = 2;

View file

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