using namespace std;
-texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
-
st_subset::st_subset()
{
levels = 0;
bkgd_red = 0;
bkgd_green = 0;
bkgd_blue = 0;
+ endpos = 0;
for(int i = 0; i < 15; ++i)
{
}
}
-/* Load data for this level: */
-/* Returns -1, if the loading of the level failed. */
int
-Level::load(const char *subset, int level)
+Level::load(const std::string& subset, int level)
{
char filename[1024];
- /* Load data file: */
-
- snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset, level);
+ // Load data file:
+ snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset.c_str(), level);
if(!faccessible(filename))
- snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset, level);
+ snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset.c_str(), level);
return load(filename);
}
}
}
- // FIXME: Set the global gravity to the latest loaded level's gravity
- ::gravity = gravity;
-
// Mark the end position of this level!
// FIXME: -10 is a rather random value, we still need some kind of
// real levelend gola
badguy_data.clear();
}
-/* Load graphics: */
-
void
Level::load_gfx()
{
- level_load_image(&img_brick[0],theme,"brick0.png", IGNORE_ALPHA);
- level_load_image(&img_brick[1],theme,"brick1.png", IGNORE_ALPHA);
-
- level_load_image(&img_solid[0],theme,"solid0.png", USE_ALPHA);
- level_load_image(&img_solid[1],theme,"solid1.png", USE_ALPHA);
- level_load_image(&img_solid[2],theme,"solid2.png", USE_ALPHA);
- level_load_image(&img_solid[3],theme,"solid3.png", USE_ALPHA);
-
- level_load_image(&img_bkgd_tile[0][0],theme,"bkgd-00.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[0][1],theme,"bkgd-01.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[0][2],theme,"bkgd-02.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[0][3],theme,"bkgd-03.png", USE_ALPHA);
-
- level_load_image(&img_bkgd_tile[1][0],theme,"bkgd-10.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[1][1],theme,"bkgd-11.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[1][2],theme,"bkgd-12.png", USE_ALPHA);
- level_load_image(&img_bkgd_tile[1][3],theme,"bkgd-13.png", USE_ALPHA);
-
if(!bkgd_image.empty())
{
char fname[1024];
}
else
{
- /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */#
- level_load_image(&img_bkgd, theme,"solid0.png", IGNORE_ALPHA);
+ /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */
+ load_image(&img_bkgd, theme,"solid0.png", IGNORE_ALPHA);
}
}
-/* Free graphics data for this level: */
-void level_free_gfx(void)
+void
+Level::free_gfx()
{
- int i;
-
- for (i = 0; i < 2; i++)
- {
- texture_free(&img_brick[i]);
- }
- for (i = 0; i < 4; i++)
- {
- texture_free(&img_solid[i]);
- texture_free(&img_bkgd_tile[0][i]);
- texture_free(&img_bkgd_tile[1][i]);
- }
-
texture_free(&img_bkgd);
}
/* Load a level-specific graphic... */
-
-void level_load_image(texture_type* ptexture, string theme,const char * file, int use_alpha)
+void
+Level::load_image(texture_type* ptexture, string theme,const char * file, int use_alpha)
{
char fname[1024];
}
}
-/* Free music data for this level: */
-
-void level_free_song(void)
+void
+Level::free_song(void)
{
free_music(level_song);
free_music(level_song_fast);
}
-/* Load music: */
-
void
Level::load_song()
{
strlen(song_title.c_str()) + 8 + 5);
song_subtitle = strdup(song_title.c_str());
strcpy(strstr(song_subtitle, "."), "\0");
- sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(), song_subtitle, strstr(song_title.c_str(), "."));
+ sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(),
+ song_subtitle, strstr(song_title.c_str(), "."));
level_song_fast = ::load_song(song_path);
free(song_subtitle);
free(song_path);
return c;
}
-Tile* gettile(float x, float y)
-{
- return TileManager::instance()->get(GameSession::current()->get_level()->gettileid(x, y));
-}
-
-bool issolid(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && tile->solid;
-}
-
-bool isbrick(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && tile->brick;
-}
-
-bool isice(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && tile->ice;
-}
-
-bool isfullbox(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && tile->fullbox;
-}
-
-bool isdistro(float x, float y)
-{
- Tile* tile = gettile(x,y);
- return tile && tile->distro;
-}
-
/* EOF */