From: Matthias Braun Date: Sun, 26 Jun 2005 13:38:53 +0000 (+0000) Subject: renamed all .h to .hpp X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=5b7f9214cb929399f1a855ef5807018a9447d510;hp=ca7b29592acc3891b6b473a30824a70719d7b2a9;p=supertux.git renamed all .h to .hpp SVN-Revision: 2642 --- diff --git a/Jamrules b/Jamrules index 524a8c59a..2e3d6b0ae 100644 --- a/Jamrules +++ b/Jamrules @@ -46,7 +46,7 @@ include $(TOP)/mk/jam/build.jam ; # Include Dirs IncludeDir $(top_builddir) ; # for config.h -IncludeDir lib src ; +IncludeDir $(top_srcdir)/src ; if $(XGETTEXT) != "" { diff --git a/src/Jamfile b/src/Jamfile index f5efe6ab5..38492e855 100644 --- a/src/Jamfile +++ b/src/Jamfile @@ -4,20 +4,20 @@ SubInclude TOP src squirrel ; SubInclude TOP src scripting ; sources = - [ Wildcard *.cpp *.h ] - [ Wildcard audio : *.cpp *.h ] - [ Wildcard audio/newapi : *.cpp *.h ] - [ Wildcard badguy : *.cpp *.h ] - [ Wildcard control : *.cpp *.h ] - [ Wildcard gui : *.cpp *.h ] - [ Wildcard lisp : *.cpp *.h ] - [ Wildcard math : *.cpp *.h ] - [ Wildcard object : *.cpp *.h ] - [ Wildcard physfs : *.cpp *.h ] - [ Wildcard sprite : *.cpp *.h ] - [ Wildcard tinygettext : *.cpp *.h ] - [ Wildcard trigger : *.cpp *.h ] - [ Wildcard video : *.cpp *.h ] + [ Wildcard *.cpp *.hpp ] + [ Wildcard audio : *.cpp *.hpp ] + [ Wildcard audio/newapi : *.cpp *.hpp ] + [ Wildcard badguy : *.cpp *.hpp ] + [ Wildcard control : *.cpp *.hpp ] + [ Wildcard gui : *.cpp *.hpp ] + [ Wildcard lisp : *.cpp *.hpp ] + [ Wildcard math : *.cpp *.hpp ] + [ Wildcard object : *.cpp *.hpp ] + [ Wildcard physfs : *.cpp *.hpp ] + [ Wildcard sprite : *.cpp *.hpp ] + [ Wildcard tinygettext : *.cpp *.hpp ] + [ Wildcard trigger : *.cpp *.hpp ] + [ Wildcard video : *.cpp *.hpp ] ; TRANSLATABLE_SOURCES += [ SearchSource $(sources) ] ; diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index b9aa051b9..0012661cf 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -1,7 +1,7 @@ /** Used SDL_mixer and glest source as reference */ #include -#include "sound_file.h" +#include "sound_file.hpp" #include #include diff --git a/src/audio/sound_file.h b/src/audio/sound_file.h deleted file mode 100644 index 81184b13a..000000000 --- a/src/audio/sound_file.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __SOUND_FILE_H__ -#define __SOUND_FILE_H__ - -#include -#include - -class SoundFile -{ -public: - virtual ~SoundFile() - { } - - virtual size_t read(void* buffer, size_t buffer_size) = 0; - virtual void reset() = 0; - - int channels; - int rate; - int bits_per_sample; - /// size in bytes - size_t size; -}; - -SoundFile* load_sound_file(const std::string& filename); - -#endif - diff --git a/src/audio/sound_file.hpp b/src/audio/sound_file.hpp new file mode 100644 index 000000000..81184b13a --- /dev/null +++ b/src/audio/sound_file.hpp @@ -0,0 +1,26 @@ +#ifndef __SOUND_FILE_H__ +#define __SOUND_FILE_H__ + +#include +#include + +class SoundFile +{ +public: + virtual ~SoundFile() + { } + + virtual size_t read(void* buffer, size_t buffer_size) = 0; + virtual void reset() = 0; + + int channels; + int rate; + int bits_per_sample; + /// size in bytes + size_t size; +}; + +SoundFile* load_sound_file(const std::string& filename); + +#endif + diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index 3803fdf88..d5ade6ffd 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -1,13 +1,13 @@ -#include "sound_manager.h" +#include "sound_manager.hpp" #include #include #include #include -#include "sound_file.h" -#include "sound_source.h" -#include "stream_sound_source.h" +#include "sound_file.hpp" +#include "sound_source.hpp" +#include "stream_sound_source.hpp" SoundManager::SoundManager() : device(0), context(0), sound_enabled(false), music_source(0) diff --git a/src/audio/sound_manager.h b/src/audio/sound_manager.h deleted file mode 100644 index 1f53285a2..000000000 --- a/src/audio/sound_manager.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __SOUND_MANAGER_H__ -#define __SOUND_MANAGER_H__ - -#include "math/vector.h" -#include -#include -#include - -#include -#include - -typedef void* SoundHandle; - -class SoundFile; -class SoundSource; -class StreamSoundSource; - -class SoundManager -{ -public: - SoundManager(); - virtual ~SoundManager(); - - void enable_sound(bool sound_enabled); - /** - * Creates a new sound source object which plays the specified soundfile. - * You are responsible for deleting the sound source later (this will stop the - * sound). - * This function might throw exceptions. It returns 0 if no audio device is - * available. - */ - SoundSource* create_sound_source(const std::string& filename); - /** - * Convenience function to simply play a sound at a given position. - * This functions prepends sounds/ to the name and adds .wav - */ - void play(const std::string& name, const Vector& pos = Vector(-1, -1)); - - void set_listener_position(Vector position); - void set_listener_velocity(Vector velocity); - - void enable_music(bool music_enabled); - void play_music(const std::string& filename); - - void update(); - -private: - friend class SoundSource; - friend class StreamSoundSource; - - static ALuint load_file_into_buffer(const std::string& filename); - static ALenum get_sample_format(SoundFile* file); - - void print_openal_version(); - void check_alc_error(const char* message); - static void check_al_error(const char* message); - - ALCdevice* device; - ALCcontext* context; - bool sound_enabled; - - typedef std::map SoundBuffers; - SoundBuffers buffers; - typedef std::vector SoundSources; - SoundSources sources; - - StreamSoundSource* music_source; - - bool music_enabled; - std::string current_music; -}; - -#endif - diff --git a/src/audio/sound_manager.hpp b/src/audio/sound_manager.hpp new file mode 100644 index 000000000..a18727e8d --- /dev/null +++ b/src/audio/sound_manager.hpp @@ -0,0 +1,74 @@ +#ifndef __SOUND_MANAGER_H__ +#define __SOUND_MANAGER_H__ + +#include "math/vector.hpp" +#include +#include +#include + +#include +#include + +typedef void* SoundHandle; + +class SoundFile; +class SoundSource; +class StreamSoundSource; + +class SoundManager +{ +public: + SoundManager(); + virtual ~SoundManager(); + + void enable_sound(bool sound_enabled); + /** + * Creates a new sound source object which plays the specified soundfile. + * You are responsible for deleting the sound source later (this will stop the + * sound). + * This function might throw exceptions. It returns 0 if no audio device is + * available. + */ + SoundSource* create_sound_source(const std::string& filename); + /** + * Convenience function to simply play a sound at a given position. + * This functions prepends sounds/ to the name and adds .wav + */ + void play(const std::string& name, const Vector& pos = Vector(-1, -1)); + + void set_listener_position(Vector position); + void set_listener_velocity(Vector velocity); + + void enable_music(bool music_enabled); + void play_music(const std::string& filename); + + void update(); + +private: + friend class SoundSource; + friend class StreamSoundSource; + + static ALuint load_file_into_buffer(const std::string& filename); + static ALenum get_sample_format(SoundFile* file); + + void print_openal_version(); + void check_alc_error(const char* message); + static void check_al_error(const char* message); + + ALCdevice* device; + ALCcontext* context; + bool sound_enabled; + + typedef std::map SoundBuffers; + SoundBuffers buffers; + typedef std::vector SoundSources; + SoundSources sources; + + StreamSoundSource* music_source; + + bool music_enabled; + std::string current_music; +}; + +#endif + diff --git a/src/audio/sound_source.cpp b/src/audio/sound_source.cpp index b0ebdc8e2..399f3a3f7 100644 --- a/src/audio/sound_source.cpp +++ b/src/audio/sound_source.cpp @@ -1,7 +1,7 @@ #include -#include "sound_source.h" -#include "sound_manager.h" +#include "sound_source.hpp" +#include "sound_manager.hpp" SoundSource::SoundSource() { diff --git a/src/audio/sound_source.h b/src/audio/sound_source.h deleted file mode 100644 index 65797ca4d..000000000 --- a/src/audio/sound_source.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __SOUND_SOURCE_H__ -#define __SOUND_SOURCE_H__ - -#include -#include "math/vector.h" - -class SoundSource -{ -public: - SoundSource(); - virtual ~SoundSource(); - - void play(); - void stop(); - bool playing(); - - void set_looping(bool looping); - /// Set volume (0.0 is silent, 1.0 is normal) - void set_gain(float gain); - void set_position(Vector position); - void set_velocity(Vector position); - void set_reference_distance(float distance); - -protected: - friend class SoundManager; - - ALuint source; -}; - -#endif - diff --git a/src/audio/sound_source.hpp b/src/audio/sound_source.hpp new file mode 100644 index 000000000..4860eaec9 --- /dev/null +++ b/src/audio/sound_source.hpp @@ -0,0 +1,31 @@ +#ifndef __SOUND_SOURCE_H__ +#define __SOUND_SOURCE_H__ + +#include +#include "math/vector.hpp" + +class SoundSource +{ +public: + SoundSource(); + virtual ~SoundSource(); + + void play(); + void stop(); + bool playing(); + + void set_looping(bool looping); + /// Set volume (0.0 is silent, 1.0 is normal) + void set_gain(float gain); + void set_position(Vector position); + void set_velocity(Vector position); + void set_reference_distance(float distance); + +protected: + friend class SoundManager; + + ALuint source; +}; + +#endif + diff --git a/src/audio/stream_sound_source.cpp b/src/audio/stream_sound_source.cpp index d282c4dbf..88e67c015 100644 --- a/src/audio/stream_sound_source.cpp +++ b/src/audio/stream_sound_source.cpp @@ -1,8 +1,8 @@ #include -#include "stream_sound_source.h" -#include "sound_manager.h" -#include "sound_file.h" +#include "stream_sound_source.hpp" +#include "sound_manager.hpp" +#include "sound_file.hpp" StreamSoundSource::StreamSoundSource(SoundFile* file) { diff --git a/src/audio/stream_sound_source.h b/src/audio/stream_sound_source.h deleted file mode 100644 index b5002f234..000000000 --- a/src/audio/stream_sound_source.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __STREAM_SOUND_SOURCE_H__ -#define __STREAM_SOUND_SOURCE_H__ - -#include -#include "sound_source.h" - -class SoundFile; - -class StreamSoundSource : public SoundSource -{ -public: - StreamSoundSource(SoundFile* file); - virtual ~StreamSoundSource(); - - void update(); - -private: - static const size_t STREAMBUFFERSIZE = 1024 * 500; - static const size_t STREAMFRAGMENTS = 5; - static const size_t STREAMFRAGMENTSIZE - = STREAMBUFFERSIZE / STREAMFRAGMENTS; - - void fillBufferAndQueue(ALuint buffer); - SoundFile* file; - ALuint buffers[STREAMFRAGMENTS]; - ALenum format; - - enum FadeState { NoFading, FadingOn, FadingOff }; - FadeState fade_state; - // TODO -}; - -#endif - diff --git a/src/audio/stream_sound_source.hpp b/src/audio/stream_sound_source.hpp new file mode 100644 index 000000000..5fe4e462e --- /dev/null +++ b/src/audio/stream_sound_source.hpp @@ -0,0 +1,34 @@ +#ifndef __STREAM_SOUND_SOURCE_H__ +#define __STREAM_SOUND_SOURCE_H__ + +#include +#include "sound_source.hpp" + +class SoundFile; + +class StreamSoundSource : public SoundSource +{ +public: + StreamSoundSource(SoundFile* file); + virtual ~StreamSoundSource(); + + void update(); + +private: + static const size_t STREAMBUFFERSIZE = 1024 * 500; + static const size_t STREAMFRAGMENTS = 5; + static const size_t STREAMFRAGMENTSIZE + = STREAMBUFFERSIZE / STREAMFRAGMENTS; + + void fillBufferAndQueue(ALuint buffer); + SoundFile* file; + ALuint buffers[STREAMFRAGMENTS]; + ALenum format; + + enum FadeState { NoFading, FadingOn, FadingOff }; + FadeState fade_state; + // TODO +}; + +#endif + diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 3a4ae694c..8af388562 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -19,9 +19,9 @@ // 02111-1307, USA. #include -#include "badguy.h" -#include "object/camera.h" -#include "statistics.h" +#include "badguy.hpp" +#include "object/camera.hpp" +#include "statistics.hpp" static const float SQUISH_TIME = 2; static const float X_OFFSCREEN_DISTANCE = 1600; diff --git a/src/badguy/badguy.h b/src/badguy/badguy.h deleted file mode 100644 index ac891a613..000000000 --- a/src/badguy/badguy.h +++ /dev/null @@ -1,154 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __BADGUY_H__ -#define __BADGUY_H__ - -// moved them here to make it less typing when implementing new badguys -#include -#include "timer.h" -#include "moving_object.h" -#include "sprite/sprite.h" -#include "physic.h" -#include "object/player.h" -#include "serializable.h" -#include "resources.h" -#include "sector.h" -#include "direction.h" -#include "object_factory.h" -#include "lisp/parser.h" -#include "lisp/lisp.h" -#include "lisp/writer.h" -#include "video/drawing_context.h" -#include "audio/sound_manager.h" -#include "audio/sound_source.h" -#include "sprite/sprite_manager.h" - -class BadGuy : public MovingObject, public Serializable -{ -public: - BadGuy(); - ~BadGuy(); - - /** Called when the badguy is drawn. The default implementation simply draws - * the badguy sprite on screen - */ - virtual void draw(DrawingContext& context); - /** Called each frame. The default implementation checks badguy state and - * calls active_update and inactive_update - */ - virtual void update(float elapsed_time); - /** Called when a collision with another object occured. The default - * implemetnation calls collision_player, collision_solid, collision_badguy - * and collision_squished - */ - virtual HitResponse collision(GameObject& other, - const CollisionHit& hit); - - /** Set the badguy to kill/falling state, which makes him falling of the - * screen (his sprite is turned upside-down) - */ - virtual void kill_fall(); - - Vector get_start_position() const - { - return start_position; - } - void set_start_position(const Vector& vec) - { - start_position = vec; - } - - /** Count this badguy to the statistics? This value should not be changed - * during runtime. */ - bool countMe; - -protected: - enum State { - STATE_INIT, - STATE_INACTIVE, - STATE_ACTIVE, - STATE_SQUISHED, - STATE_FALLING - }; - - /** Called when the badguy collided with a player */ - virtual HitResponse collision_player(Player& player, - const CollisionHit& hit); - /** Called when the badguy collided with solid ground */ - virtual HitResponse collision_solid(GameObject& other, - const CollisionHit& hit); - /** Called when the badguy collided with another badguy */ - virtual HitResponse collision_badguy(BadGuy& other, - const CollisionHit& hit); - - /** Called when the player hit the badguy from above. You should return true - * if the badguy was squished, false if squishing wasn't possible - */ - virtual bool collision_squished(Player& player); - - /** called each frame when the badguy is activated. */ - virtual void active_update(float elapsed_time); - /** called each frame when the badguy is not activated. */ - virtual void inactive_update(float elapsed_time); - - /** - * called when the badguy has been activated. (As a side effect the dir - * variable might have been changed so that it faces towards the player. - */ - virtual void activate(); - /** called when the badguy has been deactivated */ - virtual void deactivate(); - - void kill_squished(Player& player); - - void set_state(State state); - State get_state() const - { return state; } - - /** - * returns a pointer to the player, try to avoid this function to avoid - * problems later when we have multiple players or no player in scripted - * sequence. - */ - Player* get_player(); - - Sprite* sprite; - Physic physic; - - /// is the enemy activated - bool activated; - /** - * initial position of the enemy. Also the position where enemy respawns when - * after being deactivated. - */ - bool is_offscreen(); - - Vector start_position; - - Direction dir; -private: - void try_activate(); - - State state; - Timer state_timer; -}; - -#endif - diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp new file mode 100644 index 000000000..8b759df37 --- /dev/null +++ b/src/badguy/badguy.hpp @@ -0,0 +1,154 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __BADGUY_H__ +#define __BADGUY_H__ + +// moved them here to make it less typing when implementing new badguys +#include +#include "timer.hpp" +#include "moving_object.hpp" +#include "sprite/sprite.hpp" +#include "physic.hpp" +#include "object/player.hpp" +#include "serializable.hpp" +#include "resources.hpp" +#include "sector.hpp" +#include "direction.hpp" +#include "object_factory.hpp" +#include "lisp/parser.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include "video/drawing_context.hpp" +#include "audio/sound_manager.hpp" +#include "audio/sound_source.hpp" +#include "sprite/sprite_manager.hpp" + +class BadGuy : public MovingObject, public Serializable +{ +public: + BadGuy(); + ~BadGuy(); + + /** Called when the badguy is drawn. The default implementation simply draws + * the badguy sprite on screen + */ + virtual void draw(DrawingContext& context); + /** Called each frame. The default implementation checks badguy state and + * calls active_update and inactive_update + */ + virtual void update(float elapsed_time); + /** Called when a collision with another object occured. The default + * implemetnation calls collision_player, collision_solid, collision_badguy + * and collision_squished + */ + virtual HitResponse collision(GameObject& other, + const CollisionHit& hit); + + /** Set the badguy to kill/falling state, which makes him falling of the + * screen (his sprite is turned upside-down) + */ + virtual void kill_fall(); + + Vector get_start_position() const + { + return start_position; + } + void set_start_position(const Vector& vec) + { + start_position = vec; + } + + /** Count this badguy to the statistics? This value should not be changed + * during runtime. */ + bool countMe; + +protected: + enum State { + STATE_INIT, + STATE_INACTIVE, + STATE_ACTIVE, + STATE_SQUISHED, + STATE_FALLING + }; + + /** Called when the badguy collided with a player */ + virtual HitResponse collision_player(Player& player, + const CollisionHit& hit); + /** Called when the badguy collided with solid ground */ + virtual HitResponse collision_solid(GameObject& other, + const CollisionHit& hit); + /** Called when the badguy collided with another badguy */ + virtual HitResponse collision_badguy(BadGuy& other, + const CollisionHit& hit); + + /** Called when the player hit the badguy from above. You should return true + * if the badguy was squished, false if squishing wasn't possible + */ + virtual bool collision_squished(Player& player); + + /** called each frame when the badguy is activated. */ + virtual void active_update(float elapsed_time); + /** called each frame when the badguy is not activated. */ + virtual void inactive_update(float elapsed_time); + + /** + * called when the badguy has been activated. (As a side effect the dir + * variable might have been changed so that it faces towards the player. + */ + virtual void activate(); + /** called when the badguy has been deactivated */ + virtual void deactivate(); + + void kill_squished(Player& player); + + void set_state(State state); + State get_state() const + { return state; } + + /** + * returns a pointer to the player, try to avoid this function to avoid + * problems later when we have multiple players or no player in scripted + * sequence. + */ + Player* get_player(); + + Sprite* sprite; + Physic physic; + + /// is the enemy activated + bool activated; + /** + * initial position of the enemy. Also the position where enemy respawns when + * after being deactivated. + */ + bool is_offscreen(); + + Vector start_position; + + Direction dir; +private: + void try_activate(); + + State state; + Timer state_timer; +}; + +#endif + diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index d6884a5ff..c611337e8 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -20,7 +20,7 @@ #include -#include "bomb.h" +#include "bomb.hpp" static const float TICKINGTIME = 1; static const float EXPLOSIONTIME = 1; diff --git a/src/badguy/bomb.h b/src/badguy/bomb.h deleted file mode 100644 index 4bd322203..000000000 --- a/src/badguy/bomb.h +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __BOMB_H__ -#define __BOMB_H__ - -#include "badguy.h" - -class Bomb : public BadGuy -{ -public: - Bomb(const Vector& pos, Direction dir); - - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_player(Player& player, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - void active_update(float elapsed_time); - void kill_fall(); - void explode(); - -private: - int state; - Timer timer; -}; - -#endif - diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp new file mode 100644 index 000000000..bc64ac54d --- /dev/null +++ b/src/badguy/bomb.hpp @@ -0,0 +1,45 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __BOMB_H__ +#define __BOMB_H__ + +#include "badguy.hpp" + +class Bomb : public BadGuy +{ +public: + Bomb(const Vector& pos, Direction dir); + + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_player(Player& player, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + void active_update(float elapsed_time); + void kill_fall(); + void explode(); + +private: + int state; + Timer timer; +}; + +#endif + diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index e998f6803..a704a04d9 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -20,7 +20,7 @@ #include -#include "bouncing_snowball.h" +#include "bouncing_snowball.hpp" static const float JUMPSPEED = 450; static const float WALKSPEED = 80; diff --git a/src/badguy/bouncing_snowball.h b/src/badguy/bouncing_snowball.h deleted file mode 100644 index 98e64f1d8..000000000 --- a/src/badguy/bouncing_snowball.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __BOUNCING_SNOWBALL_H__ -#define __BOUNCING_SNOWBALL_H__ - -#include "badguy.h" - -class BouncingSnowball : public BadGuy -{ -public: - BouncingSnowball(const lisp::Lisp& reader); - BouncingSnowball(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; -}; - -#endif - diff --git a/src/badguy/bouncing_snowball.hpp b/src/badguy/bouncing_snowball.hpp new file mode 100644 index 000000000..ae2ce4632 --- /dev/null +++ b/src/badguy/bouncing_snowball.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __BOUNCING_SNOWBALL_H__ +#define __BOUNCING_SNOWBALL_H__ + +#include "badguy.hpp" + +class BouncingSnowball : public BadGuy +{ +public: + BouncingSnowball(const lisp::Lisp& reader); + BouncingSnowball(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; +}; + +#endif + diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 6f83ee7d0..41a886370 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -20,13 +20,13 @@ #include -#include "dispenser.h" -#include "badguy/bouncing_snowball.h" -#include "badguy/snowball.h" -#include "badguy/mrbomb.h" -#include "badguy/mriceblock.h" -#include "badguy/mrrocket.h" -#include "badguy/poisonivy.h" +#include "dispenser.hpp" +#include "badguy/bouncing_snowball.hpp" +#include "badguy/snowball.hpp" +#include "badguy/mrbomb.hpp" +#include "badguy/mriceblock.hpp" +#include "badguy/mrrocket.hpp" +#include "badguy/poisonivy.hpp" Dispenser::Dispenser(const lisp::Lisp& reader) { diff --git a/src/badguy/dispenser.h b/src/badguy/dispenser.h deleted file mode 100644 index 235544491..000000000 --- a/src/badguy/dispenser.h +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __DISPENSER_H__ -#define __DISPENSER_H__ - -#include "badguy.h" -#include "timer.h" - -class Dispenser : public BadGuy -{ -public: - Dispenser(const lisp::Lisp& reader); - - void activate(); - void write(lisp::Writer& writer); - void active_update(float elapsed_time); - -protected: - bool collision_squished(Player& player); - void launch_badguy(); - float cycle; - std::string badguy; - Timer dispense_timer; -}; - -#endif - diff --git a/src/badguy/dispenser.hpp b/src/badguy/dispenser.hpp new file mode 100644 index 000000000..2b4f10fc0 --- /dev/null +++ b/src/badguy/dispenser.hpp @@ -0,0 +1,45 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __DISPENSER_H__ +#define __DISPENSER_H__ + +#include "badguy.hpp" +#include "timer.hpp" + +class Dispenser : public BadGuy +{ +public: + Dispenser(const lisp::Lisp& reader); + + void activate(); + void write(lisp::Writer& writer); + void active_update(float elapsed_time); + +protected: + bool collision_squished(Player& player); + void launch_badguy(); + float cycle; + std::string badguy; + Timer dispense_timer; +}; + +#endif + diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 0bd892bf7..f43b69a05 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -20,7 +20,7 @@ #include -#include "flame.h" +#include "flame.hpp" Flame::Flame(const lisp::Lisp& reader) : angle(0), radius(100), speed(2), source(0) diff --git a/src/badguy/flame.h b/src/badguy/flame.h deleted file mode 100644 index 877fa9bd3..000000000 --- a/src/badguy/flame.h +++ /dev/null @@ -1,48 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __FLAME_H__ -#define __FLAME_H__ - -#include "badguy.h" - -class Flame : public BadGuy -{ -public: - Flame(const lisp::Lisp& reader); - ~Flame(); - - void activate(); - void deactivate(); - - void write(lisp::Writer& write); - void active_update(float elapsed_time); - void kill_fall(); - -private: - float angle; - float radius; - float speed; - - SoundSource* source; -}; - -#endif - diff --git a/src/badguy/flame.hpp b/src/badguy/flame.hpp new file mode 100644 index 000000000..c9e7a40f9 --- /dev/null +++ b/src/badguy/flame.hpp @@ -0,0 +1,48 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __FLAME_H__ +#define __FLAME_H__ + +#include "badguy.hpp" + +class Flame : public BadGuy +{ +public: + Flame(const lisp::Lisp& reader); + ~Flame(); + + void activate(); + void deactivate(); + + void write(lisp::Writer& write); + void active_update(float elapsed_time); + void kill_fall(); + +private: + float angle; + float radius; + float speed; + + SoundSource* source; +}; + +#endif + diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index b95e487f6..3135c6a21 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -21,7 +21,7 @@ #include #include -#include "flyingsnowball.h" +#include "flyingsnowball.hpp" static const float FLYTIME = 1.0; static const float FLYSPEED = 100.0; diff --git a/src/badguy/flyingsnowball.h b/src/badguy/flyingsnowball.h deleted file mode 100644 index 7e1510b70..000000000 --- a/src/badguy/flyingsnowball.h +++ /dev/null @@ -1,48 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __FLYINGSNOWBALL_H__ -#define __FLYINGSNOWBALL_H__ - -#include "badguy.h" - -class FlyingSnowBall : public BadGuy -{ -public: - FlyingSnowBall(const lisp::Lisp& reader); - FlyingSnowBall(float pos_x, float pos_y); - - void activate(); - void write(lisp::Writer& writer); - void active_update(float elapsed_time); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); -protected: - enum FlyingSnowballMode { - FLY_UP, - FLY_DOWN - }; - FlyingSnowballMode mode; - bool collision_squished(Player& player); -private: - Timer timer; -}; - -#endif - diff --git a/src/badguy/flyingsnowball.hpp b/src/badguy/flyingsnowball.hpp new file mode 100644 index 000000000..2058e21db --- /dev/null +++ b/src/badguy/flyingsnowball.hpp @@ -0,0 +1,48 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __FLYINGSNOWBALL_H__ +#define __FLYINGSNOWBALL_H__ + +#include "badguy.hpp" + +class FlyingSnowBall : public BadGuy +{ +public: + FlyingSnowBall(const lisp::Lisp& reader); + FlyingSnowBall(float pos_x, float pos_y); + + void activate(); + void write(lisp::Writer& writer); + void active_update(float elapsed_time); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); +protected: + enum FlyingSnowballMode { + FLY_UP, + FLY_DOWN + }; + FlyingSnowballMode mode; + bool collision_squished(Player& player); +private: + Timer timer; +}; + +#endif + diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index 7958c5e4b..9b2a6b770 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -19,7 +19,7 @@ // 02111-1307, USA. #include -#include "jumpy.h" +#include "jumpy.hpp" static const float JUMPSPEED=600; static const float JUMPY_MID_TOLERANCE=4; diff --git a/src/badguy/jumpy.h b/src/badguy/jumpy.h deleted file mode 100644 index d4d6d4c6f..000000000 --- a/src/badguy/jumpy.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __JUMPY_H__ -#define __JUMPY_H__ - -#include "badguy.h" - -class Jumpy : public BadGuy -{ -public: - Jumpy(const lisp::Lisp& reader); - - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - - void write(lisp::Writer& writer); - void active_update(float); - -private: - HitResponse hit(const CollisionHit& hit); - Vector pos_groundhit; - bool groundhit_pos_set; -}; - -#endif - diff --git a/src/badguy/jumpy.hpp b/src/badguy/jumpy.hpp new file mode 100644 index 000000000..96360c625 --- /dev/null +++ b/src/badguy/jumpy.hpp @@ -0,0 +1,43 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __JUMPY_H__ +#define __JUMPY_H__ + +#include "badguy.hpp" + +class Jumpy : public BadGuy +{ +public: + Jumpy(const lisp::Lisp& reader); + + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); + + void write(lisp::Writer& writer); + void active_update(float); + +private: + HitResponse hit(const CollisionHit& hit); + Vector pos_groundhit; + bool groundhit_pos_set; +}; + +#endif + diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index a52904898..596899e60 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -20,8 +20,8 @@ #include -#include "mrbomb.h" -#include "bomb.h" +#include "mrbomb.hpp" +#include "bomb.hpp" static const float WALKSPEED = 80; diff --git a/src/badguy/mrbomb.h b/src/badguy/mrbomb.h deleted file mode 100644 index f59a0fb63..000000000 --- a/src/badguy/mrbomb.h +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __MRBOMB_H__ -#define __MRBOMB_H__ - -#include "badguy.h" - -class MrBomb : public BadGuy -{ -public: - MrBomb(const lisp::Lisp& reader); - MrBomb(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - void kill_fall(); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; -}; - -#endif - diff --git a/src/badguy/mrbomb.hpp b/src/badguy/mrbomb.hpp new file mode 100644 index 000000000..8fa7f5aa7 --- /dev/null +++ b/src/badguy/mrbomb.hpp @@ -0,0 +1,45 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __MRBOMB_H__ +#define __MRBOMB_H__ + +#include "badguy.hpp" + +class MrBomb : public BadGuy +{ +public: + MrBomb(const lisp::Lisp& reader); + MrBomb(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + void kill_fall(); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; +}; + +#endif + diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 0dcd96eaa..437f56cda 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -20,8 +20,8 @@ #include -#include "mriceblock.h" -#include "object/block.h" +#include "mriceblock.hpp" +#include "object/block.hpp" static const float WALKSPEED = 80; static const float KICKSPEED = 500; diff --git a/src/badguy/mriceblock.h b/src/badguy/mriceblock.h deleted file mode 100644 index 906b0f49c..000000000 --- a/src/badguy/mriceblock.h +++ /dev/null @@ -1,56 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __MRICEBLOCK_H__ -#define __MRICEBLOCK_H__ - -#include "badguy.h" - -class MrIceBlock : public BadGuy -{ -public: - MrIceBlock(const lisp::Lisp& reader); - MrIceBlock(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& object, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - - void active_update(float elapsed_time); - -protected: - bool collision_squished(Player& player); - -private: - enum IceState { - ICESTATE_NORMAL, - ICESTATE_FLAT, - ICESTATE_KICKED - }; - IceState ice_state; - Timer flat_timer; - int squishcount; - bool set_direction; - Direction initial_direction; -}; - -#endif - diff --git a/src/badguy/mriceblock.hpp b/src/badguy/mriceblock.hpp new file mode 100644 index 000000000..4031e0d2c --- /dev/null +++ b/src/badguy/mriceblock.hpp @@ -0,0 +1,56 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __MRICEBLOCK_H__ +#define __MRICEBLOCK_H__ + +#include "badguy.hpp" + +class MrIceBlock : public BadGuy +{ +public: + MrIceBlock(const lisp::Lisp& reader); + MrIceBlock(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& object, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + + void active_update(float elapsed_time); + +protected: + bool collision_squished(Player& player); + +private: + enum IceState { + ICESTATE_NORMAL, + ICESTATE_FLAT, + ICESTATE_KICKED + }; + IceState ice_state; + Timer flat_timer; + int squishcount; + bool set_direction; + Direction initial_direction; +}; + +#endif + diff --git a/src/badguy/mrrocket.cpp b/src/badguy/mrrocket.cpp index 0a77d7f06..95a65d95a 100644 --- a/src/badguy/mrrocket.cpp +++ b/src/badguy/mrrocket.cpp @@ -20,7 +20,7 @@ #include -#include "mrrocket.h" +#include "mrrocket.hpp" static const float SPEED = 200; diff --git a/src/badguy/mrrocket.h b/src/badguy/mrrocket.h deleted file mode 100644 index e0385a2fb..000000000 --- a/src/badguy/mrrocket.h +++ /dev/null @@ -1,47 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __MRROCKET_H__ -#define __MRROCKET_H__ - -#include "badguy.h" -#include "timer.h" -#include "rocketexplosion.h" - -class MrRocket : public BadGuy -{ -public: - MrRocket(const lisp::Lisp& reader); - MrRocket(float pos_x, float pos_y, Direction d); - - void activate(); - void active_update(float elapsed_time); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; - Timer collision_timer; -}; - -#endif - diff --git a/src/badguy/mrrocket.hpp b/src/badguy/mrrocket.hpp new file mode 100644 index 000000000..fe4658e95 --- /dev/null +++ b/src/badguy/mrrocket.hpp @@ -0,0 +1,47 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __MRROCKET_H__ +#define __MRROCKET_H__ + +#include "badguy.hpp" +#include "timer.hpp" +#include "rocketexplosion.hpp" + +class MrRocket : public BadGuy +{ +public: + MrRocket(const lisp::Lisp& reader); + MrRocket(float pos_x, float pos_y, Direction d); + + void activate(); + void active_update(float elapsed_time); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; + Timer collision_timer; +}; + +#endif + diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index ba396b136..73e2c6308 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -20,7 +20,7 @@ #include -#include "mrtree.h" +#include "mrtree.hpp" static const float WALKSPEED = 50; static const float WALKSPEED_SMALL = 30; diff --git a/src/badguy/mrtree.h b/src/badguy/mrtree.h deleted file mode 100644 index 0fdbb3940..000000000 --- a/src/badguy/mrtree.h +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __MRTREE_H__ -#define __MRTREE_H__ - -#include "badguy.h" - -class MrTree : public BadGuy -{ -public: - MrTree(const lisp::Lisp& reader); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - -protected: - enum MyState { - STATE_BIG, STATE_NORMAL - }; - MyState mystate; - - bool collision_squished(Player& player); -}; - -#endif diff --git a/src/badguy/mrtree.hpp b/src/badguy/mrtree.hpp new file mode 100644 index 000000000..058e26141 --- /dev/null +++ b/src/badguy/mrtree.hpp @@ -0,0 +1,45 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __MRTREE_H__ +#define __MRTREE_H__ + +#include "badguy.hpp" + +class MrTree : public BadGuy +{ +public: + MrTree(const lisp::Lisp& reader); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + +protected: + enum MyState { + STATE_BIG, STATE_NORMAL + }; + MyState mystate; + + bool collision_squished(Player& player); +}; + +#endif diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index e88a0abe8..925e4de90 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -20,9 +20,9 @@ #include -#include "nolok_01.h" -#include "badguy/bouncing_snowball.h" -#include "trigger/door.h" +#include "nolok_01.hpp" +#include "badguy/bouncing_snowball.hpp" +#include "trigger/door.hpp" #define WALK_TIME 2.5 #define SHOOT_TIME 0.4 diff --git a/src/badguy/nolok_01.h b/src/badguy/nolok_01.h deleted file mode 100644 index a7cdc43ea..000000000 --- a/src/badguy/nolok_01.h +++ /dev/null @@ -1,47 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __NOLOK01_H__ -#define __NOLOK01_H__ - -#include "badguy.h" -#include "timer.h" - -class Nolok_01 : public BadGuy -{ -public: - Nolok_01(const lisp::Lisp& reader); - Nolok_01(float pos_x, float pos_y); - - void activate(); - void write(lisp::Writer& writer); - void active_update(float elapsed_time); - void kill_fall(); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - Timer action_timer; - enum Actions { WALKING, JUMPING, SHOOTING }; - Actions action; -}; - -#endif - diff --git a/src/badguy/nolok_01.hpp b/src/badguy/nolok_01.hpp new file mode 100644 index 000000000..fddb503b5 --- /dev/null +++ b/src/badguy/nolok_01.hpp @@ -0,0 +1,47 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __NOLOK01_H__ +#define __NOLOK01_H__ + +#include "badguy.hpp" +#include "timer.hpp" + +class Nolok_01 : public BadGuy +{ +public: + Nolok_01(const lisp::Lisp& reader); + Nolok_01(float pos_x, float pos_y); + + void activate(); + void write(lisp::Writer& writer); + void active_update(float elapsed_time); + void kill_fall(); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + Timer action_timer; + enum Actions { WALKING, JUMPING, SHOOTING }; + Actions action; +}; + +#endif + diff --git a/src/badguy/poisonivy.cpp b/src/badguy/poisonivy.cpp index cb38796e8..848f5600f 100644 --- a/src/badguy/poisonivy.cpp +++ b/src/badguy/poisonivy.cpp @@ -20,7 +20,7 @@ #include -#include "poisonivy.h" +#include "poisonivy.hpp" static const float WALKSPEED = 80; diff --git a/src/badguy/poisonivy.h b/src/badguy/poisonivy.h deleted file mode 100644 index 7d683bb0f..000000000 --- a/src/badguy/poisonivy.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __POISONIVY_H__ -#define __POISONIVY_H__ - -#include "badguy.h" - -class PoisonIvy : public BadGuy -{ -public: - PoisonIvy(const lisp::Lisp& reader); - PoisonIvy(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; -}; - -#endif diff --git a/src/badguy/poisonivy.hpp b/src/badguy/poisonivy.hpp new file mode 100644 index 000000000..7a34a22aa --- /dev/null +++ b/src/badguy/poisonivy.hpp @@ -0,0 +1,43 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __POISONIVY_H__ +#define __POISONIVY_H__ + +#include "badguy.hpp" + +class PoisonIvy : public BadGuy +{ +public: + PoisonIvy(const lisp::Lisp& reader); + PoisonIvy(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; +}; + +#endif diff --git a/src/badguy/rocketexplosion.cpp b/src/badguy/rocketexplosion.cpp index f1d79e782..e79e847d8 100644 --- a/src/badguy/rocketexplosion.cpp +++ b/src/badguy/rocketexplosion.cpp @@ -20,7 +20,7 @@ #include -#include "rocketexplosion.h" +#include "rocketexplosion.hpp" static const float EXPLOSIONTIME = 1; diff --git a/src/badguy/rocketexplosion.h b/src/badguy/rocketexplosion.h deleted file mode 100644 index 60a3f134a..000000000 --- a/src/badguy/rocketexplosion.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __BOMB_H__ -#define __BOMB_H__ - -#include "badguy.h" - -class RocketExplosion : public BadGuy -{ -public: - RocketExplosion(const Vector& pos, Direction dir); - - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_player(Player& player, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - void active_update(float elapsed_time); - void kill_fall(); - void explode(); - -private: - Timer timer; -}; - -#endif - diff --git a/src/badguy/rocketexplosion.hpp b/src/badguy/rocketexplosion.hpp new file mode 100644 index 000000000..d5b7a79b8 --- /dev/null +++ b/src/badguy/rocketexplosion.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __BOMB_H__ +#define __BOMB_H__ + +#include "badguy.hpp" + +class RocketExplosion : public BadGuy +{ +public: + RocketExplosion(const Vector& pos, Direction dir); + + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_player(Player& player, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); + void active_update(float elapsed_time); + void kill_fall(); + void explode(); + +private: + Timer timer; +}; + +#endif + diff --git a/src/badguy/snowball.cpp b/src/badguy/snowball.cpp index 1db1eb5d7..66ac4311b 100644 --- a/src/badguy/snowball.cpp +++ b/src/badguy/snowball.cpp @@ -20,7 +20,7 @@ #include -#include "snowball.h" +#include "snowball.hpp" static const float WALKSPEED = 80; diff --git a/src/badguy/snowball.h b/src/badguy/snowball.h deleted file mode 100644 index 46df80978..000000000 --- a/src/badguy/snowball.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __SNOWBALL_H__ -#define __SNOWBALL_H__ - -#include "badguy.h" - -class SnowBall : public BadGuy -{ -public: - SnowBall(const lisp::Lisp& reader); - SnowBall(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; -}; - -#endif - diff --git a/src/badguy/snowball.hpp b/src/badguy/snowball.hpp new file mode 100644 index 000000000..3e340340c --- /dev/null +++ b/src/badguy/snowball.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __SNOWBALL_H__ +#define __SNOWBALL_H__ + +#include "badguy.hpp" + +class SnowBall : public BadGuy +{ +public: + SnowBall(const lisp::Lisp& reader); + SnowBall(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; +}; + +#endif + diff --git a/src/badguy/spike.cpp b/src/badguy/spike.cpp index 0db1dfb1d..eded3f9cf 100644 --- a/src/badguy/spike.cpp +++ b/src/badguy/spike.cpp @@ -19,7 +19,7 @@ // 02111-1307, USA. #include -#include "spike.h" +#include "spike.hpp" Spike::Spike(const Vector& pos, Direction dir) { diff --git a/src/badguy/spike.h b/src/badguy/spike.h deleted file mode 100644 index 2cada0736..000000000 --- a/src/badguy/spike.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __SPIKE_H__ -#define __SPIKE_H__ - -#include "badguy.h" - -class Spike : public BadGuy -{ -public: - enum Direction { - NORTH=0, SOUTH, WEST, EAST - }; - Spike(const Vector& pos, Direction dir); - Spike(const lisp::Lisp& reader); - - void active_update(float elapsed_time); - void write(lisp::Writer& writer); - void kill_fall(); -private: - void set_direction(Direction dir); - Direction spikedir; -}; - -#endif - diff --git a/src/badguy/spike.hpp b/src/badguy/spike.hpp new file mode 100644 index 000000000..bdfea108e --- /dev/null +++ b/src/badguy/spike.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __SPIKE_H__ +#define __SPIKE_H__ + +#include "badguy.hpp" + +class Spike : public BadGuy +{ +public: + enum Direction { + NORTH=0, SOUTH, WEST, EAST + }; + Spike(const Vector& pos, Direction dir); + Spike(const lisp::Lisp& reader); + + void active_update(float elapsed_time); + void write(lisp::Writer& writer); + void kill_fall(); +private: + void set_direction(Direction dir); + Direction spikedir; +}; + +#endif + diff --git a/src/badguy/spiky.cpp b/src/badguy/spiky.cpp index 7a71c3df0..04368833d 100644 --- a/src/badguy/spiky.cpp +++ b/src/badguy/spiky.cpp @@ -20,7 +20,7 @@ #include -#include "spiky.h" +#include "spiky.hpp" static const float WALKSPEED = 80; diff --git a/src/badguy/spiky.h b/src/badguy/spiky.h deleted file mode 100644 index 981a928bb..000000000 --- a/src/badguy/spiky.h +++ /dev/null @@ -1,37 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __SPIKY_H__ -#define __SPIKY_H__ - -#include "badguy.h" - -class Spiky : public BadGuy -{ -public: - Spiky(const lisp::Lisp& reader); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); -}; - -#endif diff --git a/src/badguy/spiky.hpp b/src/badguy/spiky.hpp new file mode 100644 index 000000000..8f679c413 --- /dev/null +++ b/src/badguy/spiky.hpp @@ -0,0 +1,37 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __SPIKY_H__ +#define __SPIKY_H__ + +#include "badguy.hpp" + +class Spiky : public BadGuy +{ +public: + Spiky(const lisp::Lisp& reader); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); +}; + +#endif diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 82d47f22e..4b697f0e7 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -20,7 +20,7 @@ #include -#include "stalactite.h" +#include "stalactite.hpp" static const int SHAKE_RANGE = 40; static const float SHAKE_TIME = .8; diff --git a/src/badguy/stalactite.h b/src/badguy/stalactite.h deleted file mode 100644 index f193f5407..000000000 --- a/src/badguy/stalactite.h +++ /dev/null @@ -1,53 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __STALACTITE_H__ -#define __STALACTITE_H__ - -#include "badguy.h" - -class Stalactite : public BadGuy -{ -public: - Stalactite(const lisp::Lisp& reader); - - void active_update(float elapsed_time); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - HitResponse collision_player(Player& player, const CollisionHit& hit); - - void kill_fall(); - void draw(DrawingContext& context); - void deactivate(); - -protected: - Timer timer; - - enum StalactiteState { - STALACTITE_HANGING, - STALACTITE_SHAKING, - STALACTITE_FALLING, - STALACTITE_SQUISHED - }; - StalactiteState state; -}; - -#endif - diff --git a/src/badguy/stalactite.hpp b/src/badguy/stalactite.hpp new file mode 100644 index 000000000..ed221cbf0 --- /dev/null +++ b/src/badguy/stalactite.hpp @@ -0,0 +1,53 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __STALACTITE_H__ +#define __STALACTITE_H__ + +#include "badguy.hpp" + +class Stalactite : public BadGuy +{ +public: + Stalactite(const lisp::Lisp& reader); + + void active_update(float elapsed_time); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_player(Player& player, const CollisionHit& hit); + + void kill_fall(); + void draw(DrawingContext& context); + void deactivate(); + +protected: + Timer timer; + + enum StalactiteState { + STALACTITE_HANGING, + STALACTITE_SHAKING, + STALACTITE_FALLING, + STALACTITE_SQUISHED + }; + StalactiteState state; +}; + +#endif + diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 60fac3e65..fef1be337 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -22,12 +22,12 @@ #include #include #include -#include "yeti.h" -#include "object/camera.h" -#include "yeti_stalactite.h" -#include "bouncing_snowball.h" -#include "game_session.h" -#include "scripting/script_interpreter.h" +#include "yeti.hpp" +#include "object/camera.hpp" +#include "yeti_stalactite.hpp" +#include "bouncing_snowball.hpp" +#include "game_session.hpp" +#include "scripting/script_interpreter.hpp" static const float JUMP_VEL1 = 250; static const float JUMP_VEL2 = 700; diff --git a/src/badguy/yeti.h b/src/badguy/yeti.h deleted file mode 100644 index 1f14a6b98..000000000 --- a/src/badguy/yeti.h +++ /dev/null @@ -1,62 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __YETI_H__ -#define __YETI_H__ - -#include "badguy.h" - -class Yeti : public BadGuy -{ -public: - Yeti(const lisp::Lisp& lisp); - ~Yeti(); - - void draw(DrawingContext& context); - void write(lisp::Writer& writer); - void active_update(float elapsed_time); - HitResponse collision_solid(GameObject& object, const CollisionHit& hit); - bool collision_squished(Player& player); - void kill_fall(); - -private: - void go_right(); - void go_left(); - void angry_jumping(); - void drop_stalactite(); - void summon_snowball(); - - enum YetiState { - INIT, - ANGRY_JUMPING, - THROW_SNOWBALL, - GO_RIGHT, - GO_LEFT - }; - Direction side; - YetiState state; - Timer timer; - Timer safe_timer; - int jumpcount; - int hit_points; - std::string dead_script; -}; - -#endif - diff --git a/src/badguy/yeti.hpp b/src/badguy/yeti.hpp new file mode 100644 index 000000000..a66434765 --- /dev/null +++ b/src/badguy/yeti.hpp @@ -0,0 +1,62 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __YETI_H__ +#define __YETI_H__ + +#include "badguy.hpp" + +class Yeti : public BadGuy +{ +public: + Yeti(const lisp::Lisp& lisp); + ~Yeti(); + + void draw(DrawingContext& context); + void write(lisp::Writer& writer); + void active_update(float elapsed_time); + HitResponse collision_solid(GameObject& object, const CollisionHit& hit); + bool collision_squished(Player& player); + void kill_fall(); + +private: + void go_right(); + void go_left(); + void angry_jumping(); + void drop_stalactite(); + void summon_snowball(); + + enum YetiState { + INIT, + ANGRY_JUMPING, + THROW_SNOWBALL, + GO_RIGHT, + GO_LEFT + }; + Direction side; + YetiState state; + Timer timer; + Timer safe_timer; + int jumpcount; + int hit_points; + std::string dead_script; +}; + +#endif + diff --git a/src/badguy/yeti_stalactite.cpp b/src/badguy/yeti_stalactite.cpp index 0d1545bc1..52ef203bb 100644 --- a/src/badguy/yeti_stalactite.cpp +++ b/src/badguy/yeti_stalactite.cpp @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. -#include "yeti_stalactite.h" +#include "yeti_stalactite.hpp" static const float SHAKE_TIME = .8; diff --git a/src/badguy/yeti_stalactite.h b/src/badguy/yeti_stalactite.h deleted file mode 100644 index baca48ff8..000000000 --- a/src/badguy/yeti_stalactite.h +++ /dev/null @@ -1,38 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __YETI_STALACTITE_H__ -#define __YETI_STALACTITE_H__ - -#include "stalactite.h" - -class YetiStalactite : public Stalactite -{ -public: - YetiStalactite(const lisp::Lisp& lisp); - virtual ~YetiStalactite(); - - void active_update(float elapsed_time); - void start_shaking(); - bool is_hanging(); -}; - -#endif - diff --git a/src/badguy/yeti_stalactite.hpp b/src/badguy/yeti_stalactite.hpp new file mode 100644 index 000000000..1a9faa114 --- /dev/null +++ b/src/badguy/yeti_stalactite.hpp @@ -0,0 +1,38 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __YETI_STALACTITE_H__ +#define __YETI_STALACTITE_H__ + +#include "stalactite.hpp" + +class YetiStalactite : public Stalactite +{ +public: + YetiStalactite(const lisp::Lisp& lisp); + virtual ~YetiStalactite(); + + void active_update(float elapsed_time); + void start_shaking(); + bool is_hanging(); +}; + +#endif + diff --git a/src/badguy/zeekling.cpp b/src/badguy/zeekling.cpp index 7d42577e3..0b2758d06 100644 --- a/src/badguy/zeekling.cpp +++ b/src/badguy/zeekling.cpp @@ -21,7 +21,7 @@ #include #include -#include "zeekling.h" +#include "zeekling.hpp" //TODO: Make the Zeekling behave more interesting diff --git a/src/badguy/zeekling.h b/src/badguy/zeekling.h deleted file mode 100644 index de2a775b0..000000000 --- a/src/badguy/zeekling.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __ZEEKLING_H__ -#define __ZEEKLING_H__ - -#include "badguy.h" - -class Zeekling : public BadGuy -{ -public: - Zeekling(const lisp::Lisp& reader); - Zeekling(float pos_x, float pos_y, Direction d); - - void activate(); - void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); - -protected: - bool collision_squished(Player& player); - bool set_direction; - Direction initial_direction; - float speed; -}; - -#endif - diff --git a/src/badguy/zeekling.hpp b/src/badguy/zeekling.hpp new file mode 100644 index 000000000..7dc18af73 --- /dev/null +++ b/src/badguy/zeekling.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __ZEEKLING_H__ +#define __ZEEKLING_H__ + +#include "badguy.hpp" + +class Zeekling : public BadGuy +{ +public: + Zeekling(const lisp::Lisp& reader); + Zeekling(float pos_x, float pos_y, Direction d); + + void activate(); + void write(lisp::Writer& writer); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + +protected: + bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; + float speed; +}; + +#endif + diff --git a/src/collision.cpp b/src/collision.cpp index cce522d5d..ad87f8918 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -19,17 +19,17 @@ // 02111-1307, USA. #include -#include "collision.h" +#include "collision.hpp" #include #include #include #include #include -#include "math/vector.h" -#include "math/aatriangle.h" -#include "math/rect.h" -#include "collision_hit.h" +#include "math/vector.hpp" +#include "math/aatriangle.hpp" +#include "math/rect.hpp" +#include "collision_hit.hpp" static const float DELTA = .0001; diff --git a/src/collision.h b/src/collision.h deleted file mode 100644 index d4f58825a..000000000 --- a/src/collision.h +++ /dev/null @@ -1,46 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __COLLISION_H__ -#define __COLLISION_H__ - -class Vector; -class Rect; -class AATriangle; -class CollisionHit; - -class Collision -{ -public: - /** does collision detection between 2 rectangles. Returns true in case of - * collision and fills in the hit structure then. - */ - static bool rectangle_rectangle(CollisionHit& hit, const Rect& r1, - const Vector& movement, const Rect& r2); - - /** does collision detection between a rectangle and an axis aligned triangle - * Returns true in case of a collision and fills in the hit structure then. - */ - static bool rectangle_aatriangle(CollisionHit& hit, const Rect& rect, - const Vector& movement, const AATriangle& triangle); -}; - -#endif - diff --git a/src/collision.hpp b/src/collision.hpp new file mode 100644 index 000000000..d4f58825a --- /dev/null +++ b/src/collision.hpp @@ -0,0 +1,46 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __COLLISION_H__ +#define __COLLISION_H__ + +class Vector; +class Rect; +class AATriangle; +class CollisionHit; + +class Collision +{ +public: + /** does collision detection between 2 rectangles. Returns true in case of + * collision and fills in the hit structure then. + */ + static bool rectangle_rectangle(CollisionHit& hit, const Rect& r1, + const Vector& movement, const Rect& r2); + + /** does collision detection between a rectangle and an axis aligned triangle + * Returns true in case of a collision and fills in the hit structure then. + */ + static bool rectangle_aatriangle(CollisionHit& hit, const Rect& rect, + const Vector& movement, const AATriangle& triangle); +}; + +#endif + diff --git a/src/collision_grid.cpp b/src/collision_grid.cpp index 6ed8e4cc3..bf6cc9332 100644 --- a/src/collision_grid.cpp +++ b/src/collision_grid.cpp @@ -21,10 +21,10 @@ #include #include -#include "collision_grid.h" -#include "collision.h" -#include "sector.h" -#include "collision_grid_iterator.h" +#include "collision_grid.hpp" +#include "collision.hpp" +#include "sector.hpp" +#include "collision_grid_iterator.hpp" static const float DELTA = .001; diff --git a/src/collision_grid.h b/src/collision_grid.h deleted file mode 100644 index abb2ef168..000000000 --- a/src/collision_grid.h +++ /dev/null @@ -1,86 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __COLLISION_GRID_H__ -#define __COLLISION_GRID_H__ - -#include -#include "moving_object.h" - -class CollisionGridIterator; - -/** - * A rectangular grid to keep track of all moving game objects. It allows fast - * queries for all objects in a rectangular area. - */ -class CollisionGrid -{ -public: - CollisionGrid(float width, float height); - ~CollisionGrid(); - - void add_object(MovingObject* object); - void remove_object(MovingObject* object); - - void check_collisions(); - -private: - friend class CollisionGridIterator; - - struct ObjectWrapper - { - MovingObject* object; - Rect dest; - /** (pseudo) timestamp. When reading from the grid the timestamp is - * changed so that you can easily avoid reading an object multiple times - * when it is in several cells that you check. - */ - int timestamp; - /// index in the objects vector - int id; - }; - - /** Element for the single linked list in each grid cell */ - struct GridEntry - { - GridEntry* next; - ObjectWrapper* object_wrapper; - }; - - void remove_object_from_gridcell(int gridcell, ObjectWrapper* wrapper); - void collide_object(ObjectWrapper* wrapper); - void collide_object_object(ObjectWrapper* wrapper, ObjectWrapper* wrapper2); - void move_object(ObjectWrapper* wrapper); - - typedef std::vector GridEntries; - GridEntries grid; - typedef std::vector Objects; - Objects objects; - size_t cells_x, cells_y; - float width; - float height; - float cell_width; - float cell_height; - int iterator_timestamp; -}; - -extern CollisionGrid* bla; - -#endif - diff --git a/src/collision_grid.hpp b/src/collision_grid.hpp new file mode 100644 index 000000000..005eb7f3a --- /dev/null +++ b/src/collision_grid.hpp @@ -0,0 +1,86 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __COLLISION_GRID_H__ +#define __COLLISION_GRID_H__ + +#include +#include "moving_object.hpp" + +class CollisionGridIterator; + +/** + * A rectangular grid to keep track of all moving game objects. It allows fast + * queries for all objects in a rectangular area. + */ +class CollisionGrid +{ +public: + CollisionGrid(float width, float height); + ~CollisionGrid(); + + void add_object(MovingObject* object); + void remove_object(MovingObject* object); + + void check_collisions(); + +private: + friend class CollisionGridIterator; + + struct ObjectWrapper + { + MovingObject* object; + Rect dest; + /** (pseudo) timestamp. When reading from the grid the timestamp is + * changed so that you can easily avoid reading an object multiple times + * when it is in several cells that you check. + */ + int timestamp; + /// index in the objects vector + int id; + }; + + /** Element for the single linked list in each grid cell */ + struct GridEntry + { + GridEntry* next; + ObjectWrapper* object_wrapper; + }; + + void remove_object_from_gridcell(int gridcell, ObjectWrapper* wrapper); + void collide_object(ObjectWrapper* wrapper); + void collide_object_object(ObjectWrapper* wrapper, ObjectWrapper* wrapper2); + void move_object(ObjectWrapper* wrapper); + + typedef std::vector GridEntries; + GridEntries grid; + typedef std::vector Objects; + Objects objects; + size_t cells_x, cells_y; + float width; + float height; + float cell_width; + float cell_height; + int iterator_timestamp; +}; + +extern CollisionGrid* bla; + +#endif + diff --git a/src/collision_grid_iterator.h b/src/collision_grid_iterator.h deleted file mode 100644 index 3d5666161..000000000 --- a/src/collision_grid_iterator.h +++ /dev/null @@ -1,107 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __COLLISION_GRID_ITERATOR_H__ -#define __COLLISION_GRID_ITERATOR_H__ - -#include "math/rect.h" - -class CollisionGrid; - -class CollisionGridIterator -{ -public: - CollisionGridIterator(CollisionGrid& newgrid, const Rect& bbox) - : grid(newgrid) - { - start_x = int(bbox.p1.x / grid.cell_width) - 2; - if(start_x < 0) - start_x = 0; - x = start_x; - - y = int(bbox.p1.y / grid.cell_height) - 2; - if(y < 0) - y = 0; - - end_x = int(bbox.p2.x / grid.cell_width) + 2; - if(end_x > (int) grid.cells_x) - end_x = grid.cells_x; - - end_y = int(bbox.p2.y / grid.cell_height) + 2; - if(end_y > (int) grid.cells_y) - end_y = grid.cells_y; - - if(start_x >= end_x) { - printf("bad region.\n"); - y = 0; - end_y = 0; - return; - } - - timestamp = grid.iterator_timestamp++; - entry = 0; - } - - MovingObject* next() - { - CollisionGrid::ObjectWrapper* wrapper = next_wrapper(); - if(wrapper == 0) - return 0; - - return wrapper->object; - } - -private: - friend class CollisionGrid; - - CollisionGrid::ObjectWrapper* next_wrapper() - { - CollisionGrid::ObjectWrapper* wrapper; - - do { - while(entry == 0) { - if(y >= end_y) - return 0; - - entry = grid.grid[y*grid.cells_x + x]; - x++; - if(x >= end_x) { - x = start_x; - y++; - } - } - - wrapper = entry->object_wrapper; - entry = entry->next; - } while(wrapper->timestamp == timestamp); - - wrapper->timestamp = timestamp; - - return wrapper; - } - - CollisionGrid& grid; - CollisionGrid::GridEntry* entry; - int x, y; - int start_x, end_x, end_y; - int timestamp; -}; - -#endif - diff --git a/src/collision_grid_iterator.hpp b/src/collision_grid_iterator.hpp new file mode 100644 index 000000000..0f7877778 --- /dev/null +++ b/src/collision_grid_iterator.hpp @@ -0,0 +1,107 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __COLLISION_GRID_ITERATOR_H__ +#define __COLLISION_GRID_ITERATOR_H__ + +#include "math/rect.hpp" + +class CollisionGrid; + +class CollisionGridIterator +{ +public: + CollisionGridIterator(CollisionGrid& newgrid, const Rect& bbox) + : grid(newgrid) + { + start_x = int(bbox.p1.x / grid.cell_width) - 2; + if(start_x < 0) + start_x = 0; + x = start_x; + + y = int(bbox.p1.y / grid.cell_height) - 2; + if(y < 0) + y = 0; + + end_x = int(bbox.p2.x / grid.cell_width) + 2; + if(end_x > (int) grid.cells_x) + end_x = grid.cells_x; + + end_y = int(bbox.p2.y / grid.cell_height) + 2; + if(end_y > (int) grid.cells_y) + end_y = grid.cells_y; + + if(start_x >= end_x) { + printf("bad region.\n"); + y = 0; + end_y = 0; + return; + } + + timestamp = grid.iterator_timestamp++; + entry = 0; + } + + MovingObject* next() + { + CollisionGrid::ObjectWrapper* wrapper = next_wrapper(); + if(wrapper == 0) + return 0; + + return wrapper->object; + } + +private: + friend class CollisionGrid; + + CollisionGrid::ObjectWrapper* next_wrapper() + { + CollisionGrid::ObjectWrapper* wrapper; + + do { + while(entry == 0) { + if(y >= end_y) + return 0; + + entry = grid.grid[y*grid.cells_x + x]; + x++; + if(x >= end_x) { + x = start_x; + y++; + } + } + + wrapper = entry->object_wrapper; + entry = entry->next; + } while(wrapper->timestamp == timestamp); + + wrapper->timestamp = timestamp; + + return wrapper; + } + + CollisionGrid& grid; + CollisionGrid::GridEntry* entry; + int x, y; + int start_x, end_x, end_y; + int timestamp; +}; + +#endif + diff --git a/src/collision_hit.h b/src/collision_hit.h deleted file mode 100644 index 4c4ccec5b..000000000 --- a/src/collision_hit.h +++ /dev/null @@ -1,56 +0,0 @@ -// $Id: collision_hit.h 2177 2004-11-24 23:10:09Z matzebraun $ -// -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun -#include "codecontroller.h" +#include "codecontroller.hpp" CodeController::CodeController() {} diff --git a/src/control/codecontroller.h b/src/control/codecontroller.h deleted file mode 100644 index 46b2e9ca2..000000000 --- a/src/control/codecontroller.h +++ /dev/null @@ -1,40 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __CODECONTROLLER_H__ -#define __CODECONTROLLER_H__ - -#include "controller.h" - -/** - * This is a dummy controler that doesn't react to any user input but should - * be controlled by code - */ -class CodeController : public Controller -{ -public: - CodeController(); - virtual ~CodeController(); - - void press(Control c, bool pressed = true); - void update(); -}; - -#endif diff --git a/src/control/codecontroller.hpp b/src/control/codecontroller.hpp new file mode 100644 index 000000000..687ec5ffa --- /dev/null +++ b/src/control/codecontroller.hpp @@ -0,0 +1,40 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __CODECONTROLLER_H__ +#define __CODECONTROLLER_H__ + +#include "controller.hpp" + +/** + * This is a dummy controler that doesn't react to any user input but should + * be controlled by code + */ +class CodeController : public Controller +{ +public: + CodeController(); + virtual ~CodeController(); + + void press(Control c, bool pressed = true); + void update(); +}; + +#endif diff --git a/src/control/controller.cpp b/src/control/controller.cpp index f6f5ecb18..73f93afed 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -20,7 +20,7 @@ #include -#include "controller.h" +#include "controller.hpp" extern Controller* main_controller; diff --git a/src/control/controller.h b/src/control/controller.h deleted file mode 100644 index 50cdb17f1..000000000 --- a/src/control/controller.h +++ /dev/null @@ -1,60 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __CONTROLLER_H__ -#define __CONTROLLER_H__ - -class Controller -{ -public: - static const char* controlNames[]; - - enum Control { - LEFT = 0, - RIGHT, - UP, - DOWN, - JUMP, - ACTION, - PAUSE_MENU, - MENU_SELECT, - - CONTROLCOUNT - }; - - Controller(); - virtual ~Controller(); - - /** returns true if the control is pressed down */ - bool hold(Control control); - /** returns true if the control has just been pressed down this frame */ - bool pressed(Control control); - - virtual void reset(); - virtual void update(); - -protected: - /** current control status */ - bool controls[CONTROLCOUNT]; - /** control status at last frame */ - bool oldControls[CONTROLCOUNT]; -}; - -#endif diff --git a/src/control/controller.hpp b/src/control/controller.hpp new file mode 100644 index 000000000..50cdb17f1 --- /dev/null +++ b/src/control/controller.hpp @@ -0,0 +1,60 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __CONTROLLER_H__ +#define __CONTROLLER_H__ + +class Controller +{ +public: + static const char* controlNames[]; + + enum Control { + LEFT = 0, + RIGHT, + UP, + DOWN, + JUMP, + ACTION, + PAUSE_MENU, + MENU_SELECT, + + CONTROLCOUNT + }; + + Controller(); + virtual ~Controller(); + + /** returns true if the control is pressed down */ + bool hold(Control control); + /** returns true if the control has just been pressed down this frame */ + bool pressed(Control control); + + virtual void reset(); + virtual void update(); + +protected: + /** current control status */ + bool controls[CONTROLCOUNT]; + /** control status at last frame */ + bool oldControls[CONTROLCOUNT]; +}; + +#endif diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 6bebf6b3d..0fb4d9ee9 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -20,12 +20,12 @@ #include #include -#include "joystickkeyboardcontroller.h" -#include "gui/menu.h" -#include "gettext.h" -#include "lisp/lisp.h" -#include "lisp/list_iterator.h" -#include "game_session.h" +#include "joystickkeyboardcontroller.hpp" +#include "gui/menu.hpp" +#include "gettext.hpp" +#include "lisp/lisp.hpp" +#include "lisp/list_iterator.hpp" +#include "game_session.hpp" class JoystickKeyboardController::JoystickMenu : public Menu { diff --git a/src/control/joystickkeyboardcontroller.h b/src/control/joystickkeyboardcontroller.h deleted file mode 100644 index 2a5f52757..000000000 --- a/src/control/joystickkeyboardcontroller.h +++ /dev/null @@ -1,106 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __JOYSTICKKEYBOARDCONTROLLER_H__ -#define __JOYSTICKKEYBOARDCONTROLLER_H__ - -#include "controller.h" -#include "lisp/lisp.h" -#include "lisp/writer.h" -#include -#include -#include - -class Menu; - -class JoystickKeyboardController : public Controller -{ -public: - JoystickKeyboardController(); - virtual ~JoystickKeyboardController(); - - /** Process an SDL Event and return true if the event has been used - */ - void process_event(const SDL_Event& event); - - void write(lisp::Writer& writer); - void read(const lisp::Lisp& lisp); - bool check_cheatcode(const std::string& cheatcode); - void reset(); - - Menu* get_key_options_menu(); - Menu* get_joystick_options_menu(); - -private: - void process_menu_key_event(const SDL_Event& event); - - typedef std::map KeyMap; - KeyMap keymap; - - std::vector joysticks; - - typedef std::map ButtonMap; - ButtonMap joy_button_map; - std::string name; - bool use_hat; - int joyaxis_x; - int joyaxis_y; - int dead_zone_x; - int dead_zone_y; - /// the number of buttons all joysticks have - int min_joybuttons; - /// the max number of buttons a joystick has - int max_joybuttons; - - enum { - MNID_KEY_UP, - MNID_KEY_DOWN, - MNID_KEY_LEFT, - MNID_KEY_RIGHT, - MNID_KEY_JUMP, - MNID_KEY_ACTION - }; - enum { - MNID_JS_JUMP, - MNID_JS_ACTION, - MNID_JS_MENU, - MNID_JS_PAUSE - }; - SDLKey reversemap_key(Control c); - int reversemap_joybutton(Control c); - void reset_joybutton(int button, Control c); - void reset_key(SDLKey key, Control c); - - int wait_for_key; - int wait_for_joybutton; - - class KeyboardMenu; - class JoystickMenu; - - KeyboardMenu* key_options_menu; - JoystickMenu* joystick_options_menu; - friend class KeyboardMenu; - friend class JoystickMenu; - - char last_keys[20]; -}; - -#endif - diff --git a/src/control/joystickkeyboardcontroller.hpp b/src/control/joystickkeyboardcontroller.hpp new file mode 100644 index 000000000..a39f68bf0 --- /dev/null +++ b/src/control/joystickkeyboardcontroller.hpp @@ -0,0 +1,106 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __JOYSTICKKEYBOARDCONTROLLER_H__ +#define __JOYSTICKKEYBOARDCONTROLLER_H__ + +#include "controller.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include +#include +#include + +class Menu; + +class JoystickKeyboardController : public Controller +{ +public: + JoystickKeyboardController(); + virtual ~JoystickKeyboardController(); + + /** Process an SDL Event and return true if the event has been used + */ + void process_event(const SDL_Event& event); + + void write(lisp::Writer& writer); + void read(const lisp::Lisp& lisp); + bool check_cheatcode(const std::string& cheatcode); + void reset(); + + Menu* get_key_options_menu(); + Menu* get_joystick_options_menu(); + +private: + void process_menu_key_event(const SDL_Event& event); + + typedef std::map KeyMap; + KeyMap keymap; + + std::vector joysticks; + + typedef std::map ButtonMap; + ButtonMap joy_button_map; + std::string name; + bool use_hat; + int joyaxis_x; + int joyaxis_y; + int dead_zone_x; + int dead_zone_y; + /// the number of buttons all joysticks have + int min_joybuttons; + /// the max number of buttons a joystick has + int max_joybuttons; + + enum { + MNID_KEY_UP, + MNID_KEY_DOWN, + MNID_KEY_LEFT, + MNID_KEY_RIGHT, + MNID_KEY_JUMP, + MNID_KEY_ACTION + }; + enum { + MNID_JS_JUMP, + MNID_JS_ACTION, + MNID_JS_MENU, + MNID_JS_PAUSE + }; + SDLKey reversemap_key(Control c); + int reversemap_joybutton(Control c); + void reset_joybutton(int button, Control c); + void reset_key(SDLKey key, Control c); + + int wait_for_key; + int wait_for_joybutton; + + class KeyboardMenu; + class JoystickMenu; + + KeyboardMenu* key_options_menu; + JoystickMenu* joystick_options_menu; + friend class KeyboardMenu; + friend class JoystickMenu; + + char last_keys[20]; +}; + +#endif + diff --git a/src/direction.h b/src/direction.h deleted file mode 100644 index 5ecc417bc..000000000 --- a/src/direction.h +++ /dev/null @@ -1,27 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2000 Bill Kendrick -// Copyright (C) 2004 Tobias Glaesser -// -// 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_DIRECTION_H -#define SUPERTUX_DIRECTION_H - -enum Direction { LEFT = 0, RIGHT = 1 }; - -#endif /*SUPERTUX_DEFINES_H*/ - diff --git a/src/direction.hpp b/src/direction.hpp new file mode 100644 index 000000000..5ecc417bc --- /dev/null +++ b/src/direction.hpp @@ -0,0 +1,27 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2000 Bill Kendrick +// Copyright (C) 2004 Tobias Glaesser +// +// 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_DIRECTION_H +#define SUPERTUX_DIRECTION_H + +enum Direction { LEFT = 0, RIGHT = 1 }; + +#endif /*SUPERTUX_DEFINES_H*/ + diff --git a/src/file_system.cpp b/src/file_system.cpp index 8d8b811b0..4989540c4 100644 --- a/src/file_system.cpp +++ b/src/file_system.cpp @@ -1,6 +1,6 @@ #include -#include "file_system.h" +#include "file_system.hpp" #include diff --git a/src/file_system.h b/src/file_system.h deleted file mode 100644 index 47f86f4a3..000000000 --- a/src/file_system.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __FILESYSTEM_H__ -#define __FILESYSTEM_H__ - -#include -#include - -namespace FileSystem -{ - std::string dirname(const std::string& filename); - std::string basename(const std::string& filename); -} - -#endif - diff --git a/src/file_system.hpp b/src/file_system.hpp new file mode 100644 index 000000000..47f86f4a3 --- /dev/null +++ b/src/file_system.hpp @@ -0,0 +1,14 @@ +#ifndef __FILESYSTEM_H__ +#define __FILESYSTEM_H__ + +#include +#include + +namespace FileSystem +{ + std::string dirname(const std::string& filename); + std::string basename(const std::string& filename); +} + +#endif + diff --git a/src/flip_level_transformer.cpp b/src/flip_level_transformer.cpp index 0ac481623..73fe33bef 100644 --- a/src/flip_level_transformer.cpp +++ b/src/flip_level_transformer.cpp @@ -19,13 +19,13 @@ // 02111-1307, USA. #include -#include "flip_level_transformer.h" -#include "object/tilemap.h" -#include "object/camera.h" -#include "badguy/badguy.h" -#include "sector.h" -#include "tile_manager.h" -#include "spawn_point.h" +#include "flip_level_transformer.hpp" +#include "object/tilemap.hpp" +#include "object/camera.hpp" +#include "badguy/badguy.hpp" +#include "sector.hpp" +#include "tile_manager.hpp" +#include "spawn_point.hpp" void FlipLevelTransformer::transform_sector(Sector* sector) diff --git a/src/flip_level_transformer.h b/src/flip_level_transformer.h deleted file mode 100644 index 79b7b0297..000000000 --- a/src/flip_level_transformer.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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 __FLIP_LEVEL_TRANSFORMER_H__ -#define __FLIP_LEVEL_TRANSFORMER_H__ - -#include "level_transformer.h" - -class TileMap; -class BadGuy; -class SpawnPoint; -class MovingObject; - -/** Vertically or horizontally flip a level */ -class FlipLevelTransformer : public LevelTransformer -{ -public: - virtual void transform_sector(Sector* sector); - -private: - void transform_tilemap(TileMap* tilemap); - void transform_moving_object(float height, MovingObject* object); - void transform_badguy(float height, BadGuy* badguy); - void transform_spawnpoint(float height, SpawnPoint* spawnpoint); -}; - -#endif - diff --git a/src/flip_level_transformer.hpp b/src/flip_level_transformer.hpp new file mode 100644 index 000000000..cecc6512e --- /dev/null +++ b/src/flip_level_transformer.hpp @@ -0,0 +1,44 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 __FLIP_LEVEL_TRANSFORMER_H__ +#define __FLIP_LEVEL_TRANSFORMER_H__ + +#include "level_transformer.hpp" + +class TileMap; +class BadGuy; +class SpawnPoint; +class MovingObject; + +/** Vertically or horizontally flip a level */ +class FlipLevelTransformer : public LevelTransformer +{ +public: + virtual void transform_sector(Sector* sector); + +private: + void transform_tilemap(TileMap* tilemap); + void transform_moving_object(float height, MovingObject* object); + void transform_badguy(float height, BadGuy* badguy); + void transform_spawnpoint(float height, SpawnPoint* spawnpoint); +}; + +#endif + diff --git a/src/game_object.cpp b/src/game_object.cpp index 40d405662..c63dbf12b 100644 --- a/src/game_object.cpp +++ b/src/game_object.cpp @@ -19,8 +19,8 @@ #include -#include "game_object.h" -#include "object_remove_listener.h" +#include "game_object.hpp" +#include "object_remove_listener.hpp" GameObject::GameObject() : wants_to_die(false), remove_listeners(0), flags(0) diff --git a/src/game_object.h b/src/game_object.h deleted file mode 100644 index 1131847fb..000000000 --- a/src/game_object.h +++ /dev/null @@ -1,109 +0,0 @@ -// $Id: game_object.h 2293 2005-03-25 20:39:56Z matzebraun $ -// -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun -// -// 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_GAMEOBJECT_H -#define SUPERTUX_GAMEOBJECT_H - -#include - -class DrawingContext; -class ObjectRemoveListener; - -/** - * This is a base class for all game objects. Each sector of a level will hold a - * list of active GameObject while the game is played. - * - * This class is responsible for: - * - Updating and Drawing the object. This should happen in the update() and - * draw() functions. Both are called once per frame. - * - Providing a safe way to remove the object by calling the remove_me - * functions. - * - a 32bit bitset for flags... - */ -class GameObject -{ -public: - GameObject(); - virtual ~GameObject(); - - /** This function is called once per frame and allows the object to update - * it's state. The elapsed_time is the time since the last frame in - * seconds and should be the base for all timed calculations (don't use - * SDL_GetTicks directly as this will fail in pause mode) - */ - virtual void update(float elapsed_time) = 0; - - /** The GameObject should draw itself onto the provided DrawingContext if this - * function is called. - */ - virtual void draw(DrawingContext& context) = 0; - - /** returns true if the object is not scheduled to be removed yet */ - bool is_valid() const - { - return !wants_to_die; - } - /** schedules this object to be removed at the end of the frame */ - void remove_me() - { - wants_to_die = true; - } - /** registers a remove listener which will be called if the object - * gets removed/destroyed - */ - void add_remove_listener(ObjectRemoveListener* listener) - { - RemoveListenerListEntry* entry = new RemoveListenerListEntry(); - entry->next = remove_listeners; - entry->listener = listener; - - remove_listeners = entry; - } - - // flags - enum { - /// the tile so you can stand on it - FLAG_SOLID = 0x0001, - /// can be used to temporatily disable collision detection - FLAG_NO_COLLDET = 0x0002 - }; - - int get_flags() const - { - return flags; - } - -private: - /** this flag indicates if the object should be removed at the end of the - * frame - */ - bool wants_to_die; - - struct RemoveListenerListEntry - { - RemoveListenerListEntry* next; - ObjectRemoveListener* listener; - }; - RemoveListenerListEntry* remove_listeners; - -protected: - int flags; -}; - -#endif /*SUPERTUX_GAMEOBJECT_H*/ - diff --git a/src/game_object.hpp b/src/game_object.hpp new file mode 100644 index 000000000..1131847fb --- /dev/null +++ b/src/game_object.hpp @@ -0,0 +1,109 @@ +// $Id: game_object.h 2293 2005-03-25 20:39:56Z matzebraun $ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun +// +// 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_GAMEOBJECT_H +#define SUPERTUX_GAMEOBJECT_H + +#include + +class DrawingContext; +class ObjectRemoveListener; + +/** + * This is a base class for all game objects. Each sector of a level will hold a + * list of active GameObject while the game is played. + * + * This class is responsible for: + * - Updating and Drawing the object. This should happen in the update() and + * draw() functions. Both are called once per frame. + * - Providing a safe way to remove the object by calling the remove_me + * functions. + * - a 32bit bitset for flags... + */ +class GameObject +{ +public: + GameObject(); + virtual ~GameObject(); + + /** This function is called once per frame and allows the object to update + * it's state. The elapsed_time is the time since the last frame in + * seconds and should be the base for all timed calculations (don't use + * SDL_GetTicks directly as this will fail in pause mode) + */ + virtual void update(float elapsed_time) = 0; + + /** The GameObject should draw itself onto the provided DrawingContext if this + * function is called. + */ + virtual void draw(DrawingContext& context) = 0; + + /** returns true if the object is not scheduled to be removed yet */ + bool is_valid() const + { + return !wants_to_die; + } + /** schedules this object to be removed at the end of the frame */ + void remove_me() + { + wants_to_die = true; + } + /** registers a remove listener which will be called if the object + * gets removed/destroyed + */ + void add_remove_listener(ObjectRemoveListener* listener) + { + RemoveListenerListEntry* entry = new RemoveListenerListEntry(); + entry->next = remove_listeners; + entry->listener = listener; + + remove_listeners = entry; + } + + // flags + enum { + /// the tile so you can stand on it + FLAG_SOLID = 0x0001, + /// can be used to temporatily disable collision detection + FLAG_NO_COLLDET = 0x0002 + }; + + int get_flags() const + { + return flags; + } + +private: + /** this flag indicates if the object should be removed at the end of the + * frame + */ + bool wants_to_die; + + struct RemoveListenerListEntry + { + RemoveListenerListEntry* next; + ObjectRemoveListener* listener; + }; + RemoveListenerListEntry* remove_listeners; + +protected: + int flags; +}; + +#endif /*SUPERTUX_GAMEOBJECT_H*/ + diff --git a/src/game_session.cpp b/src/game_session.cpp index d8e2204b4..d6d10d3f0 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -35,34 +35,34 @@ #include -#include "game_session.h" -#include "video/screen.h" -#include "audio/sound_manager.h" -#include "gui/menu.h" -#include "sector.h" -#include "level.h" -#include "tile.h" -#include "player_status.h" -#include "object/particlesystem.h" -#include "object/background.h" -#include "object/tilemap.h" -#include "object/camera.h" -#include "object/player.h" -#include "lisp/lisp.h" -#include "lisp/parser.h" -#include "resources.h" -#include "worldmap.h" -#include "misc.h" -#include "statistics.h" -#include "timer.h" -#include "object/fireworks.h" -#include "textscroller.h" -#include "control/codecontroller.h" -#include "control/joystickkeyboardcontroller.h" -#include "main.h" -#include "file_system.h" -#include "gameconfig.h" -#include "gettext.h" +#include "game_session.hpp" +#include "video/screen.hpp" +#include "audio/sound_manager.hpp" +#include "gui/menu.hpp" +#include "sector.hpp" +#include "level.hpp" +#include "tile.hpp" +#include "player_status.hpp" +#include "object/particlesystem.hpp" +#include "object/background.hpp" +#include "object/tilemap.hpp" +#include "object/camera.hpp" +#include "object/player.hpp" +#include "lisp/lisp.hpp" +#include "lisp/parser.hpp" +#include "resources.hpp" +#include "worldmap.hpp" +#include "misc.hpp" +#include "statistics.hpp" +#include "timer.hpp" +#include "object/fireworks.hpp" +#include "textscroller.hpp" +#include "control/codecontroller.hpp" +#include "control/joystickkeyboardcontroller.hpp" +#include "main.hpp" +#include "file_system.hpp" +#include "gameconfig.hpp" +#include "gettext.hpp" // the engine will be run with a logical framerate of 64fps. // We chose 64fps here because it is a power of 2, so 1/64 gives an "even" diff --git a/src/game_session.h b/src/game_session.h deleted file mode 100644 index 9c5d381b5..000000000 --- a/src/game_session.h +++ /dev/null @@ -1,168 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2004 Bill Kendrick -// Tobias Glaesser -// Ingo Ruhnke -// -// 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_GAMELOOP_H -#define SUPERTUX_GAMELOOP_H - -#include -#include -#include "timer.h" -#include "statistics.h" -#include "math/vector.h" - -/* GameLoop modes */ -enum GameSessionMode { - ST_GL_PLAY, - ST_GL_TEST, - ST_GL_LOAD_GAME, - ST_GL_LOAD_LEVEL_FILE, - ST_GL_DEMO_GAME -}; - -enum GameMenuIDs { - MNID_CONTINUE, - MNID_ABORTLEVEL -}; - -extern int game_started; - -class Level; -class Sector; -class Statistics; -class DrawingContext; -class CodeController; - -/** The GameSession class controlls the controll flow of a World, ie. - present the menu on specifc keypresses, render and update it while - keeping the speed and framerate sane, etc. */ -class GameSession -{ -public: - enum ExitStatus { ES_NONE, ES_LEVEL_FINISHED, ES_GAME_OVER, ES_LEVEL_ABORT }; - -public: - DrawingContext* context; - - GameSession(const std::string& levelfile, GameSessionMode mode, - Statistics* statistics=0); - ~GameSession(); - - /** Enter the busy loop */ - ExitStatus run(); - - void record_demo(const std::string& filename); - void play_demo(const std::string& filename); - void draw(); - void update(float frame_ratio); - - void set_current() - { current_ = this; } - static GameSession* current() { return current_; } - - /// ends the current level - void finish(bool win = true); - void respawn(const std::string& sectorname, - const std::string& spawnpointname); - void set_reset_point(const std::string& sectorname, - const Vector& pos); - void display_info_box(const std::string& text); - Sector* get_current_sector() - { return currentsector; } - - Level* get_current_level() - { return level; } - - void start_sequence(const std::string& sequencename); - /// called by JoystickKeyboardController after an ascii key has been pressed - void try_cheats(); - - /** returns the "working directory" usually this is the directory where the - * currently played level resides. This is used when locating additional - * resources for the current level/world - */ - std::string get_working_directory(); - -private: - void restart_level(); - - void check_end_conditions(); - void process_events(); - void capture_demo_step(); - - void levelintro(); - void drawstatus(DrawingContext& context); - void drawendscreen(); - void drawresultscreen(); - void draw_pause(); - - void on_escape_press(); - void process_menu(); - - Timer endsequence_timer; - Level* level; - Sector* currentsector; - - GameSessionMode mode; - int levelnb; - float fps_fps; - int pause_menu_frame; - - /** If true the end_sequence will be played, user input will be - ignored while doing that */ - enum EndSequenceState { - NO_ENDSEQUENCE, - ENDSEQUENCE_RUNNING, // tux is running right - ENDSEQUENCE_WAITING // waiting for the end of the music - }; - EndSequenceState end_sequence; - float last_x_pos; - CodeController* end_sequence_controller; - - bool game_pause; - bool music_playing; - - std::string levelfile; - - // reset point (the point where tux respawns if he dies) - std::string reset_sector; - Vector reset_pos; - - // the sector and spawnpoint we should spawn after this frame - std::string newsector; - std::string newspawnpoint; - - static GameSession* current_; - - Statistics* best_level_statistics; - ExitStatus exit_status; - - std::ostream* capture_demo_stream; - std::string capture_file; - std::istream* playback_demo_stream; - CodeController* demo_controller; -}; - -std::string slotinfo(int slot); - -/** Return true if the gameloop() was entered, false otherwise */ -bool process_load_game_menu(); - -#endif /*SUPERTUX_GAMELOOP_H*/ - diff --git a/src/game_session.hpp b/src/game_session.hpp new file mode 100644 index 000000000..114c27de6 --- /dev/null +++ b/src/game_session.hpp @@ -0,0 +1,168 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Bill Kendrick +// Tobias Glaesser +// Ingo Ruhnke +// +// 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_GAMELOOP_H +#define SUPERTUX_GAMELOOP_H + +#include +#include +#include "timer.hpp" +#include "statistics.hpp" +#include "math/vector.hpp" + +/* GameLoop modes */ +enum GameSessionMode { + ST_GL_PLAY, + ST_GL_TEST, + ST_GL_LOAD_GAME, + ST_GL_LOAD_LEVEL_FILE, + ST_GL_DEMO_GAME +}; + +enum GameMenuIDs { + MNID_CONTINUE, + MNID_ABORTLEVEL +}; + +extern int game_started; + +class Level; +class Sector; +class Statistics; +class DrawingContext; +class CodeController; + +/** The GameSession class controlls the controll flow of a World, ie. + present the menu on specifc keypresses, render and update it while + keeping the speed and framerate sane, etc. */ +class GameSession +{ +public: + enum ExitStatus { ES_NONE, ES_LEVEL_FINISHED, ES_GAME_OVER, ES_LEVEL_ABORT }; + +public: + DrawingContext* context; + + GameSession(const std::string& levelfile, GameSessionMode mode, + Statistics* statistics=0); + ~GameSession(); + + /** Enter the busy loop */ + ExitStatus run(); + + void record_demo(const std::string& filename); + void play_demo(const std::string& filename); + void draw(); + void update(float frame_ratio); + + void set_current() + { current_ = this; } + static GameSession* current() { return current_; } + + /// ends the current level + void finish(bool win = true); + void respawn(const std::string& sectorname, + const std::string& spawnpointname); + void set_reset_point(const std::string& sectorname, + const Vector& pos); + void display_info_box(const std::string& text); + Sector* get_current_sector() + { return currentsector; } + + Level* get_current_level() + { return level; } + + void start_sequence(const std::string& sequencename); + /// called by JoystickKeyboardController after an ascii key has been pressed + void try_cheats(); + + /** returns the "working directory" usually this is the directory where the + * currently played level resides. This is used when locating additional + * resources for the current level/world + */ + std::string get_working_directory(); + +private: + void restart_level(); + + void check_end_conditions(); + void process_events(); + void capture_demo_step(); + + void levelintro(); + void drawstatus(DrawingContext& context); + void drawendscreen(); + void drawresultscreen(); + void draw_pause(); + + void on_escape_press(); + void process_menu(); + + Timer endsequence_timer; + Level* level; + Sector* currentsector; + + GameSessionMode mode; + int levelnb; + float fps_fps; + int pause_menu_frame; + + /** If true the end_sequence will be played, user input will be + ignored while doing that */ + enum EndSequenceState { + NO_ENDSEQUENCE, + ENDSEQUENCE_RUNNING, // tux is running right + ENDSEQUENCE_WAITING // waiting for the end of the music + }; + EndSequenceState end_sequence; + float last_x_pos; + CodeController* end_sequence_controller; + + bool game_pause; + bool music_playing; + + std::string levelfile; + + // reset point (the point where tux respawns if he dies) + std::string reset_sector; + Vector reset_pos; + + // the sector and spawnpoint we should spawn after this frame + std::string newsector; + std::string newspawnpoint; + + static GameSession* current_; + + Statistics* best_level_statistics; + ExitStatus exit_status; + + std::ostream* capture_demo_stream; + std::string capture_file; + std::istream* playback_demo_stream; + CodeController* demo_controller; +}; + +std::string slotinfo(int slot); + +/** Return true if the gameloop() was entered, false otherwise */ +bool process_load_game_menu(); + +#endif /*SUPERTUX_GAMELOOP_H*/ + diff --git a/src/gameconfig.cpp b/src/gameconfig.cpp index b763feff2..1e753b24d 100644 --- a/src/gameconfig.cpp +++ b/src/gameconfig.cpp @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "gameconfig.h" +#include "gameconfig.hpp" #include #include @@ -26,12 +26,12 @@ #include #include -#include "lisp/parser.h" -#include "lisp/lisp.h" -#include "lisp/writer.h" -#include "control/joystickkeyboardcontroller.h" -#include "resources.h" -#include "main.h" +#include "lisp/parser.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include "control/joystickkeyboardcontroller.hpp" +#include "resources.hpp" +#include "main.hpp" Config* config = 0; diff --git a/src/gameconfig.h b/src/gameconfig.h deleted file mode 100644 index d16ebe65b..000000000 --- a/src/gameconfig.h +++ /dev/null @@ -1,53 +0,0 @@ -// $Id: configfile.h 2293 2005-03-25 20:39:56Z matzebraun $ -// -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Michael George -// -// 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_CONFIG_H -#define SUPERTUX_CONFIG_H - -#include - -class Config { -public: - Config(); - ~Config(); - - void load(); - void save(); - - /** screen width in pixel (warning: this is the real screen width+height, - * supertux is using a logical width+height and not this one) - */ - int screenwidth; - int screenheight; - bool use_gl; - - bool use_fullscreen; - bool show_fps; - bool sound_enabled; - bool music_enabled; - bool cheats_enabled; - - /** this variable is set if supertux should start in a specific level */ - std::string start_level; - std::string start_demo; - std::string record_demo; -}; - -extern Config* config; - -#endif diff --git a/src/gameconfig.hpp b/src/gameconfig.hpp new file mode 100644 index 000000000..d16ebe65b --- /dev/null +++ b/src/gameconfig.hpp @@ -0,0 +1,53 @@ +// $Id: configfile.h 2293 2005-03-25 20:39:56Z matzebraun $ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Michael George +// +// 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_CONFIG_H +#define SUPERTUX_CONFIG_H + +#include + +class Config { +public: + Config(); + ~Config(); + + void load(); + void save(); + + /** screen width in pixel (warning: this is the real screen width+height, + * supertux is using a logical width+height and not this one) + */ + int screenwidth; + int screenheight; + bool use_gl; + + bool use_fullscreen; + bool show_fps; + bool sound_enabled; + bool music_enabled; + bool cheats_enabled; + + /** this variable is set if supertux should start in a specific level */ + std::string start_level; + std::string start_demo; + std::string record_demo; +}; + +extern Config* config; + +#endif diff --git a/src/gettext.h b/src/gettext.h deleted file mode 100644 index b12cdd2f7..000000000 --- a/src/gettext.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - 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 - -#include "tinygettext/tinygettext.h" - -extern TinyGetText::DictionaryManager dictionary_manager; - -static inline const char* _(const char* message) -{ - return dictionary_manager.get_dictionary().translate(message); -} - -static inline std::string _(const std::string& message) -{ - return dictionary_manager.get_dictionary().translate(message); -} - -static inline const char* N_(const char* id, const char* id2, int num) -{ - return dictionary_manager.get_dictionary().translate(id, id2, num).c_str(); -} - -#endif /* _LIBGETTEXT_H */ diff --git a/src/gettext.hpp b/src/gettext.hpp new file mode 100644 index 000000000..a3353e12b --- /dev/null +++ b/src/gettext.hpp @@ -0,0 +1,38 @@ +/* + 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 + +#include "tinygettext/tinygettext.hpp" + +extern TinyGetText::DictionaryManager dictionary_manager; + +static inline const char* _(const char* message) +{ + return dictionary_manager.get_dictionary().translate(message); +} + +static inline std::string _(const std::string& message) +{ + return dictionary_manager.get_dictionary().translate(message); +} + +static inline const char* N_(const char* id, const char* id2, int num) +{ + return dictionary_manager.get_dictionary().translate(id, id2, num).c_str(); +} + +#endif /* _LIBGETTEXT_H */ diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 2f4580a48..16d901db5 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -19,14 +19,14 @@ // 02111-1307, USA. #include -#include "SDL.h" +#include #include -#include "main.h" -#include "button.h" -#include "mousecursor.h" -#include "video/font.h" -#include "video/surface.h" +#include "main.hpp" +#include "button.hpp" +#include "mousecursor.hpp" +#include "video/font.hpp" +#include "video/surface.hpp" Font* Button::info_font = 0; extern SDL_Surface* screen; diff --git a/src/gui/button.h b/src/gui/button.h deleted file mode 100644 index 700dbf079..000000000 --- a/src/gui/button.h +++ /dev/null @@ -1,91 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2005 Matthias Braun -// -// 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_BUTTON_H -#define SUPERTUX_BUTTON_H - -#include -#include - -#include "math/vector.h" -#include "video/drawing_context.h" - -class Surface; - -class ButtonGroup; - -enum { - BT_NONE, - BT_HOVER, - BT_SELECTED, - BT_SHOW_INFO - }; - -class Button -{ -public: - Button(Surface* image_, std::string info_, SDLKey binding_); - ~Button(); - - void draw(DrawingContext& context, bool selected); - int event(SDL_Event& event, int x_offset = 0, int y_offset = 0); - - static Font* info_font; - -private: - friend class ButtonGroup; - - Vector pos, size; - - Surface* image; - SDLKey binding; - - int id; - int state; - std::string info; -}; - -class ButtonGroup -{ -public: - ButtonGroup(Vector pos_, Vector size_, Vector button_box_); - ~ButtonGroup(); - - void draw(DrawingContext& context); - bool event(SDL_Event& event); - - void add_button(Button button, int id, bool select = false); - void add_pair_of_buttons(Button button1, int id1, Button button2, int id2); - - int selected_id(); - void set_unselected(); - bool is_hover(); - -private: - Vector pos, buttons_size, buttons_box; - typedef std::vector