player_level_begin(&tux);
set_defaults();
level_free(¤t_level);
- if(level_load(¤t_level,level_subset,level) != 0)
- return 0;
+
+ if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
+ {
+ if(level_load(¤t_level, level_subset) != 0)
+ return 0;
+ }
+ else
+ {
+ if(level_load(¤t_level,level_subset,level) != 0)
+ return 0;
+ }
+
arrays_free();
arrays_init();
activate_bad_guys();
st_gl_mode = mode;
level = levelnb;
- strcpy(level_subset,subset);
/* Init the game: */
arrays_init();
set_defaults();
- if(level_load(¤t_level,level_subset,level) != 0)
- exit(1);
+ strcpy(level_subset,subset);
+
+ if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
+ {
+ if (level_load(¤t_level, level_subset))
+ exit(1);
+ }
+ else
+ {
+ if(level_load(¤t_level, level_subset, level) != 0)
+ exit(1);
+ }
+
level_load_gfx(¤t_level);
activate_bad_guys();
level_load_song(¤t_level);
loadshared();
- if(st_gl_mode == ST_GL_PLAY)
+ if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
levelintro();
-
timer_init(&time_left,YES);
start_timers();
#define ST_GL_PLAY 0
#define ST_GL_TEST 1
#define ST_GL_LOAD_GAME 2
+#define ST_GL_LOAD_LEVEL_FILE 3
extern int game_started;
extern st_level current_level;
int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps;
+char* level_startup_file = 0;
+bool launch_worldmap_mode = false;
+
/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
char *st_dir, *st_save_dir;
extern int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps;
+extern char* level_startup_file;
+extern bool launch_worldmap_mode;
+
/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
extern char *st_dir, *st_save_dir;
/* Returns -1, if the loading of the level failed. */
int level_load(st_level* plevel, char *subset, int level)
{
- int y,x;
- FILE * fi;
- char str[80];
char filename[1024];
- char * line;
/* Load data file: */
snprintf(filename, 1024, "%s/levels/%s/level%d.dat", st_dir, subset, level);
if(!faccessible(filename))
snprintf(filename, 1024, "%s/levels/%s/level%d.dat", DATA_PREFIX, subset, level);
+
+ return level_load(plevel, filename);
+}
+
+int level_load(st_level* plevel, const char* filename)
+{
+ char str[80];
+ int x, y;
+ char * line;
+ FILE * fi;
fi = fopen(filename, "r");
if (fi == NULL)
{
return -1;
}
-
/* Load header info: */
extern texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
int level_load(st_level* plevel, char * subset, int level);
+int level_load(st_level* plevel, const char* filename);
void level_save(st_level* plevel, char * subset, int level);
void level_free(st_level* plevel);
void level_load_gfx(st_level* plevel);
use_fullscreen = YES;
}
+ else if (strcmp(argv[i], "--worldmap") == 0)
+ {
+ launch_worldmap_mode = true;
+ }
else if (strcmp(argv[i], "--show-fps") == 0)
{
/* Use full screen: */
{ /* Show help: */
printf("Super Tux " VERSION "\n\n");
-
+ printf("Usage: %s [OPTIONS] FILENAME", argv[0]);
printf("---------- Command-line options ----------\n\n");
+ printf(" --worldmap - Start in worldmap-mode (EXPERIMENTAL)\n\n");
+
printf(" --opengl - If opengl support was compiled in, this will enable the EXPERIMENTAL OpenGL mode.\n\n");
printf(" --disable-sound - If sound support was compiled in, this will\n disable sound for this session of the game.\n\n");
exit(0);
}
+ else if (argv[i][0] != '-')
+ {
+ level_startup_file = argv[i];
+ }
else
{
/* Unknown - complain! */
April 11, 2000 - March 15, 2004
*/
-
#include "supertux.h"
st_joystick_setup();
st_general_setup();
st_menu();
+
+ if (launch_worldmap_mode)
+ {
+ worldmap_run();
+ }
+ else if (level_startup_file)
+ {
+ gameloop(level_startup_file, 1, ST_GL_LOAD_LEVEL_FILE);
+ }
+ else
+ {
+ done = intro();
- done = intro();
-
- done = 0;
+ done = 0;
- while (!done)
- {
- done = title();
+ while (!done)
+ {
+ done = title();
+ }
}
clearscreen(0, 0, 0);
updatescreen();
-
+
st_shutdown();
return(0);
TileManager::TileManager()
{
lisp_stream_t stream;
- FILE* in = fopen(DATA_PREFIX "tiles/antarctica.scm", "r");
+ FILE* in = fopen(DATA_PREFIX "images/worldmap/antarctica.scm", "r");
assert(in);
lisp_stream_init_file (&stream, in);
lisp_object_t* root_obj = lisp_read (&stream);
{
lisp_object_t* element = lisp_car(cur);
- lisp_dump (element, stdout);
if (strcmp(lisp_symbol(lisp_car(element)), "tile") == 0)
{
int id = 0;
width = 20;
height = 15;
tux_moving = false;
- tilemap.resize(width * height);
-
- tilemap[0] = 5;
- tilemap[1] = 1;
- tilemap[2] = 6;
- tilemap[3] = 1;
- tilemap[4] = 3;
- tilemap[4+20] = 2;
- tilemap[4+40] = 7;
- tilemap[4+60] = 2;
- tilemap[4+80] = 4;
texture_load(&tux_sprite, DATA_PREFIX "/images/worldmap/tux.png", USE_ALPHA);
input_direction = NONE;
tux_direction = NONE;
enter_level = false;
+
+ load_map();
}
WorldMap::~WorldMap()
}
void
+WorldMap::load_map()
+{
+ tilemap.resize(width * height);
+
+ tilemap[0] = 5;
+ tilemap[1] = 1;
+ tilemap[2] = 6;
+ tilemap[3] = 1;
+ tilemap[4] = 3;
+ tilemap[4+20] = 2;
+ tilemap[4+40] = 7;
+ tilemap[4+60] = 2;
+ tilemap[4+80] = 4;
+}
+
+void
WorldMap::get_input()
{
SDL_Event event;
/** Busy loop */
void display();
+
+ void load_map();
void get_input();