super-tux-commit Mailing List for Super Tux (Page 48)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Tobias G. <to...@us...> - 2004-07-20 17:51:48
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/audio Added Files: musicref.cpp musicref.h sound.cpp sound.h sound_manager.cpp sound_manager.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: sound.cpp --- // $Id: sound.cpp,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // Copyright (C) 2004 Duong-Khang NGUYEN <neo...@us...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <string> #include "audio/sound.h" /*global variable*/ bool use_sound = true; /* handle sound on/off menu and command-line option */ bool use_music = true; /* handle music on/off menu and command-line option */ bool audio_device = true; /* != 0: available and initialized */ #include <SDL_mixer.h> std::vector<Mix_Chunk*> sounds; /* --- OPEN THE AUDIO DEVICE --- */ int open_audio (int frequency, Uint16 format, int channels, int chunksize) { if (Mix_OpenAudio( frequency, format, channels, chunksize ) < 0) return -1; // allocate 16 channels for mixing if (Mix_AllocateChannels(8) != 8) return -2; return 0; } /* --- CLOSE THE AUDIO DEVICE --- */ void close_audio( void ) { if (audio_device) { Mix_CloseAudio(); } } /* --- LOAD A SOUND --- */ Mix_Chunk* load_sound(const std::string& file) { if(!audio_device) return 0; Mix_Chunk* snd = Mix_LoadWAV(file.c_str()); /*if (snd == 0) st_abort("Can't load", file);*/ return(snd); } void free_chunk(Mix_Chunk *chunk) { Mix_FreeChunk( chunk ); } --- NEW FILE: sound_manager.cpp --- // $Id: sound_manager.cpp,v 1.1 2004/07/20 17:51:35 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <cmath> #include <cassert> #include "audio/sound_manager.h" #include "audio/musicref.h" #include "audio/sound.h" #include "app/globals.h" #include "app/setup.h" #include "special/moving_object.h" SoundManager::SoundManager() : current_music(0), music_enabled(true) { } SoundManager::~SoundManager() { if(audio_device) Mix_HaltMusic(); } void SoundManager::play_sound(Mix_Chunk* sound) { if(!audio_device || !use_sound) return; Mix_PlayChannel(-1, sound, 0); } void SoundManager::play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos) { // TODO keep track of the object later and move the sound along with the // object. play_sound(sound, object->get_pos(), pos); } void SoundManager::play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2) { if(!audio_device || !use_sound) return; // TODO make sure this formula is good float distance = pos2.x- pos.x; int loud = int(255.0/float(screen->w*2) * fabsf(distance)); if(loud > 255) return; int chan = Mix_PlayChannel(-1, sound, 0); if(chan < 0) return; Mix_SetDistance(chan, loud); // very bad way to do this... if(distance > 100) Mix_SetPanning(chan, 230, 24); else if(distance < -100) Mix_SetPanning(chan, 24, 230); } MusicRef SoundManager::load_music(const std::string& file) { if(!audio_device) return MusicRef(0); if(!exists_music(file)) st_abort("Couldn't load musicfile ", file.c_str()); std::map<std::string, MusicResource>::iterator i = musics.find(file); assert(i != musics.end()); return MusicRef(& (i->second)); } bool SoundManager::exists_music(const std::string& file) { if(!audio_device) return true; // song already loaded? std::map<std::string, MusicResource>::iterator i = musics.find(file); if(i != musics.end()) { return true; } Mix_Music* song = Mix_LoadMUS(file.c_str()); if(song == 0) return false; // insert into music list std::pair<std::map<std::string, MusicResource>::iterator, bool> result = musics.insert( std::make_pair<std::string, MusicResource> (file, MusicResource())); MusicResource& resource = result.first->second; resource.manager = this; resource.music = song; return true; } void SoundManager::free_music(MusicResource* ) { // TODO free music, currently we can't do this since SDL_mixer seems to have // some bugs if you load/free alot of mod files. } void SoundManager::play_music(const MusicRef& musicref, int loops) { if(!audio_device) return; if(musicref.music == 0 || current_music == musicref.music) return; if(current_music) current_music->refcount--; current_music = musicref.music; current_music->refcount++; if(music_enabled) Mix_PlayMusic(current_music->music, loops); } void SoundManager::halt_music() { if(!audio_device) return; Mix_HaltMusic(); if(current_music) { current_music->refcount--; if(current_music->refcount == 0) free_music(current_music); current_music = 0; } } void SoundManager::enable_music(bool enable) { if(!audio_device) return; if(enable == music_enabled) return; music_enabled = enable; if(music_enabled == false) { Mix_HaltMusic(); } else { Mix_PlayMusic(current_music->music, -1); } } SoundManager::MusicResource::~MusicResource() { // don't free music buggy SDL_Mixer crashs for some mod files // Mix_FreeMusic(music); } --- NEW FILE: sound_manager.h --- // $Id: sound_manager.h,v 1.1 2004/07/20 17:51:35 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SOUND_MANAGER_H #define SUPERTUX_SOUND_MANAGER_H #include <string> #include <map> #include "SDL_mixer.h" #include "math/vector.h" class MusicRef; class MovingObject; /** This class handles all sounds that are played */ class SoundManager { public: SoundManager(); ~SoundManager(); void play_sound(Mix_Chunk* sound); void play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2); void play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos); MusicRef load_music(const std::string& file); bool exists_music(const std::string& filename); void play_music(const MusicRef& music, int loops = -1); void halt_music(); void enable_music(bool enable); private: // music part friend class MusicRef; class MusicResource { public: ~MusicResource(); SoundManager* manager; Mix_Music* music; int refcount; }; void free_music(MusicResource* music); std::map<std::string, MusicResource> musics; MusicResource* current_music; bool music_enabled; }; #endif /*SUPERTUX_SOUND_MANAGER_H*/ --- NEW FILE: musicref.cpp --- // $Id: musicref.cpp,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "audio/musicref.h" MusicRef::MusicRef() : music(0) { } MusicRef::MusicRef(SoundManager::MusicResource* newmusic) : music(newmusic) { if(music) music->refcount++; } MusicRef::~MusicRef() { if(music) { music->refcount--; if(music->refcount == 0) music->manager->free_music(music); } } MusicRef::MusicRef(const MusicRef& other) : music(other.music) { if(music) music->refcount++; } MusicRef& MusicRef::operator =(const MusicRef& other) { SoundManager::MusicResource* oldres = music; music = other.music; if(music) music->refcount++; if(oldres) { oldres->refcount--; if(oldres->refcount == 0) music->manager->free_music(music); } return *this; } --- NEW FILE: musicref.h --- // $Id: musicref.h,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_MUSICREF_H #define SUPERTUX_MUSICREF_H #include "audio/sound_manager.h" /** This class holds a reference to a music file and maintains a correct * refcount for that file. */ class MusicRef { public: MusicRef(); MusicRef(const MusicRef& other); ~MusicRef(); MusicRef& operator= (const MusicRef& other); private: friend class SoundManager; MusicRef(SoundManager::MusicResource* music); SoundManager::MusicResource* music; }; #endif /*SUPERTUX_MUSICREF_H*/ --- NEW FILE: sound.h --- // $Id: sound.h,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // Copyright (C) 2004 Duong-Khang NGUYEN <neo...@us...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SOUND_H #define SUPERTUX_SOUND_H //#include "defines.h" /* get YES/NO defines */ #include <vector> /*global variable*/ extern bool use_sound; /* handle sound on/off menu and command-line option */ extern bool use_music; /* handle music on/off menu and command-line */ extern bool audio_device; /* != 0: available and initialized */ /* enum of different internal music types */ enum Music_Type { NO_MUSIC, LEVEL_MUSIC, HURRYUP_MUSIC, HERRING_MUSIC }; #include <string> #include <SDL_mixer.h> /* variables for stocking the sound and music */ extern std::vector<Mix_Chunk*> sounds; /* functions handling the sound and music */ int open_audio(int frequency, Uint16 format, int channels, int chunksize); void close_audio( void ); Mix_Chunk * load_sound(const std::string& file); void free_chunk(Mix_Chunk*chunk); #endif /*SUPERTUX_SOUND_H*/ |
From: Tobias G. <to...@us...> - 2004-07-20 17:51:46
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/math Added Files: physic.cpp physic.h vector.cpp vector.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: vector.cpp --- // $Id: vector.cpp,v 1.1 2004/07/20 17:51:36 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <cmath> #include "math/vector.h" Vector Vector::unit() const { return *this / norm(); } float Vector::norm() const { return sqrt(x*x + y*y); } --- NEW FILE: vector.h --- // $Id: vector.h,v 1.1 2004/07/20 17:51:36 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_VECTOR_H #define SUPERTUX_VECTOR_H class Vector { public: Vector(float nx, float ny) : x(nx), y(ny) { } Vector(const Vector& other) : x(other.x), y(other.y) { } Vector() : x(0), y(0) { } bool operator ==(const Vector& other) const { return x == other.x && y == other.y; } const Vector& operator=(const Vector& other) { x = other.x; y = other.y; return *this; } Vector operator+(const Vector& other) const { return Vector(x + other.x, y + other.y); } Vector operator-(const Vector& other) const { return Vector(x - other.x, y - other.y); } Vector operator*(float s) const { return Vector(x * s, y * s); } Vector operator/(float s) const { return Vector(x / s, y / s); } Vector operator-() const { return Vector(-x, -y); } const Vector& operator +=(const Vector& other) { x += other.x; y += other.y; return *this; } // scalar product of 2 vectors float operator*(const Vector& other) const { return x*other.x + y*other.y; } float norm() const; Vector unit() const; // ... add the other operators as needed, I'm too lazy now ... float x, y; // leave this public, get/set methods just give me headaches // for such simple stuff :) }; #endif /*SUPERTUX_VECTOR_H*/ --- NEW FILE: physic.cpp --- // $Id: physic.cpp,v 1.1 2004/07/20 17:51:36 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include <cstdio> #include "math/physic.h" #include "special/timer.h" Physic::Physic() : ax(0), ay(0), vx(0), vy(0), gravity_enabled(true) { } Physic::~Physic() { } void Physic::reset() { ax = ay = vx = vy = 0; gravity_enabled = true; } void Physic::set_velocity_x(float nvx) { vx = nvx; } void Physic::set_velocity_y(float nvy) { vy = -nvy; } void Physic::set_velocity(float nvx, float nvy) { vx = nvx; vy = -nvy; } void Physic::inverse_velocity_x() { vx = -vx; } void Physic::inverse_velocity_y() { vy = -vy; } float Physic::get_velocity_x() { return vx; } float Physic::get_velocity_y() { return -vy; } void Physic::set_acceleration_x(float nax) { ax = nax; } void Physic::set_acceleration_y(float nay) { ay = -nay; } void Physic::set_acceleration(float nax, float nay) { ax = nax; ay = -nay; } float Physic::get_acceleration_x() { return ax; } float Physic::get_acceleration_y() { return -ay; } void Physic::enable_gravity(bool enable_gravity) { gravity_enabled = enable_gravity; } void Physic::apply(float elapsed_time, float &x, float &y, float& gravity) { float grav; if(gravity_enabled) grav = gravity / 100.0; else grav = 0; x += vx * elapsed_time + ax * elapsed_time * elapsed_time; y += vy * elapsed_time + (ay + grav) * elapsed_time * elapsed_time; vx += ax * elapsed_time; vy += (ay + grav) * elapsed_time; } void Physic::apply(Vector& vector, float elapsed_time, float& gravity) { apply(elapsed_time, vector.x, vector.y, gravity); } --- NEW FILE: physic.h --- // $Id: physic.h,v 1.1 2004/07/20 17:51:36 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_PHYSIC_H #define SUPERTUX_PHYSIC_H #include "math/vector.h" /** This is a very simplistic physics engine handling accelerated and constant * movement along with gravity. */ class Physic { public: Physic(); ~Physic(); /** resets all velocities and accelerations to 0 */ void reset(); /** sets velocity to a fixed value */ void set_velocity(float vx, float vy); void set_velocity_x(float vx); void set_velocity_y(float vy); /** velocities invertion */ void inverse_velocity_x(); void inverse_velocity_y(); float get_velocity_x(); float get_velocity_y(); /** sets acceleration applied to the object. (Note that gravity is * eventually added to the vertical acceleration) */ void set_acceleration(float ax, float ay); void set_acceleration_x(float ax); void set_acceleration_y(float ay); float get_acceleration_x(); float get_acceleration_y(); /** enables or disables handling of gravity */ void enable_gravity(bool gravity_enabled); /** applies the physical simulation to given x and y coordinates */ void apply(float frame_ratio, float &x, float &y, float& gravity = 10); /** applies the physical simulation to given x and y coordinates */ void apply(Vector& vector, float frame_ratio, float& gravity = 10); private: /// horizontal and vertical acceleration float ax, ay; /// horizontal and vertical velocity float vx, vy; /// should we respect gravity in out calculations? bool gravity_enabled; }; #endif /*SUPERTUX_PHYSIC_H*/ |
From: Tobias G. <to...@us...> - 2004-07-20 17:51:45
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/app Added Files: defines.h gettext.h globals.cpp globals.h setup.cpp setup.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: defines.h --- // $Id: defines.h,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_DEFINES_H #define SUPERTUX_DEFINES_H 1 #include <config.h> /* Version: */ #ifndef VERSION #define VERSION "0.1.1" #endif enum Direction { LEFT = 0, RIGHT = 1 }; /* Direction (keyboard/joystick) states: */ #define UP 0 #define DOWN 1 /* Dying types: */ /* ---- NO 0 */ enum DyingType { DYING_NOT = 0, DYING_SQUISHED = 1, DYING_FALLING = 2 }; /* Screen-related stuff */ // +1 is needed because when tiles are wrapping around the screen there // are two partial tiles on the screen #define VISIBLE_TILES_X (25 +1) #define VISIBLE_TILES_Y (19 +1) /* Speed constraints: */ #define MAX_WALK_XM 2.3 #define MAX_RUN_XM 3.2 #define MAX_YM 20.0 #define MAX_JUMP_TIME 375 #define MAX_LIVES 99 #define WALK_SPEED 1.0 #define RUN_SPEED 1.5 #define JUMP_SPEED 1.2 /* gameplay related defines */ #define START_LIVES 4 #define MAX_FIRE_BULLETS 2 #define MAX_ICE_BULLETS 1 #define FROZEN_TIME 3000 #define YM_FOR_JUMP 6.0 #define WALK_ACCELERATION_X 0.03 #define RUN_ACCELERATION_X 0.04 #define KILL_BOUNCE_YM 8.0 #define SKID_XM 2.0 #define SKID_TIME 200 /* Size constraints: */ #define X_OFFSCREEN_DISTANCE (screen->w/2) #define Y_OFFSCREEN_DISTANCE (screen->h/2) /* Debugging */ #ifdef DEBUG #define DEBUG_MSG( msg ) { \ printf( msg ); printf("\n"); \ } #else #define DEBUG_MSG( msg ) {} #endif #define UNUSED_ARG(a) do {/* null */} while (&a == 0) #endif /*SUPERTUX_DEFINES_H*/ --- NEW FILE: setup.cpp --- // $Id: setup.cpp,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <cassert> #include <cstdio> #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cerrno> #include <unistd.h> #include "SDL.h" #include "SDL_image.h" #ifndef NOOPENGL #include "SDL_opengl.h" #endif #include <sys/stat.h> #include <sys/types.h> #include <dirent.h> #ifndef WIN32 #include <libgen.h> #endif #include <cctype> #include "app/globals.h" #include "app/defines.h" #include "app/setup.h" #include "video/screen.h" #include "video/surface.h" #include "gui/menu.h" #include "utils/configfile.h" #include "audio/sound_manager.h" #include "app/gettext.h" #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) // on win32 we typically don't want LFS paths #undef DATA_PREFIX #define DATA_PREFIX "./data/" #endif /* Screen proprities: */ /* Don't use this to test for the actual screen sizes. Use screen->w/h instead! */ #define SCREEN_W 800 #define SCREEN_H 600 /* Local function prototypes: */ void seticon(void); void usage(char * prog, int ret); /* Does the given file exist and is it accessible? */ int faccessible(const char *filename) { struct stat filestat; if (stat(filename, &filestat) == -1) { return false; } else { if(S_ISREG(filestat.st_mode)) return true; else return false; } } /* Can we write to this location? */ int fwriteable(const char *filename) { FILE* fi; fi = fopen(filename, "wa"); if (fi == NULL) { return false; } return true; } /* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/ int fcreatedir(const char* relative_dir) { char path[1024]; snprintf(path, 1024, "%s/%s/", st_dir, relative_dir); if(mkdir(path,0755) != 0) { snprintf(path, 1024, "%s/%s/", datadir.c_str(), relative_dir); if(mkdir(path,0755) != 0) { return false; } else { return true; } } else { return true; } } FILE * opendata(const char * rel_filename, const char * mode) { char * filename = NULL; FILE * fi; filename = (char *) malloc(sizeof(char) * (strlen(st_dir) + strlen(rel_filename) + 1)); strcpy(filename, st_dir); /* Open the high score file: */ strcat(filename, rel_filename); /* Try opening the file: */ fi = fopen(filename, mode); if (fi == NULL) { fprintf(stderr, "Warning: Unable to open the file \"%s\" ", filename); if (strcmp(mode, "r") == 0) fprintf(stderr, "for read!!!\n"); else if (strcmp(mode, "w") == 0) fprintf(stderr, "for write!!!\n"); } free( filename ); return(fi); } /* Get all names of sub-directories in a certain directory. */ /* Returns the number of sub-directories found. */ /* Note: The user has to free the allocated space. */ string_list_type dsubdirs(const char *rel_path,const char* expected_file) { DIR *dirStructP; struct dirent *direntp; string_list_type sdirs; char filename[1024]; char path[1024]; string_list_init(&sdirs); sprintf(path,"%s/%s",st_dir,rel_path); if((dirStructP = opendir(path)) != NULL) { while((direntp = readdir(dirStructP)) != NULL) { char absolute_filename[1024]; struct stat buf; sprintf(absolute_filename, "%s/%s", path, direntp->d_name); if (stat(absolute_filename, &buf) == 0 && S_ISDIR(buf.st_mode)) { if(expected_file != NULL) { sprintf(filename,"%s/%s/%s",path,direntp->d_name,expected_file); if(!faccessible(filename)) continue; } string_list_add_item(&sdirs,direntp->d_name); } } closedir(dirStructP); } sprintf(path,"%s/%s",datadir.c_str(),rel_path); if((dirStructP = opendir(path)) != NULL) { while((direntp = readdir(dirStructP)) != NULL) { char absolute_filename[1024]; struct stat buf; sprintf(absolute_filename, "%s/%s", path, direntp->d_name); if (stat(absolute_filename, &buf) == 0 && S_ISDIR(buf.st_mode)) { if(expected_file != NULL) { sprintf(filename,"%s/%s/%s",path,direntp->d_name,expected_file); if(!faccessible(filename)) { continue; } else { sprintf(filename,"%s/%s/%s/%s",st_dir,rel_path,direntp->d_name,expected_file); if(faccessible(filename)) continue; } } string_list_add_item(&sdirs,direntp->d_name); } } closedir(dirStructP); } return sdirs; } string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str) { DIR *dirStructP; struct dirent *direntp; string_list_type sdirs; char path[1024]; string_list_init(&sdirs); sprintf(path,"%s/%s",st_dir,rel_path); if((dirStructP = opendir(path)) != NULL) { while((direntp = readdir(dirStructP)) != NULL) { char absolute_filename[1024]; struct stat buf; sprintf(absolute_filename, "%s/%s", path, direntp->d_name); if (stat(absolute_filename, &buf) == 0 && S_ISREG(buf.st_mode)) { if(exception_str != NULL) { if(strstr(direntp->d_name,exception_str) != NULL) continue; } if(glob != NULL) if(strstr(direntp->d_name,glob) == NULL) continue; string_list_add_item(&sdirs,direntp->d_name); } } closedir(dirStructP); } sprintf(path,"%s/%s",datadir.c_str(),rel_path); if((dirStructP = opendir(path)) != NULL) { while((direntp = readdir(dirStructP)) != NULL) { char absolute_filename[1024]; struct stat buf; sprintf(absolute_filename, "%s/%s", path, direntp->d_name); if (stat(absolute_filename, &buf) == 0 && S_ISREG(buf.st_mode)) { if(exception_str != NULL) { if(strstr(direntp->d_name,exception_str) != NULL) continue; } if(glob != NULL) if(strstr(direntp->d_name,glob) == NULL) continue; string_list_add_item(&sdirs,direntp->d_name); } } closedir(dirStructP); } return sdirs; } void free_strings(char **strings, int num) { int i; for(i=0; i < num; ++i) free(strings[i]); } /* --- SETUP --- */ /* Set SuperTux configuration and save directories */ void st_directory_setup(void) { char *home; char str[1024]; /* Get home directory (from $HOME variable)... if we can't determine it, use the current directory ("."): */ if (getenv("HOME") != NULL) home = getenv("HOME"); else home = "."; st_dir = (char *) malloc(sizeof(char) * (strlen(home) + strlen("/.supertux") + 1)); strcpy(st_dir, home); strcat(st_dir, "/.supertux"); /* Remove .supertux config-file from old SuperTux versions */ if(faccessible(st_dir)) { remove (st_dir); } st_save_dir = (char *) malloc(sizeof(char) * (strlen(st_dir) + strlen("/save") + 1)); strcpy(st_save_dir,st_dir); strcat(st_save_dir,"/save"); /* Create them. In the case they exist they won't destroy anything. */ mkdir(st_dir, 0755); mkdir(st_save_dir, 0755); sprintf(str, "%s/levels", st_dir); mkdir(str, 0755); // User has not that a datadir, so we try some magic if (datadir.empty()) { #ifndef WIN32 // Detect datadir char exe_file[PATH_MAX]; if (readlink("/proc/self/exe", exe_file, PATH_MAX) < 0) { puts("Couldn't read /proc/self/exe, using default path: " DATA_PREFIX); datadir = DATA_PREFIX; } else { std::string exedir = std::string(dirname(exe_file)) + "/"; datadir = exedir + "../data"; // SuperTux run from source dir if (access(datadir.c_str(), F_OK) != 0) { datadir = exedir + "../share/supertux"; // SuperTux run from PATH if (access(datadir.c_str(), F_OK) != 0) { // If all fails, fall back to compiled path datadir = DATA_PREFIX; } } } #else datadir = DATA_PREFIX; #endif } printf("Datadir: %s\n", datadir.c_str()); } void st_general_setup(void) { /* Seed random number generator: */ srand(SDL_GetTicks()); /* Set icon image: */ seticon(); /* Unicode needed for input handling: */ SDL_EnableUNICODE(1); /* Load global images: */ gold_text = new Font(datadir + "/images/fonts/gold.png", Font::TEXT, 16,18); blue_text = new Font(datadir + "/images/fonts/blue.png", Font::TEXT, 16,18,3); white_text = new Font(datadir + "/images/fonts/white.png", Font::TEXT, 16,18); gray_text = new Font(datadir + "/images/fonts/gray.png", Font::TEXT, 16,18); white_small_text = new Font(datadir + "/images/fonts/white-small.png", Font::TEXT, 8,9, 1); white_big_text = new Font(datadir + "/images/fonts/white-big.png", Font::TEXT, 20,22, 3); yellow_nums = new Font(datadir + "/images/fonts/numbers.png", Font::NUM, 32,32); /* Load GUI/menu images: */ checkbox = new Surface(datadir + "/images/status/checkbox.png", true); checkbox_checked = new Surface(datadir + "/images/status/checkbox-checked.png", true); back = new Surface(datadir + "/images/status/back.png", true); arrow_left = new Surface(datadir + "/images/icons/left.png", true); arrow_right = new Surface(datadir + "/images/icons/right.png", true); /* Load the mouse-cursor */ mouse_cursor = new MouseCursor( datadir + "/images/status/mousecursor.png",1); MouseCursor::set_current(mouse_cursor); } void st_general_free(void) { /* Free global images: */ delete gold_text; delete white_text; delete blue_text; delete gray_text; delete white_small_text; delete white_big_text; delete yellow_nums; /* Free GUI/menu images: */ delete checkbox; delete checkbox_checked; delete back; delete arrow_left; delete arrow_right; /* Free mouse-cursor */ delete mouse_cursor; /* Free menus */ delete main_menu; delete game_menu; delete options_menu; delete options_keys_menu; delete options_joystick_menu; delete highscore_menu; delete contrib_menu; delete contrib_subset_menu; delete save_game_menu; delete load_game_menu; } void st_video_setup(void) { /* Init SDL Video: */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "\nError: I could not initialize video!\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); exit(1); } /* Open display: */ if(use_gl) st_video_setup_gl(); else st_video_setup_sdl(); Surface::reload_all(); /* Set window manager stuff: */ SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux"); } void st_video_setup_sdl(void) { if (use_fullscreen) { screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */ if (screen == NULL) { fprintf(stderr, "\nWarning: I could not set up fullscreen video for " "800x600 mode.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); use_fullscreen = false; } } else { screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_HWSURFACE | SDL_DOUBLEBUF ); if (screen == NULL) { fprintf(stderr, "\nError: I could not set up video for 800x600 mode.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); exit(1); } } } void st_video_setup_gl(void) { #ifndef NOOPENGL SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (use_fullscreen) { screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */ if (screen == NULL) { fprintf(stderr, "\nWarning: I could not set up fullscreen video for " "640x480 mode.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); use_fullscreen = false; } } else { screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_OPENGL); if (screen == NULL) { fprintf(stderr, "\nError: I could not set up video for 640x480 mode.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); exit(1); } } /* * Set up OpenGL for 2D rendering. */ glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glViewport(0, 0, screen->w, screen->h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, screen->w, screen->h, 0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, 0.0f); #endif } void st_joystick_setup(void) { /* Init Joystick: */ use_joystick = true; if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "Warning: I could not initialize joystick!\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); use_joystick = false; } else { /* Open joystick: */ if (SDL_NumJoysticks() <= 0) { fprintf(stderr, "Info: No joysticks were found.\n"); use_joystick = false; } else { js = SDL_JoystickOpen(joystick_num); if (js == NULL) { fprintf(stderr, "Warning: Could not open joystick %d.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", joystick_num, SDL_GetError()); use_joystick = false; } else { if (SDL_JoystickNumAxes(js) < 2) { fprintf(stderr, "Warning: Joystick does not have enough axes!\n"); use_joystick = false; } else { if (SDL_JoystickNumButtons(js) < 2) { fprintf(stderr, "Warning: " "Joystick does not have enough buttons!\n"); use_joystick = false; } } } } } } void st_audio_setup(void) { /* Init SDL Audio silently even if --disable-sound : */ if (audio_device) { if (SDL_Init(SDL_INIT_AUDIO) < 0) { /* only print out message if sound or music was not disabled at command-line */ if (use_sound || use_music) { fprintf(stderr, "\nWarning: I could not initialize audio!\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); } /* keep the programming logic the same :-) because in this case, use_sound & use_music' values are ignored when there's no available audio device */ use_sound = false; use_music = false; audio_device = false; } } /* Open sound silently regarless the value of "use_sound": */ if (audio_device) { if (open_audio(44100, AUDIO_S16, 2, 2048) < 0) { /* only print out message if sound or music was not disabled at command-line */ if (use_sound || use_music) { fprintf(stderr, "\nWarning: I could not set up audio for 44100 Hz " "16-bit stereo.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); } use_sound = false; use_music = false; audio_device = false; } } } /* --- SHUTDOWN --- */ void st_shutdown(void) { close_audio(); SDL_Quit(); config->save(); } /* --- ABORT! --- */ void st_abort(const std::string& reason, const std::string& details) { fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str()); st_shutdown(); abort(); } /* Set Icon (private) */ void seticon(void) { // int masklen; // Uint8 * mask; SDL_Surface * icon; /* Load icon into a surface: */ icon = IMG_Load((datadir + "/images/supertux.xpm").c_str()); if (icon == NULL) { fprintf(stderr, "\nError: I could not load the icon image: %s%s\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", datadir.c_str(), "/images/supertux.xpm", SDL_GetError()); exit(1); } /* Create mask: */ /* masklen = (((icon -> w) + 7) / 8) * (icon -> h); mask = (Uint8*) malloc(masklen * sizeof(Uint8)); memset(mask, 0xFF, masklen); */ /* Set icon: */ SDL_WM_SetIcon(icon, NULL);//mask); /* Free icon surface & mask: */ // free(mask); SDL_FreeSurface(icon); } /* Parse command-line arguments: */ void parseargs(int argc, char * argv[]) { int i; config->load(); /* Parse arguments: */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "--fullscreen") == 0 || strcmp(argv[i], "-f") == 0) { use_fullscreen = true; } else if (strcmp(argv[i], "--window") == 0 || strcmp(argv[i], "-w") == 0) { use_fullscreen = false; } else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0) { assert(i+1 < argc); joystick_num = atoi(argv[++i]); } else if (strcmp(argv[i], "--joymap") == 0) { assert(i+1 < argc); if (sscanf(argv[++i], "%d:%d:%d:%d:%d", &joystick_keymap.x_axis, &joystick_keymap.y_axis, &joystick_keymap.a_button, &joystick_keymap.b_button, &joystick_keymap.start_button) != 5) { puts("Warning: Invalid or incomplete joymap, should be: 'XAXIS:YAXIS:A:B:START'"); } else { std::cout << "Using new joymap:\n" << " X-Axis: " << joystick_keymap.x_axis << "\n" << " Y-Axis: " << joystick_keymap.y_axis << "\n" << " A-Button: " << joystick_keymap.a_button << "\n" << " B-Button: " << joystick_keymap.b_button << "\n" << " Start-Button: " << joystick_keymap.start_button << std::endl; } } else if (strcmp(argv[i], "--leveleditor") == 0) { launch_leveleditor_mode = true; } else if (strcmp(argv[i], "--worldmap") == 0) { launch_worldmap_mode = true; } else if (strcmp(argv[i], "--datadir") == 0 || strcmp(argv[i], "-d") == 0 ) { assert(i+1 < argc); datadir = argv[++i]; } else if (strcmp(argv[i], "--show-fps") == 0) { /* Use full screen: */ show_fps = true; } else if (strcmp(argv[i], "--opengl") == 0 || strcmp(argv[i], "-gl") == 0) { #ifndef NOOPENGL /* Use OpengGL: */ use_gl = true; #endif } else if (strcmp(argv[i], "--sdl") == 0) { use_gl = false; } else if (strcmp(argv[i], "--usage") == 0) { /* Show usage: */ usage(argv[0], 0); } else if (strcmp(argv[i], "--version") == 0) { /* Show version: */ printf("SuperTux " VERSION "\n"); exit(0); } else if (strcmp(argv[i], "--disable-sound") == 0) { /* Disable the compiled in sound feature */ printf("Sounds disabled \n"); use_sound = false; audio_device = false; } else if (strcmp(argv[i], "--disable-music") == 0) { /* Disable the compiled in sound feature */ printf("Music disabled \n"); use_music = false; } else if (strcmp(argv[i], "--debug") == 0) { /* Enable the debug-mode */ debug_mode = true; } else if (strcmp(argv[i], "--help") == 0) { /* Show help: */ puts(_(" SuperTux " VERSION "\n" " Please see the file \"README.txt\" for more details.\n")); printf(_("Usage: %s [OPTIONS] FILENAME\n\n"), argv[0]); puts(_("Display Options:\n" " -f, --fullscreen Run in fullscreen mode.\n" " -w, --window Run in window mode.\n" " --opengl If OpenGL support was compiled in, this will tell\n" " SuperTux to make use of it.\n" " --sdl Use the SDL software graphical renderer\n" "\n" "Sound Options:\n" " --disable-sound If sound support was compiled in, this will\n" " disable sound for this session of the game.\n" " --disable-music Like above, but this will disable music.\n" "\n" "Misc Options:\n" " -j, --joystick NUM Use joystick NUM (default: 0)\n" " --joymap XAXIS:YAXIS:A:B:START\n" " Define how joystick buttons and axis should be mapped\n" " --leveleditor Opens the leveleditor in a file.\n" " --worldmap Opens the specified worldmap file.\n" " -d, --datadir DIR Load Game data from DIR (default: automatic)\n" " --debug Enables the debug mode, which is useful for developers.\n" " --help Display a help message summarizing command-line\n" " options, license and game controls.\n" " --usage Display a brief message summarizing command-line options.\n" " --version Display the version of SuperTux you're running.\n\n" )); exit(0); } else if (argv[i][0] != '-') { level_startup_file = argv[i]; } else { /* Unknown - complain! */ usage(argv[0], 1); } } } /* Display usage: */ void usage(char * prog, int ret) { FILE * fi; /* Determine which stream to write to: */ if (ret == 0) fi = stdout; else fi = stderr; /* Display the usage message: */ fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] FILENAME\n"), prog); /* Quit! */ exit(ret); } std::vector<std::string> read_directory(const std::string& pathname) { std::vector<std::string> dirnames; DIR* dir = opendir(pathname.c_str()); if (dir) { struct dirent *direntp; while((direntp = readdir(dir))) { dirnames.push_back(direntp->d_name); } closedir(dir); } return dirnames; } /* EOF */ --- NEW FILE: setup.h --- // $Id: setup.h,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2000 Bill Kendrick <bi...@ne...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SETUP_H #define SUPERTUX_SETUP_H #include <vector> #include <string> #include "gui/menu.h" #include "audio/sound.h" #include "special/base.h" int faccessible(const char *filename); int fcreatedir(const char* relative_dir); int fwriteable(const char *filename); std::vector<std::string> read_directory(const std::string& pathname); FILE * opendata(const char * filename, const char * mode); string_list_type dsubdirs(const char *rel_path, const char* expected_file); string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str); void free_strings(char **strings, int num); void st_directory_setup(void); void st_general_setup(void); void st_general_free(); void st_video_setup_sdl(void); void st_video_setup_gl(void); void st_video_setup(void); void st_audio_setup(void); void st_joystick_setup(void); void st_shutdown(void); void st_abort(const std::string& reason, const std::string& details); void parseargs(int argc, char * argv[]); #endif /*SUPERTUX_SETUP_H*/ --- NEW FILE: globals.cpp --- // $Id: globals.cpp,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux // Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include "app/globals.h" /** The datadir prefix prepended when loading game data file */ std::string datadir; JoystickKeymap::JoystickKeymap() { a_button = 0; b_button = 1; start_button = 2; x_axis = 0; y_axis = 1; dead_zone = 4096; } JoystickKeymap joystick_keymap; SDL_Surface * screen; Font* gold_text; Font* blue_text; Font* gray_text; Font* yellow_nums; Font* white_text; Font* white_small_text; Font* white_big_text; MouseCursor * mouse_cursor; bool use_gl; bool use_joystick; bool use_fullscreen; bool debug_mode; bool show_fps; float game_speed = 1.0f; int joystick_num = 0; char* level_startup_file = 0; bool launch_leveleditor_mode = false; bool launch_worldmap_mode = false; /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ char *st_dir, *st_save_dir; SDL_Joystick * js; /* Returns 1 for every button event, 2 for a quit event and 0 for no event. */ int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_delay, bool empty_events) { int i; Timer maxdelay; Timer mindelay; maxdelay.init(false); mindelay.init(false); if(max_delay < min_delay) max_delay = min_delay; maxdelay.start(max_delay); mindelay.start(min_delay); if(empty_events) while (SDL_PollEvent(&event)) {} /* Handle events: */ for(i = 0; maxdelay.check() || !i; ++i) { while (SDL_PollEvent(&event)) { if(!mindelay.check()) { if (event.type == SDL_QUIT) { /* Quit event - quit: */ return 2; } else if (event.type == SDL_KEYDOWN) { /* Keypress - skip intro: */ return 1; } else if (event.type == SDL_JOYBUTTONDOWN) { /* Fire button - skip intro: */ return 1; } else if (event.type == SDL_MOUSEBUTTONDOWN) { /* Mouse button - skip intro: */ return 1; } } } SDL_Delay(10); } return 0; } --- NEW FILE: globals.h --- // $Id: globals.h,v 1.1 2004/07/20 17:51:34 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Bill Kendrick <bi...@ne...> // Tobias Glaesser <tob...@gm...> // Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_GLOBALS_H #define SUPERTUX_GLOBALS_H #include <string> #include "SDL.h" #include "video/font.h" #include "gui/menu.h" #include "gui/mousecursor.h" extern std::string datadir; struct JoystickKeymap { int a_button; int b_button; int start_button; int x_axis; int y_axis; int dead_zone; JoystickKeymap(); }; extern JoystickKeymap joystick_keymap; extern SDL_Surface* screen; extern Font* gold_text; extern Font* white_text; extern Font* blue_text; extern Font* gray_text; extern Font* white_small_text; extern Font* white_big_text; extern Font* yellow_nums; extern MouseCursor * mouse_cursor; extern bool use_gl; extern bool use_joystick; extern bool use_fullscreen; extern bool debug_mode; extern bool show_fps; /** The number of the joystick that will be use in the game */ extern int joystick_num; extern char* level_startup_file; extern bool launch_leveleditor_mode; extern bool launch_worldmap_mode; /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ extern char* st_dir; extern char* st_save_dir; extern float game_speed; extern SDL_Joystick * js; int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); #endif /* SUPERTUX_GLOBALS_H */ --- NEW FILE: gettext.h --- /* Convenience header for conditional use of GNU <libintl.h>. Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 #ifdef HAVE_GETTEXT # define _(String) gettext(String) # define N_(String) gettext_noop(String) #else # define _(String) String # define N_(String) String #endif /* NLS can be disabled through the configure --disable-nls option. */ #if ENABLE_NLS /* Get declarations of GNU message catalog functions. */ #include <libintl.h> #else /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of <locale.h> a NOP. We don't include <libintl.h> as well because people using "gettext.h" will not include <libintl.h>, and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> is OK. */ #if defined(__sun) # include <locale.h> #endif #ifndef gettext /* Disabled NLS. The casts to 'const char *' serve the purpose of producing warnings for invalid uses of the value returned from these functions. On pre-ANSI systems without 'const', the config.h file is supposed to contain "#define const". */ # define gettext(Msgid) ((const char *) (Msgid)) # define dgettext(Domainname, Msgid) ((const char *) (Msgid)) # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) # define ngettext(Msgid1, Msgid2, N) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define dngettext(Domainname, Msgid1, Msgid2, N) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define textdomain(Domainname) ((const char *) (Domainname)) # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) #endif #endif /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time translation is done at a different place in the code. The argument, String, should be a literal string. Concatenated strings and other string expressions won't work. The macro's expansion is not parenthesized, so that it is suitable as initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String #endif /* _LIBGETTEXT_H */ |
From: Tobias G. <to...@us...> - 2004-07-20 17:51:26
|
Update of /cvsroot/super-tux/supertux/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib Added Files: Makefile.am Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: Makefile.am --- INCLUDES = METASOURCES = AUTO lib_LTLIBRARIES = libsupertux.la libsupertux_la_SOURCES =app/defines.h \ app/gettext.h \ app/globals.h app/globals.cpp \ app/setup.h app/setup.cpp \ audio/musicref.h audio/musicref.cpp \ audio/sound.h audio/sound.cpp \ audio/sound_manager.h audio/sound_manager.cpp \ gui/button.h gui/button.cpp \ gui/menu.h gui/menu.cpp \ gui/mousecursor.cpp gui/mousecursor.h \ math/physic.h math/physic.cpp \ math/vector.h math/vector.cpp \ special/base.h \ special/game_object.h special/game_object.cpp \ special/moving_object.h special/moving_object.cpp \ special/sprite.h special/sprite.cpp \ special/sprite_manager.h special/sprite_manager.cpp \ special/stringlist.h special/stringlist.cpp \ special/timer.h special/timer.cpp \ utils/configfile.h utils/configfile.cpp \ utils/exceptions.h \ utils/lispreader.h utils/lispreader.cpp \ utils/lispwriter.h utils/lispwriter.cpp \ video/drawing_context.h video/drawing_context.cpp \ video/font.h video/font.cpp \ video/screen.h video/screen.cpp \ video/surface.h video/surface.cpp libsupertux_la_LDFLAGS = -module |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:45
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18907/lib/video Log Message: Directory /cvsroot/super-tux/supertux/lib/video added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:44
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18907/lib/utils Log Message: Directory /cvsroot/super-tux/supertux/lib/utils added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:44
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18907/lib/special Log Message: Directory /cvsroot/super-tux/supertux/lib/special added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:44
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18907/lib/gui Log Message: Directory /cvsroot/super-tux/supertux/lib/gui added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:44
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18907/lib/math Log Message: Directory /cvsroot/super-tux/supertux/lib/math added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:47:13
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18839/lib/audio Log Message: Directory /cvsroot/super-tux/supertux/lib/audio added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:46:50
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18687/lib/app Log Message: Directory /cvsroot/super-tux/supertux/lib/app added to the repository |
From: Tobias G. <to...@us...> - 2004-07-20 17:46:03
|
Update of /cvsroot/super-tux/supertux/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18527/lib Log Message: Directory /cvsroot/super-tux/supertux/lib added to the repository |
From: Ricardo C. <rm...@us...> - 2004-07-20 13:18:48
|
Update of /cvsroot/super-tux/supertux/po In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31445/po Modified Files: LINGUAS Added Files: nn.po Log Message: Norwegian Nynorsk translation by Karl Ove Hufthammer! --- NEW FILE: nn.po --- # translation of nn.po to Norwegian Nynorsk # This file is distributed under the same license as the PACKAGE package. # Copyright (C) YEAR SuperTux Development Team. # Karl Ove Hufthammer <ka...@hu...>, 2004. # msgid "" msgstr "" "Project-Id-Version: nn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2004-07-19 12:45+0200\n" "PO-Revision-Date: 2004-07-19 12:55+0200\n" "Last-Translator: Karl Ove Hufthammer <ka...@hu...>\n" "Language-Team: Norwegian Nynorsk <i1...@li...>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.3\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: src/gameloop.cpp:169 msgid "by " msgstr "av " #: src/gameloop.cpp:175 msgid "Level Vertically Flipped!" msgstr "Brettet er snudd opp-ned!" #: src/gameloop.cpp:535 msgid "PAUSE - Press 'P' To Play" msgstr "PAUSE â Trykk «P» for Ã¥ halda fram" #: src/gameloop.cpp:540 #, c-format msgid "Playing: " msgstr "Brett: " #: src/gameloop.cpp:726 src/worldmap.cpp:890 msgid "SCORE" msgstr "POENG" #: src/gameloop.cpp:731 msgid "Press ESC To Return" msgstr "Trykk «Escape» for Ã¥ gÃ¥ tilbake" #: src/gameloop.cpp:736 msgid "TIME's UP" msgstr "DU HAR BRUKT OPP TIDA" #: src/gameloop.cpp:740 msgid "TIME" msgstr "TID" #: src/gameloop.cpp:747 src/gameloop.cpp:748 src/worldmap.cpp:894 msgid "COINS" msgstr "MYNTAR" #: src/gameloop.cpp:769 src/gameloop.cpp:770 src/worldmap.cpp:915 #: src/worldmap.cpp:916 msgid "LIVES" msgstr "LIV" #: src/gameloop.cpp:792 msgid "Result:" msgstr "Resultat:" #: src/gameloop.cpp:795 src/worldmap.cpp:748 #, c-format msgid "SCORE: %d" msgstr "POENG: %d" #: src/gameloop.cpp:798 src/worldmap.cpp:752 #, c-format msgid "COINS: %d" msgstr "MYNTAR: %d" #: src/gameloop.cpp:827 #, c-format msgid "Slot %d - Savegame" msgstr "Plass %d â lagra spel" #: src/gameloop.cpp:830 #, c-format msgid "Slot %d - Free" msgstr "Plass %d â ledig" #: src/menu.cpp:76 msgid "Yes" msgstr "Ja" #: src/menu.cpp:77 msgid "No" msgstr "Nei" #: src/menu.cpp:256 msgid "Up cursor" msgstr "Pil opp" #: src/menu.cpp:259 msgid "Down cursor" msgstr "Pil ned" #: src/menu.cpp:262 msgid "Left cursor" msgstr "Pil venstre" #: src/menu.cpp:265 msgid "Right cursor" msgstr "Pil høgre" #: src/menu.cpp:268 msgid "Return" msgstr "Enter" #: src/menu.cpp:271 msgid "Space" msgstr "Mellomrom" #: src/menu.cpp:274 msgid "Right Shift" msgstr "Høgre Shift" #: src/menu.cpp:277 msgid "Left Shift" msgstr "Venstre Shift" #: src/menu.cpp:280 msgid "Right Control" msgstr "Høgre Ctrl" #: src/menu.cpp:283 msgid "Left Control" msgstr "Venstre Ctrl" #: src/menu.cpp:286 msgid "Right Alt" msgstr "Høgre Alt" #: src/menu.cpp:289 msgid "Left Alt" msgstr "Venstre Alt" #: src/setup.cpp:390 src/setup.cpp:450 msgid "Start Game" msgstr "Start spelet" #: src/setup.cpp:391 src/title.cpp:97 msgid "Contrib Levels" msgstr "Andre brett" #: src/setup.cpp:392 src/setup.cpp:397 src/setup.cpp:473 src/setup.cpp:480 msgid "Options" msgstr "Oppsett" #: src/setup.cpp:393 msgid "Level Editor" msgstr "Lag brett" #: src/setup.cpp:394 msgid "Credits" msgstr "Rulletekst" #: src/setup.cpp:395 msgid "Quit" msgstr "Avslutt" #: src/setup.cpp:400 msgid "OpenGL " msgstr "OpenGL " #: src/setup.cpp:402 msgid "OpenGL (not supported)" msgstr "OpenGL (ikkje støtta)" #: src/setup.cpp:404 msgid "Fullscreen" msgstr "Fullskjerm " #: src/setup.cpp:407 src/setup.cpp:412 msgid "Sound " msgstr "Lyd " #: src/setup.cpp:408 src/setup.cpp:413 msgid "Music " msgstr "Musikk " #: src/setup.cpp:415 msgid "Show FPS " msgstr "Vis FPS " #: src/setup.cpp:416 msgid "Setup Keys" msgstr "Speltastar" #: src/setup.cpp:419 msgid "Setup Joystick" msgstr "Styrespak" #: src/setup.cpp:422 src/setup.cpp:434 src/setup.cpp:447 src/setup.cpp:458 #: src/title.cpp:117 src/title.cpp:164 msgid "Back" msgstr "Tilbake" #: src/setup.cpp:424 msgid "Keyboard Setup" msgstr "Tastaturoppsett" #: src/setup.cpp:426 msgid "Left move" msgstr "Venstre" #: src/setup.cpp:427 msgid "Right move" msgstr "Høgre" #: src/setup.cpp:428 msgid "Jump" msgstr "Hopp" #: src/setup.cpp:429 msgid "Duck" msgstr "Dukk" #: src/setup.cpp:430 msgid "Activate" msgstr "Bruk" #: src/setup.cpp:432 msgid "Power/Run" msgstr "Kraft/spring" #: src/setup.cpp:438 msgid "Joystick Setup" msgstr "Styrespakoppsett" #. options_joystick_menu->additem(MN_CONTROLFIELD_JS,"X axis", 0,0, 0,&joystick_keymap.x_axis); #. options_joystick_menu->additem(MN_CONTROLFIELD_JS,"Y axis", 0,0, 0,&joystick_keymap.y_axis); #: src/setup.cpp:442 msgid "A button" msgstr "Knapp A" #: src/setup.cpp:443 msgid "B button" msgstr "Knapp B" #: src/setup.cpp:460 msgid "Save Game" msgstr "Lagra spel" #: src/setup.cpp:470 src/setup.cpp:477 msgid "Pause" msgstr "Pause" #: src/setup.cpp:472 src/setup.cpp:479 msgid "Continue" msgstr "Hald fram" #: src/setup.cpp:475 msgid "Abort Level" msgstr "Avbryt brett" #: src/setup.cpp:482 msgid "Quit Game" msgstr "Avslutt spel" #: src/setup.cpp:484 msgid "Enter your name:" msgstr "Skriv inn namnet ditt:" #. Show help: #: src/setup.cpp:1053 msgid " SuperTux " msgstr " SuperTux " #: src/setup.cpp:1053 msgid "" "\n" " Please see the file \"README.txt\" for more details.\n" msgstr "" "\n" " SjÃ¥ fila «README.TXT» for meir informasjon.\n" #: src/setup.cpp:1055 #, c-format msgid "" "Usage: %s [OPTIONS] FILENAME\n" "\n" msgstr "" "Bruk: %s [VAL] FILNAMN\n" "\n" #: src/setup.cpp:1056 msgid "" "Display Options:\n" " -f, --fullscreen Run in fullscreen mode.\n" " -w, --window Run in window mode.\n" " --opengl If OpenGL support was compiled in, this will tell\n" " SuperTux to make use of it.\n" " --sdl Use the SDL software graphical renderer\n" "\n" "Sound Options:\n" " --disable-sound If sound support was compiled in, this will\n" " disable sound for this session of the game.\n" " --disable-music Like above, but this will disable music.\n" "\n" "Misc Options:\n" " -j, --joystick NUM Use joystick NUM (default: 0)\n" " --joymap XAXIS:YAXIS:A:B:START\n" " Define how joystick buttons and axis should be mapped\n" " --leveleditor Opens the leveleditor in a file.\n" " --worldmap Opens the specified worldmap file.\n" " -d, --datadir DIR Load Game data from DIR (default: automatic)\n" " --debug Enables the debug mode, which is useful for " "developers.\n" " --help Display a help message summarizing command-line\n" " options, license and game controls.\n" " --usage Display a brief message summarizing command-line " "options.\n" " --version Display the version of SuperTux you're running.\n" "\n" msgstr "" "Skjermval:\n" " --fullscreen Køyr spelet over heile skjermen.\n" " -w, --window Køyr spelet i eit vindauge.\n" " --opengl Bruk OpenGL viss dette er kompilert inn.\n" " --sdl Bruk SDL-basert biletvising.\n" "\n" "Lydval:\n" " --disable-sound SlÃ¥ av lydeffektar.\n" " --disable-music SlÃ¥ av musikk.\n" "\n" "Ymse:\n" " -j, --joystick NUM Bruk styrespak nummer NUM (standard: 0).\n" " --joymap XAXIS:YAXIS:A:B:START\n" " Definer oppsett av knappar og aksar pÃ¥ styrespaken.\n" " --leveleditor Start brettredigering av ei fil.\n" " --worldmap Opna valt verdskartfil.\n" " -d, --datadir MAP Hent speldata frÃ¥ mappa MAP (standard: automatisk).\n" " --debug Køyr i feilsøkjingsmodus. Nyttig for utviklarar.\n" " --help Vis ei kort oversikt over kommandolinjeval,\n" " lisensvilkÃ¥r og spelkontrollar.\n" " --usage Vis ei kort oversikt over kommandolinjeval.\n" " --version Vis versjonsnummer.\n" "\n" #. Display the usage message: #: src/setup.cpp:1114 #, c-format msgid "" "Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" "debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] " "FILENAME\n" msgstr "" "Bruk: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" "debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] " "FILNAMN\n" #: src/title.cpp:309 msgid "" "Copyright (c) 2003 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" "are welcome to redistribute it under certain conditions; see the file " "COPYING\n" "for details.\n" msgstr "" "Copyright © 2003 SuperTux-laget.\n" "Dette spelet kjem heilt utan nokon garantiar. Det er fri programvare,\n" "og du kan kopiera det til andre under visse vilkÃ¥r. SjÃ¥ fila «COPYING»\n" "for meir informasjon.\n" #: src/title.cpp:360 #, c-format msgid "Are you sure you want to delete slot %d?" msgstr "Er du sikker pÃ¥ at du vil sletta plass %d?" #: src/worldmap.cpp:745 msgid "GAMEOVER" msgstr "SPELET ER SLUTT" Index: LINGUAS =================================================================== RCS file: /cvsroot/super-tux/supertux/po/LINGUAS,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- LINGUAS 16 Jul 2004 19:39:00 -0000 1.6 +++ LINGUAS 20 Jul 2004 13:18:22 -0000 1.7 @@ -4,3 +4,4 @@ pt fr nl +nn |
From: Ricardo C. <rm...@us...> - 2004-07-19 11:42:03
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11317/src Modified Files: Tag: supertux_0_1_1_branch title.cpp Log Message: Save Bonus Island state to file. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.81.2.2 retrieving revision 1.81.2.3 diff -u -d -r1.81.2.2 -r1.81.2.3 --- title.cpp 18 Jul 2004 19:12:27 -0000 1.81.2.2 +++ title.cpp 19 Jul 2004 11:41:54 -0000 1.81.2.3 @@ -142,9 +142,9 @@ { WorldMapNS::WorldMap worldmap; worldmap.loadmap(worldmap_list.item[index - contrib_subsets.size()]); - // since levels state is not saved, make them all as solved, since - // we can't expect the user to play them all at once. - worldmap.set_levels_as_solved(); +// worldmap.set_levels_as_solved(); + worldmap.loadgame(std::string(st_save_dir) + "/bonus_island.stsg"); + worldmap.display(); Menu::set_current(main_menu); |
From: Ricardo C. <rm...@us...> - 2004-07-18 19:39:18
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11680/src Modified Files: Tag: supertux_0_1_1_branch badguy.cpp Log Message: Implemented bricks breaking by Ice Guys. Thx Ryan for pointing out the code. Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.68 retrieving revision 1.68.2.1 diff -u -d -r1.68 -r1.68.2.1 --- badguy.cpp 8 May 2004 23:46:43 -0000 1.68 +++ badguy.cpp 18 Jul 2004 19:39:05 -0000 1.68.2.1 @@ -288,12 +288,18 @@ float halfheight = base.height / 2; if (dir == LEFT && issolid( base.x, (int) base.y + halfheight)) { + if (kind == BAD_MRICEBLOCK && mode == KICK) + World::current()->trybreakbrick(base.x, base.y + halfheight, false); + dir = RIGHT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); return; } if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight)) { + if (kind == BAD_MRICEBLOCK && mode == KICK) + World::current()->trybreakbrick(base.x + base.width, (int) base.y + halfheight, false); + dir = LEFT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); return; |
From: Ricardo C. <rm...@us...> - 2004-07-18 19:12:51
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6841/src Modified Files: Tag: supertux_0_1_1_branch title.cpp worldmap.h Log Message: Mark all contrib world map levels as played. This as to be done (at least, until another solution is implemented), since the world map level's state are not saved, and it would make no sense to make the player to have to play the all map without exiting the game. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.81.2.1 retrieving revision 1.81.2.2 diff -u -d -r1.81.2.1 -r1.81.2.2 --- title.cpp 18 Jul 2004 11:58:15 -0000 1.81.2.1 +++ title.cpp 18 Jul 2004 19:12:27 -0000 1.81.2.2 @@ -142,6 +142,9 @@ { WorldMapNS::WorldMap worldmap; worldmap.loadmap(worldmap_list.item[index - contrib_subsets.size()]); + // since levels state is not saved, make them all as solved, since + // we can't expect the user to play them all at once. + worldmap.set_levels_as_solved(); worldmap.display(); Menu::set_current(main_menu); Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.28.2.3 retrieving revision 1.28.2.4 diff -u -d -r1.28.2.3 -r1.28.2.4 --- worldmap.h 18 Jul 2004 11:58:15 -0000 1.28.2.3 +++ worldmap.h 18 Jul 2004 19:12:28 -0000 1.28.2.4 @@ -188,7 +188,7 @@ ~WorldMap(); void set_map_file(std::string mapfile); - + /** Busy loop */ void display(); @@ -223,6 +223,12 @@ const int& get_start_y() const { return start_y; } + /** This functions should be call by contrib menu to set + all levels as played, since their state is not saved. */ + void set_levels_as_solved() + { for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + i->solved = true; } + private: void on_escape_press(); }; |
From: Ricardo C. <rm...@us...> - 2004-07-18 11:58:24
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10705/src Modified Files: Tag: supertux_0_1_1_branch setup.cpp title.cpp worldmap.cpp worldmap.h Log Message: Added support for worlds in Contribs menus. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.81 retrieving revision 1.81.2.1 diff -u -d -r1.81 -r1.81.2.1 --- title.cpp 10 May 2004 20:37:59 -0000 1.81 +++ title.cpp 18 Jul 2004 11:58:15 -0000 1.81.2.1 @@ -50,6 +50,7 @@ #include "math.h" #include "tile.h" #include "resources.h" +#include "worldmap.h" static Surface* bkg_title; static Surface* logo; @@ -62,8 +63,10 @@ static unsigned int last_update_time; static unsigned int update_time; -std::vector<LevelSubset*> contrib_subsets; -std::string current_contrib_subset; +static std::vector<LevelSubset*> contrib_subsets; +static std::string current_contrib_subset; + +static string_list_type worldmap_list; void free_contrib_menu() { @@ -81,7 +84,7 @@ free_contrib_menu(); - contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); + contrib_menu->additem(MN_LABEL,"Bonus Levels",0,0); contrib_menu->additem(MN_HL,"",0,0); for (int i = 0; i < level_subsets.num_items; ++i) @@ -89,10 +92,17 @@ LevelSubset* subset = new LevelSubset(); subset->load(level_subsets.item[i]); contrib_menu->additem(MN_GOTO, subset->title.c_str(), i, - contrib_subset_menu, i+1); + contrib_subset_menu, i); contrib_subsets.push_back(subset); } + for(int i = 0; i < worldmap_list.num_items; i++) + { + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(worldmap_list.item[i]); + contrib_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0, i + level_subsets.num_items); + } + contrib_menu->additem(MN_HL,"",0,0); contrib_menu->additem(MN_BACK,"Back",0,0); @@ -101,43 +111,41 @@ void check_contrib_menu() { - static int current_subset = -1; - int index = contrib_menu->check(); - if (index != -1) + if (index == -1) + return; + + if (index < (int)contrib_subsets.size()) { - index -= 1; - if (index >= 0 && index <= int(contrib_subsets.size())) - { - if (current_subset != index) - { - current_subset = index; - // FIXME: This shouln't be busy looping - LevelSubset& subset = * (contrib_subsets[index]); - - current_contrib_subset = subset.name; + // FIXME: This shouln't be busy looping + LevelSubset& subset = * (contrib_subsets[index]); - std::cout << "Updating the contrib subset menu..." << subset.levels << std::endl; - - contrib_subset_menu->clear(); + current_contrib_subset = subset.name; + + contrib_subset_menu->clear(); + + contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0); + contrib_subset_menu->additem(MN_HL,"",0,0); - contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0); - contrib_subset_menu->additem(MN_HL,"",0,0); - for (int i = 1; i <= subset.levels; ++i) - { - Level level; - level.load(subset.name, i); - contrib_subset_menu->additem(MN_ACTION, level.name, 0, 0, i); - } - contrib_subset_menu->additem(MN_HL,"",0,0); - contrib_subset_menu->additem(MN_BACK, "Back", 0, 0); - } - } - else + for (int i = 0; i < subset.levels; ++i) { - // Back button + /** get level's title */ + Level level; + level.load(subset.name, i); + contrib_subset_menu->additem(MN_ACTION, level.name, 0,0,i); } - } + + contrib_subset_menu->additem(MN_HL,"",0,0); + contrib_subset_menu->additem(MN_BACK, "Back", 0, 0); + } + else if(index < worldmap_list.num_items + (int)contrib_subsets.size()) + { + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(worldmap_list.item[index - contrib_subsets.size()]); + worldmap.display(); + + Menu::set_current(main_menu); + } } void check_contrib_subset_menu() @@ -230,6 +238,12 @@ logo = new Surface(datadir + "/images/title/logo.png", USE_ALPHA); img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", USE_ALPHA); + /* Generating contrib maps by only using a string_list */ + // Since there isn't any world dir or anything, add a hardcoded entry for Bonus Island + string_list_init(&worldmap_list); + string_list_add_item(&worldmap_list, "bonusisland.stwm"); +// worldmap_list = dfiles("levels/default", NULL, "icyisland.stwm"); + /* --- Main title loop: --- */ frame = 0; @@ -369,6 +383,7 @@ /* Free surfaces: */ free_contrib_menu(); + string_list_free(&worldmap_list); delete bkg_title; delete logo; delete img_choose_subset; Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.68.2.3 retrieving revision 1.68.2.4 diff -u -d -r1.68.2.3 -r1.68.2.4 --- worldmap.cpp 10 Jul 2004 21:53:08 -0000 1.68.2.3 +++ worldmap.cpp 18 Jul 2004 11:58:15 -0000 1.68.2.4 @@ -384,7 +384,6 @@ void WorldMap::load_map() { - lisp_object_t* root_obj = lisp_read_from_file(map_file); if (!root_obj) st_abort("Couldn't load file", map_file); @@ -1028,6 +1027,14 @@ lisp_free(savegame); } +void +WorldMap::loadmap(const std::string& filename) +{ + savegame_file = ""; + set_map_file(filename); + load_map(); +} + } // namespace WorldMapNS /* Local Variables: */ Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.28.2.2 retrieving revision 1.28.2.3 diff -u -d -r1.28.2.2 -r1.28.2.3 --- worldmap.h 10 Jul 2004 21:53:08 -0000 1.28.2.2 +++ worldmap.h 18 Jul 2004 11:58:15 -0000 1.28.2.3 @@ -212,6 +212,10 @@ void savegame(const std::string& filename); void loadgame(const std::string& filename); + void loadmap(const std::string& filename); + + const std::string& get_world_title() const + { return name; } const int& get_start_x() const { return start_x; } Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.79.2.1 retrieving revision 1.79.2.2 diff -u -d -r1.79.2.1 -r1.79.2.2 --- setup.cpp 10 Jul 2004 21:53:08 -0000 1.79.2.1 +++ setup.cpp 18 Jul 2004 11:58:15 -0000 1.79.2.2 @@ -385,7 +385,7 @@ main_menu->set_pos(screen->w/2, 335); main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu, MNID_STARTGAME); - main_menu->additem(MN_GOTO, "Contrib Levels",0,contrib_menu, MNID_CONTRIB); + main_menu->additem(MN_GOTO, "Bonus Levels",0,contrib_menu, MNID_CONTRIB); main_menu->additem(MN_GOTO, "Options",0,options_menu, MNID_OPTIONMENU); main_menu->additem(MN_ACTION,"Level Editor",0,0, MNID_LEVELEDITOR); main_menu->additem(MN_ACTION,"Credits",0,0, MNID_CREDITS); @@ -509,7 +509,7 @@ WorldMapNS::WorldMap worldmap; //TODO: Define the circumstances under which BonusIsland is chosen - worldmap.set_map_file("bonusisland.stwm"); + worldmap.set_map_file("worldmap.stwm"); worldmap.load_map(); // Load the game or at least set the savegame_file variable |
From: Ricardo C. <rm...@us...> - 2004-07-17 16:20:42
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20810/src Modified Files: worldmap.cpp worldmap.h Log Message: Just changed the name of a worldmap flag. Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.97 retrieving revision 1.98 diff -u -d -r1.97 -r1.98 --- worldmap.cpp 17 Jul 2004 13:14:20 -0000 1.97 +++ worldmap.cpp 17 Jul 2004 16:20:32 -0000 1.98 @@ -429,7 +429,7 @@ reader.read_string("extro-filename", level.extro_filename); reader.read_string("map-message", level.display_map_message); - reader.read_string("goto-world", level.goto_worldmap); + reader.read_string("next-world", level.next_worldmap); reader.read_string("level", level.name, true); reader.read_int("x", level.x); reader.read_int("y", level.y); @@ -788,10 +788,10 @@ // TODO: add an effect, like a camera scrolling, or at least, a fading tux->set_tile_pos(Vector(level->swap_x, level->swap_y)); } - if (!level->goto_worldmap.empty()) + if (!level->next_worldmap.empty()) { // Load given worldmap - loadmap(level->goto_worldmap); + loadmap(level->next_worldmap); } if (level->quit_worldmap) quit = true; Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- worldmap.h 16 Jul 2004 19:22:26 -0000 1.37 +++ worldmap.h 17 Jul 2004 16:20:33 -0000 1.38 @@ -155,7 +155,7 @@ std::string display_map_message; /** Go to this world */ - std::string goto_worldmap; + std::string next_worldmap; /** Quit the worldmap */ bool quit_worldmap; |
From: Ricardo C. <rm...@us...> - 2004-07-17 13:14:29
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29075/src Modified Files: title.cpp worldmap.cpp Log Message: Optmized code for reading level's name. Instead of loading the all levels, just parses now the title. Both worldmap loading and contrib menu generating were optmized. I couldn't time the worldmap loading speedup, since it was already instantaneously in my machine. But the contrib menu takes less than 1 sec versus the 4 seconds (and a few ms) of the old code. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.107 retrieving revision 1.108 diff -u -d -r1.107 -r1.108 --- title.cpp 14 Jul 2004 09:46:19 -0000 1.107 +++ title.cpp 17 Jul 2004 13:14:20 -0000 1.108 @@ -144,10 +144,20 @@ for (int i = 0; i < subset.get_num_levels(); ++i) { - Level* level = new Level; - level->load(subset.get_level_filename(i)); - contrib_subset_menu->additem(MN_ACTION, level->get_name(), 0, 0, i); - delete level; + /** get level's title */ + std::string level_title = "<no title>"; + + LispReader* reader = LispReader::load(subset.get_level_filename(i), "supertux-level"); + if(!reader) + { + std::cerr << "Error: Could not open level file. Ignoring...\n"; + return; + } + + reader->read_string("name", level_title, true); + delete reader; + + contrib_subset_menu->additem(MN_ACTION, level_title, 0, 0, i); } contrib_subset_menu->additem(MN_HL,"",0,0); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- worldmap.cpp 16 Jul 2004 19:22:26 -0000 1.96 +++ worldmap.cpp 17 Jul 2004 13:14:20 -0000 1.97 @@ -489,33 +489,15 @@ /** get level's title */ level.title = "<no title>"; - FILE * fi; - lisp_object_t* root_obj = 0; - fi = fopen((datadir + "/levels/" + level.name).c_str(), "r"); - if (fi == NULL) - { - perror((datadir + "/levels/" + level.name).c_str()); + LispReader* reader = LispReader::load(datadir + "/levels/" + level.name, "supertux-level"); + if(!reader) + { + std::cerr << "Error: Could not open level file. Ignoring...\n"; return; - } - - lisp_stream_t stream; - lisp_stream_init_file (&stream, fi); - root_obj = lisp_read (&stream); - - if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) - { - printf("World: Parse Error in file %s", level.name.c_str()); - } - - if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) - { - LispReader reader(lisp_cdr(root_obj)); - reader.read_string("name", level.title, true); - } - - lisp_free(root_obj); + } - fclose(fi); + reader->read_string("name", level.title, true); + delete reader; } void |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:39:11
|
Update of /cvsroot/super-tux/supertux/po In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20139/po Modified Files: LINGUAS Added Files: fr.po Log Message: French translation by Frederic Rodrigo! Index: LINGUAS =================================================================== RCS file: /cvsroot/super-tux/supertux/po/LINGUAS,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- LINGUAS 3 Jun 2004 20:48:36 -0000 1.5 +++ LINGUAS 16 Jul 2004 19:39:00 -0000 1.6 @@ -2,3 +2,5 @@ de es pt +fr +nl --- NEW FILE: fr.po --- (This appears to be a binary file; contents omitted.) |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:24:33
|
Update of /cvsroot/super-tux/supertux/data/levels/worldmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17148/data/levels/worldmap Modified Files: icyisland.stwm Log Message: Converted map to use special-tile . Index: icyisland.stwm =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/worldmap/icyisland.stwm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- icyisland.stwm 15 Jul 2004 19:57:53 -0000 1.7 +++ icyisland.stwm 16 Jul 2004 19:24:25 -0000 1.8 @@ -46,85 +46,115 @@ (levels - (level (name "world1/level1.stl") - (x 4) - (y 6)) - (level (name "world1/level2.stl") - (x 4) - (y 8)) - (level (name "world1/level3.stl") - (x 5) - (y 11)) - (level (name "world1/level4.stl") - (x 7) - (y 11)) - (level (name "world1/level5.stl") - (x 7) - (y 8)) - (level (name "world1/level6.stl") - (x 11) - (y 9)) - (level (name "world1/level7.stl") - (x 14) - (y 9)) - (level (name "world1/level8.stl") - (x 17) - (y 6)) - (level (name "world1/level9.stl") - (x 14) - (y 6)) - (level (name "world1/level10.stl") - (x 21) - (y 8)) - (level (name "world1/level11.stl") - (x 26) - (y 7)) - (level (name "world1/level12.stl") - (x 28) - (y 9)) - (level (name "world1/level13.stl") - (x 31) - (y 9)) - (level (name "world1/level14.stl") - (x 34) - (y 11)) - (level (name "world1/level15.stl") - (x 29) - (y 11)) - (level (name "world1/level16.stl") - (x 28) - (y 13)) - (level (name "world1/level17.stl") - (x 29) - (y 16)) - (level (name "world1/level18.stl") - (x 27) - (y 19)) - (level (name "world1/level19.stl") - (x 23) - (y 22)) - (level (name "world1/level20.stl") - (x 20) - (y 25)) - (level (name "world1/level21.stl") - (x 18) - (y 23)) - (level (name "world1/level22.stl") - (x 19) - (y 20)) - (level (name "world1/level23.stl") - (x 14) - (y 24)) - (level (name "world1/level24.stl") - (x 14) - (y 20)) - (level (name "world1/level25.stl") - (x 10) - (y 22)) - (level (name "world1/level26.stl") - (x 7) - (y 20) - (extro-filename "extro.txt")) + (special-tile + (x 4) + (y 6) + (level "world1/level1.stl")) + (special-tile + (x 4) + (y 8) + (level "world1/level2.stl")) + (special-tile + (x 5) + (y 11) + (level "world1/level3.stl")) + (special-tile + (x 7) + (y 11) + (level "world1/level4.stl")) + (special-tile + (x 7) + (y 8) + (level "world1/level5.stl")) + (special-tile + (x 11) + (y 9) + (level "world1/level6.stl")) + (special-tile + (x 11) + (y 9) + (level "world1/level7.stl")) + (special-tile + (x 17) + (y 6) + (level "world1/level8.stl")) + (special-tile + (x 14) + (y 6) + (level "world1/level9.stl")) + (special-tile + (x 21) + (y 8) + (level "world1/level10.stl")) + (special-tile + (x 26) + (y 7) + (level "world1/level11.stl")) + (special-tile + (x 28) + (y 9) + (level "world1/level12.stl")) + (special-tile + (x 31) + (y 9) + (level "world1/level13.stl")) + (special-tile + (x 34) + (y 11) + (level "world1/level14.stl")) + (special-tile + (x 29) + (y 11) + (level "world1/level15.stl")) + (special-tile + (x 28) + (y 13) + (level "world1/level16.stl")) + (special-tile + (x 29) + (y 16) + (level "world1/level17.stl")) + (special-tile + (x 27) + (y 19) + (level "world1/level18.stl")) + (special-tile + (x 23) + (y 22) + (level "world1/level19.stl")) + (special-tile + (x 20) + (y 25) + (level "world1/level20.stl")) + (special-tile + (x 18) + (y 23) + (level "world1/level21.stl")) + (special-tile + (x 19) + (y 20) + (level "world1/level22.stl")) + (special-tile + (x 14) + (y 24) + (level "world1/level23.stl")) + (special-tile + (x 14) + (y 20) + (level "world1/level24.stl")) + (special-tile + (x 10) + (y 22) + (level "world1/level25.stl")) + (special-tile + (x 7) + (y 20) + (extro-filename "extro.txt") + (level "world1/level26.stl") + (exit-game #t)) +; In the future, do this to go to another world: +; (goto-world "forest.stwt) + ) |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:23:22
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16808/data Modified Files: extro.txt Log Message: Added music and specified to open CREDITS after this. Index: extro.txt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/extro.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extro.txt 10 Jul 2004 14:07:33 -0000 1.4 +++ extro.txt 16 Jul 2004 19:23:02 -0000 1.5 @@ -1,6 +1,8 @@ ; Ending text (supertux-text (background "extro.jpg") + (music "theme.mod") + (show-after "CREDITS") (text "-Entering Nolok's Throne Room! |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:22:34
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16643/src Modified Files: worldmap.cpp worldmap.h Log Message: Implemented a new special-tile field that should replaced the depricated level field in world maps. Also extended display_text_file(). special-tile can have the following flags: [integer] x / y - necessary to say where the tile is located [string] extro-filename - read the given file * [integer] swap-x / swap-y - say coordinates for swapping * [string] map-message - show a message in the world map viewer [string] goto-world - change the world to the given one * [boolean] flip-level - flip vertically the level (of course, only works when there is a level) [boolean] exit-game - quit game * [string] level - feed a level to this tile * - if there is a level, open it only if the level is successful Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- worldmap.cpp 10 Jul 2004 14:22:59 -0000 1.95 +++ worldmap.cpp 16 Jul 2004 19:22:26 -0000 1.96 @@ -415,8 +415,8 @@ while(!lisp_nil_p(cur)) { lisp_object_t* element = lisp_car(cur); - - if (strcmp(lisp_symbol(lisp_car(element)), "level") == 0) + + if (strcmp(lisp_symbol(lisp_car(element)), "special-tile") == 0) { Level level; LispReader reader(lisp_cdr(element)); @@ -428,11 +428,42 @@ level.west = true; reader.read_string("extro-filename", level.extro_filename); + reader.read_string("map-message", level.display_map_message); + reader.read_string("goto-world", level.goto_worldmap); + reader.read_string("level", level.name, true); + reader.read_int("x", level.x); + reader.read_int("y", level.y); + level.swap_x = level.swap_y = -1; + reader.read_int("swap-x", level.swap_x); + reader.read_int("swap-y", level.swap_y); + level.vertical_flip = false; + reader.read_bool("flip-level", level.vertical_flip); + level.quit_worldmap = false; + reader.read_bool("exit-game", level.quit_worldmap); + + levels.push_back(level); + } + + /* Kept for backward compability */ + else if (strcmp(lisp_symbol(lisp_car(element)), "level") == 0) + { + Level level; + LispReader reader(lisp_cdr(element)); + level.solved = false; + + level.north = true; + level.east = true; + level.south = true; + level.west = true; + + reader.read_string("extro-filename", level.extro_filename); + if(!level.extro_filename.empty()) + level.quit_worldmap = true; reader.read_string("name", level.name, true); reader.read_int("x", level.x); reader.read_int("y", level.y); level.vertical_flip = false; - reader.read_bool("flip", level.vertical_flip); + level.swap_x = level.swap_y = -1; levels.push_back(level); } @@ -639,8 +670,17 @@ { if (enter_level && !tux->is_moving()) { + bool level_finished = true; Level* level = at_level(); - if (level) + if (!level) + { + std::cout << "Nothing to enter at: " + << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl; + return; + } + + + if(!level->name.empty()) { if (level->x == tux->get_tile_pos().x && level->y == tux->get_tile_pos().y) @@ -658,6 +698,7 @@ { case GameSession::ES_LEVEL_FINISHED: { + level_finished = true; bool old_level_state = level->solved; level->solved = true; @@ -693,30 +734,22 @@ std::cout << "Walk to dir: " << dir << std::endl; } - - if (!level->extro_filename.empty()) - { - MusicRef theme = - sound_manager->load_music(datadir + "/music/theme.mod"); - sound_manager->play_music(theme); - // Display final credits and go back to the main menu - display_text_file(level->extro_filename, SCROLL_SPEED_MESSAGE); - display_text_file("CREDITS", SCROLL_SPEED_CREDITS); - quit = true; - } } break; case GameSession::ES_LEVEL_ABORT: + level_finished = false; /* In case the player's abort the level, keep it using the old status. But the minimum lives and no bonus. */ player_status.score = old_player_status.score; player_status.distros = old_player_status.distros; player_status.lives = std::min(old_player_status.lives, player_status.lives); player_status.bonus = player_status.NO_BONUS; + break; case GameSession::ES_GAME_OVER: - { + { + level_finished = false; /* draw an end screen */ /* in the future, this should make a dialog a la SuperMario, asking if the player wants to restart the world map with no score and from @@ -724,7 +757,7 @@ char str[80]; DrawingContext context; - context.draw_gradient(Color (0, 255, 0), Color (255, 0, 255), + context.draw_gradient(Color (200,240,220), Color(200,200,220), LAYER_BACKGROUND0); context.draw_text_center(blue_text, _("GAMEOVER"), @@ -732,7 +765,7 @@ sprintf(str, _("SCORE: %d"), player_status.score); context.draw_text_center(gold_text, str, - Vector(0, 224), LAYER_FOREGROUND1); + Vector(0, 230), LAYER_FOREGROUND1); sprintf(str, _("COINS: %d"), player_status.distros); context.draw_text_center(gold_text, str, @@ -746,7 +779,7 @@ quit = true; player_status.reset(); break; - } + } case GameSession::ES_NONE: assert(false); // Should never be reached @@ -757,13 +790,29 @@ Menu::set_current(0); if (!savegame_file.empty()) savegame(savegame_file); - return; } } - else + /* The porpose of the next checking is that if the player lost + the level (in case there is one), don't show anything */ + if(level_finished) { - std::cout << "Nothing to enter at: " - << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl; + if (!level->extro_filename.empty()) + { + // Display a text file + display_text_file(level->extro_filename, SCROLL_SPEED_MESSAGE); + } + if (level->swap_x != -1 && level->swap_y != -1) + { + // TODO: add an effect, like a camera scrolling, or at least, a fading + tux->set_tile_pos(Vector(level->swap_x, level->swap_y)); + } + if (!level->goto_worldmap.empty()) + { + // Load given worldmap + loadmap(level->goto_worldmap); + } + if (level->quit_worldmap) + quit = true; } } else @@ -835,6 +884,9 @@ for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { + if(i->name.empty()) + continue; + if (i->solved) context.draw_surface(leveldot_green, Vector(i->x*32 + offset.x, i->y*32 + offset.y), LAYER_TILES+1); @@ -889,13 +941,21 @@ if (i->x == tux->get_tile_pos().x && i->y == tux->get_tile_pos().y) { - if(i->title == "") - get_level_title(*i); + if(!i->name.empty()) + { + if(i->title == "") + get_level_title(*i); - context.draw_text(white_text, i->title, - Vector(screen->w/2 - white_text->get_text_width(i->title)/2, - screen->h - white_text->get_height() - 30), - LAYER_FOREGROUND1); + context.draw_text_center(white_text, i->title, + Vector(0, screen->h - white_text->get_height() - 30), + LAYER_FOREGROUND1); + } + + /* Display a message in the map, if any as been selected */ + if(!i->display_map_message.empty()) + context.draw_text_center(gold_text, i->display_map_message, + Vector(0, screen->h - white_text->get_height() - 60), + LAYER_FOREGROUND1); break; } } Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- worldmap.h 10 Jul 2004 10:59:00 -0000 1.36 +++ worldmap.h 16 Jul 2004 19:22:26 -0000 1.37 @@ -139,6 +139,8 @@ std::string title; bool solved; + /** Optional flags: */ + /** Check if this level should be vertically flipped */ bool vertical_flip; @@ -146,6 +148,18 @@ successfully completed */ std::string extro_filename; + /** Position to swap player */ + int swap_x, swap_y; + + /** Message to show in the Map */ + std::string display_map_message; + + /** Go to this world */ + std::string goto_worldmap; + + /** Quit the worldmap */ + bool quit_worldmap; + // Directions which are walkable from this level bool north; bool east; |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:22:34
|
Update of /cvsroot/super-tux/supertux/src/screen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16643/src/screen Modified Files: font.cpp Log Message: Implemented a new special-tile field that should replaced the depricated level field in world maps. Also extended display_text_file(). special-tile can have the following flags: [integer] x / y - necessary to say where the tile is located [string] extro-filename - read the given file * [integer] swap-x / swap-y - say coordinates for swapping * [string] map-message - show a message in the world map viewer [string] goto-world - change the world to the given one * [boolean] flip-level - flip vertically the level (of course, only works when there is a level) [boolean] exit-game - quit game * [string] level - feed a level to this tile * - if there is a level, open it only if the level is successful Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/screen/font.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- font.cpp 10 Jul 2004 14:22:58 -0000 1.10 +++ font.cpp 16 Jul 2004 19:22:26 -0000 1.11 @@ -27,6 +27,8 @@ #include "font.h" #include "drawing_context.h" #include "../lispreader.h" +#include "../musicref.h" +#include "../resources.h" Font::Font(const std::string& file, FontType ntype, int nw, int nh, int nshadowsize) @@ -146,8 +148,18 @@ reader->read_string("text", text, true); std::string background_file; reader->read_string("background", background_file, true); + std::string music_file; + reader->read_string("music", music_file, true); + std::string show_after_text; + reader->read_string("show-after", show_after_text, true); delete reader; + if(!music_file.empty()) + { + MusicRef theme = sound_manager->load_music(datadir + "/music/" + music_file); + sound_manager->play_music(theme); + } + // Split text string lines into a vector names.clear(); unsigned int i, l; @@ -264,5 +276,10 @@ SDL_EnableKeyRepeat(0, 0); // disables key repeating delete background; + + if(!show_after_text.empty()) + { + display_text_file(show_after_text, scroll_speed); + } } |
From: Ricardo C. <rm...@us...> - 2004-07-16 19:15:08
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15050/src Modified Files: lispreader.cpp Log Message: Read the first 5 chars, not the all string of LANG. Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/lispreader.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- lispreader.cpp 12 Jul 2004 22:04:26 -0000 1.32 +++ lispreader.cpp 16 Jul 2004 19:15:00 -0000 1.33 @@ -1221,9 +1221,18 @@ char* lang = getenv("LANG"); char str_[1024]; // check, for instance, for (title-fr_FR "Bonjour") - sprintf(str_, "%s-%s", name, lang); - obj = search_for (str_); + if(lang != NULL && strlen(lang) >= 5) + { + char lang_[6]; + strncpy(lang_, lang, 5); + lang_[5] = '\0'; + sprintf(str_, "%s-%s", name, lang_); + + obj = search_for (str_); + } + else + obj = 0; if(!obj) // check, for instance, for (title-fr "Bonjour") { |