// $Id$
//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
+// SuperTux - A Jump'n Run
+// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
#include <iostream>
#include <vector>
#include <assert.h>
+#include "globals.h"
#include "texture.h"
#include "screen.h"
#include "lispreader.h"
#include "gameloop.h"
+#include "setup.h"
#include "worldmap.h"
namespace WorldMapNS {
TileManager::TileManager()
{
- lisp_object_t* root_obj = lisp_read_from_file(DATA_PREFIX "images/worldmap/antarctica.scm");
-
- assert(root_obj);
+ std::string stwt_filename = datadir + "images/worldmap/antarctica.stwt";
+ lisp_object_t* root_obj = lisp_read_from_file(stwt_filename);
+
+ if (!root_obj)
+ st_abort("Couldn't load file", stwt_filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap-tiles") == 0)
{
reader.read_string("image", &filename);
texture_load(&tile->sprite,
- const_cast<char*>((std::string(DATA_PREFIX "/images/worldmap/") + filename).c_str()),
+ datadir + "/images/worldmap/" + filename,
USE_ALPHA);
if (id >= int(tiles.size()))
Tux::Tux(WorldMap* worldmap_)
: worldmap(worldmap_)
{
- texture_load(&sprite, DATA_PREFIX "/images/worldmap/tux.png", USE_ALPHA);
+ texture_load(&sprite, datadir + "/images/worldmap/tux.png", USE_ALPHA);
offset = 0;
moving = false;
tile_pos.x = 0;
width = 20;
height = 15;
- texture_load(&level_sprite, DATA_PREFIX "/images/worldmap/levelmarker.png", USE_ALPHA);
+ texture_load(&level_sprite, datadir + "/images/worldmap/levelmarker.png", USE_ALPHA);
input_direction = NONE;
enter_level = false;
void
WorldMap::load_map()
{
- lisp_object_t* root_obj = lisp_read_from_file(DATA_PREFIX "levels/default/worldmap.scm");
- assert(root_obj);
+ std::string filename = datadir + "levels/default/worldmap.stwm";
+
+ lisp_object_t* root_obj = lisp_read_from_file(filename);
+ if (!root_obj)
+ st_abort("Couldn't load file", filename);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap") == 0)
{
SDL_Event event;
enter_level = false;
+ input_direction = NONE;
while (SDL_PollEvent(&event))
{
break;
}
break;
+
+ case SDL_JOYAXISMOTION:
+ switch(event.jaxis.axis)
+ {
+ case JOY_X:
+ if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ input_direction = WEST;
+ else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ input_direction = EAST;
+ break;
+ case JOY_Y:
+ if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ input_direction = SOUTH;
+ else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ input_direction = NORTH;
+ break;
+ }
+ break;
+
+ case SDL_JOYBUTTONDOWN:
+ if (event.jbutton.button == JOY_B)
+ enter_level = true;
+ break;
+
+ default:
+ break;
}
}
Uint8 *keystate = SDL_GetKeyState(NULL);
- input_direction = NONE;
-
if (keystate[SDLK_LEFT])
input_direction = WEST;
else if (keystate[SDLK_RIGHT])
{
std::cout << "Enter the current level: " << i->name << std::endl;;
halt_music();
- gameloop(const_cast<char*>((DATA_PREFIX "levels/default/" + i->name).c_str()),
+ gameloop(const_cast<char*>((datadir + "levels/default/" + i->name).c_str()),
1, ST_GL_LOAD_LEVEL_FILE);
play_music(song, 1);
break;
{
quit = false;
- song = load_song(const_cast<char*>((DATA_PREFIX "/music/" + music).c_str()));
+ song = load_song(datadir + "/music/" + music);
play_music(song, 1);
while(!quit) {