mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 18:39:45 +01:00
Turn tower vectors into plain arrays
Also, the arrays are statically allocated. I forgot to do this when we were statically allocating things earlier, but better late than never.
This commit is contained in:
parent
9dcda17978
commit
adca6a122a
2 changed files with 20 additions and 44 deletions
|
@ -8,26 +8,14 @@ towerclass::towerclass()
|
||||||
{
|
{
|
||||||
minitowermode = false;
|
minitowermode = false;
|
||||||
//We init the lookup table:
|
//We init the lookup table:
|
||||||
for (int i = 0; i < 700; i++)
|
for (size_t i = 0; i < SDL_arraysize(vmult); i++)
|
||||||
{
|
{
|
||||||
vmult.push_back(int(i * 40));
|
vmult[i] = i * 40;
|
||||||
}
|
}
|
||||||
//We create a blank map
|
//We create a blank map
|
||||||
for (int j = 0; j < 700; j++)
|
SDL_memset(contents, 0, sizeof(contents));
|
||||||
{
|
SDL_memset(back, 0, sizeof(back));
|
||||||
for (int i = 0; i < 40; i++)
|
SDL_memset(minitower, 0, sizeof(minitower));
|
||||||
{
|
|
||||||
contents.push_back(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int j = 0; j < 120; j++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 40; i++)
|
|
||||||
{
|
|
||||||
back.push_back(0);
|
|
||||||
minitower.push_back(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadbackground();
|
loadbackground();
|
||||||
loadmap();
|
loadmap();
|
||||||
|
@ -108,7 +96,7 @@ void towerclass::loadminitower1()
|
||||||
{
|
{
|
||||||
//Loads the first minitower into the array.
|
//Loads the first minitower into the array.
|
||||||
#if !defined(MAKEANDPLAY)
|
#if !defined(MAKEANDPLAY)
|
||||||
const int tmap[] = {
|
static const int tmap[] = {
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
|
@ -211,17 +199,16 @@ void towerclass::loadminitower1()
|
||||||
12,12,12,12,12,12,12,12,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
const int tmap[100*40] = {0};
|
static const int tmap[100*40] = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
minitower.clear();
|
SDL_memcpy(minitower, tmap, sizeof(minitower));
|
||||||
minitower.insert(minitower.end(), tmap, tmap + 100*40);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void towerclass::loadminitower2()
|
void towerclass::loadminitower2()
|
||||||
{
|
{
|
||||||
#if !defined(MAKEANDPLAY)
|
#if !defined(MAKEANDPLAY)
|
||||||
const int tmap[] = {
|
static const int tmap[] = {
|
||||||
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
12,12,21,10,0,0,0,0,0,0,0,0,0,0,0,0,11,20,21,10,0,20,21,28,28,20,21,28,28,20,12,12,12,12,12,12,12,12,12,12,
|
||||||
|
@ -324,18 +311,17 @@ void towerclass::loadminitower2()
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,21,28,28,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,21,28,28,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
const int tmap[100*40] = {0};
|
static const int tmap[100*40] = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
minitower.clear();
|
SDL_memcpy(minitower, tmap, sizeof(minitower));
|
||||||
minitower.insert(minitower.end(), tmap, tmap + 100*40);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void towerclass::loadbackground()
|
void towerclass::loadbackground()
|
||||||
{
|
{
|
||||||
//Loads the background into the array.
|
//Loads the background into the array.
|
||||||
const int tmap[] = {
|
static const int tmap[] = {
|
||||||
1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,4,0,0,
|
1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,4,0,0,
|
||||||
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,4,0,
|
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,4,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,4,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,4,
|
||||||
|
@ -457,15 +443,14 @@ void towerclass::loadbackground()
|
||||||
1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,3,1,1,2,3,1,1,2,0,0,0,0,
|
1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,3,1,1,2,3,1,1,2,0,0,0,0,
|
||||||
1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,3,2,0,0,3,2,0,0,0,0,0,
|
1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,2,0,0,0,0,3,2,0,0,3,2,0,0,0,0,0,
|
||||||
};
|
};
|
||||||
back.clear();
|
SDL_memcpy(back, tmap, sizeof(back));
|
||||||
back.insert(back.end(), tmap, tmap + 120*40);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void towerclass::loadmap()
|
void towerclass::loadmap()
|
||||||
{
|
{
|
||||||
//Loads the map into the array.
|
//Loads the map into the array.
|
||||||
#if !defined(MAKEANDPLAY)
|
#if !defined(MAKEANDPLAY)
|
||||||
const int tmap[] = {
|
static const int tmap[] = {
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
|
@ -1168,9 +1153,8 @@ void towerclass::loadmap()
|
||||||
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
const int tmap[700*40] = {0};
|
static const int tmap[700*40] = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
contents.clear();
|
SDL_memcpy(contents, tmap, sizeof(contents));
|
||||||
contents.insert(contents.end(), tmap, tmap + 700*40);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#ifndef TOWER_H
|
#ifndef TOWER_H
|
||||||
#define TOWER_H
|
#define TOWER_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class towerclass
|
class towerclass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -23,15 +20,10 @@ public:
|
||||||
|
|
||||||
void loadmap();
|
void loadmap();
|
||||||
|
|
||||||
//public var back:Array = new Array();
|
int back[40 * 120];
|
||||||
//public var contents:Array = new Array();
|
int contents[40 * 700];
|
||||||
//public var minitower:Array = new Array();
|
int minitower[40 * 100];
|
||||||
//public var vmult:Array = new Array();
|
int vmult[40 * 700];
|
||||||
|
|
||||||
std::vector<int> back;
|
|
||||||
std::vector<int> contents;
|
|
||||||
std::vector<int> minitower;
|
|
||||||
std::vector<int> vmult;
|
|
||||||
|
|
||||||
bool minitowermode;
|
bool minitowermode;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue