for(int i = 0; i < 15; ++i)
{
- ia_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ ia_tiles[i].resize(width+1, 0);
ia_tiles[i][width] = (unsigned int) '\0';
+
for(int y = 0; y < width; ++y)
ia_tiles[i][y] = 0;
- ia_tiles[i][width] = (unsigned int) '\0';
- bg_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ bg_tiles[i].resize(width+1, 0);
bg_tiles[i][width] = (unsigned int) '\0';
for(int y = 0; y < width; ++y)
bg_tiles[i][y] = 0;
- bg_tiles[i][width] = (unsigned int) '\0';
- fg_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ fg_tiles[i].resize(width+1, 0);
fg_tiles[i][width] = (unsigned int) '\0';
for(int y = 0; y < width; ++y)
fg_tiles[i][y] = 0;
- fg_tiles[i][width] = (unsigned int) '\0';
}
}
for(int i = 0; i < 15; ++i)
{
- ia_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
- bg_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
- fg_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
+ ia_tiles[i].resize(width + 1, 0);
+ bg_tiles[i].resize(width + 1, 0);
+ fg_tiles[i].resize(width + 1, 0);
}
int i = 0;
Level::cleanup()
{
for(int i=0; i < 15; ++i)
- free(bg_tiles[i]);
- for(int i=0; i < 15; ++i)
- free(ia_tiles[i]);
- for(int i=0; i < 15; ++i)
- free(fg_tiles[i]);
+ {
+ bg_tiles[i].clear();
+ ia_tiles[i].clear();
+ fg_tiles[i].clear();
+ }
name.clear();
author.clear();
std::string song_title;
std::string bkgd_image;
std::string particle_system;
- unsigned int* bg_tiles[15]; /* Tiles in the background */
- unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
- unsigned int* fg_tiles[15]; /* Tiles in the foreground */
+ std::vector<unsigned int> bg_tiles[15]; /* Tiles in the background */
+ std::vector<unsigned int> ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
+ std::vector<unsigned int> fg_tiles[15]; /* Tiles in the foreground */
int time_left;
Color bkgd_top;
Color bkgd_bottom;
struct Color
{
-int red, green, blue;
+ Color()
+ : red(0), green(0), blue(0)
+ {}
+
+ Color(int red_, int green_, int blue_)
+ : red(red_), green(green_), blue(blue_)
+ {}
+
+ int red, green, blue;
};
void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a);