Thread: [Super-tux-commit] supertux/lib/special base.h,NONE,1.1 game_object.cpp,NONE,1.1 game_object.h,NONE,
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-20 17:51:50
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/special Added Files: base.h game_object.cpp game_object.h moving_object.cpp moving_object.h sprite.cpp sprite.h sprite_manager.cpp sprite_manager.h stringlist.cpp stringlist.h timer.cpp timer.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: moving_object.cpp --- // $Id: moving_object.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "special/moving_object.h" MovingObject::MovingObject() { base.x = base.y = base.width = base.height = 0; old_base = base; } MovingObject::~MovingObject() { } --- NEW FILE: timer.h --- // $Id: timer.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_TIMER_H #define SUPERTUX_TIMER_H extern unsigned int st_pause_ticks, st_pause_count; unsigned int st_get_ticks(void); void st_pause_ticks_init(void); void st_pause_ticks_start(void); void st_pause_ticks_stop(void); bool st_pause_ticks_started(void); class Timer { public: unsigned int period; unsigned int time; unsigned int (*get_ticks) (void); public: Timer(); void init(bool st_ticks); void start(unsigned int period); void stop(); /*====================================================================== return: NO = the timer is not started or it is over YES = otherwise ======================================================================*/ int check(); int started(); /*====================================================================== return: the time left (in millisecond) note : the returned value can be negative ======================================================================*/ int get_left(); int get_gone(); void fwrite(FILE* fi); void fread(FILE* fi); }; #endif /*SUPERTUX_TIMER_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ --- NEW FILE: sprite_manager.cpp --- // $Id: sprite_manager.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <iostream> #include "utils/lispreader.h" #include "special/sprite_manager.h" SpriteManager::SpriteManager(const std::string& filename) { load_resfile(filename); } SpriteManager::~SpriteManager() { for(std::map<std::string, Sprite*>::iterator i = sprites.begin(); i != sprites.end(); ++i) { delete i->second; } } void SpriteManager::load_resfile(const std::string& filename) { lisp_object_t* root_obj = lisp_read_from_file(filename); if (!root_obj) { std::cout << "SpriteManager: Couldn't load: " << filename << std::endl; return; } lisp_object_t* cur = root_obj; if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-resources") != 0) return; cur = lisp_cdr(cur); while(cur) { lisp_object_t* el = lisp_car(cur); if (strcmp(lisp_symbol(lisp_car(el)), "sprite") == 0) { Sprite* sprite = new Sprite(lisp_cdr(el)); Sprites::iterator i = sprites.find(sprite->get_name()); if (i == sprites.end()) { sprites[sprite->get_name()] = sprite; } else { delete i->second; i->second = sprite; std::cout << "Warning: dulpicate entry: '" << sprite->get_name() << "'" << std::endl; } } else { std::cout << "SpriteManager: Unknown tag" << std::endl; } cur = lisp_cdr(cur); } lisp_free(root_obj); } Sprite* SpriteManager::load(const std::string& name) { Sprites::iterator i = sprites.find(name); if (i != sprites.end()) { return i->second; } else { std::cout << "SpriteManager: Sprite '" << name << "' not found" << std::endl; return 0; } } /* EOF */ --- NEW FILE: stringlist.h --- // $Id: stringlist.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_STRINGLIST_H #define SUPERTUX_STRINGLIST_H struct string_list_type { int num_items; int active_item; char **item; }; void string_list_init(string_list_type* pstring_list); char* string_list_active(string_list_type* pstring_list); void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig); int string_list_find(string_list_type* pstring_list, const char* str); void string_list_sort(string_list_type* pstring_list); void string_list_add_item(string_list_type* pstring_list, const char* str); void string_list_free(string_list_type* pstring_list); #endif /*SUPERTUX_STRINGLIST_H*/ --- NEW FILE: game_object.cpp --- // $Id: game_object.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "special/game_object.h" GameObject::GameObject() : wants_to_die(false) { } GameObject::~GameObject() { } --- NEW FILE: sprite.cpp --- // $Id: sprite.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <iostream> #include <cmath> #include "app/globals.h" #include "app/setup.h" #include "special/sprite.h" #include "video/drawing_context.h" Sprite::Sprite(lisp_object_t* cur) { init_defaults(); LispReader reader(cur); if(!reader.read_string("name", name)) st_abort("Sprite wihtout name", ""); reader.read_int("x-hotspot", x_hotspot); reader.read_int("y-hotspot", y_hotspot); reader.read_float("fps", fps); std::vector<std::string> images; if(!reader.read_string_vector("images", images)) st_abort("Sprite contains no images: ", name.c_str()); for(std::vector<std::string>::size_type i = 0; i < images.size(); ++i) { surfaces.push_back( new Surface(datadir + "/images/" + images[i], true)); } frame_delay = 1000.0f/fps; } Sprite::~Sprite() { for(std::vector<Surface*>::iterator i = surfaces.begin(); i != surfaces.end(); ++i) delete *i; } void Sprite::init_defaults() { x_hotspot = 0; y_hotspot = 0; fps = 10; time = 0; frame_delay = 1000.0f/fps; } void Sprite::update(float /*delta*/) { //time += 10*delta; //std::cout << "Delta: " << delta << std::endl; } void Sprite::draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect) { time = SDL_GetTicks(); unsigned int frame = get_current_frame(); if (frame < surfaces.size()) { Surface* surface = surfaces[frame]; context.draw_surface(surface, pos - Vector(x_hotspot, y_hotspot), layer, drawing_effect); } } #if 0 void Sprite::draw_part(float sx, float sy, float x, float y, float w, float h) { time = SDL_GetTicks(); unsigned int frame = get_current_frame(); if (frame < surfaces.size()) surfaces[frame]->draw_part(sx, sy, x - x_hotspot, y - y_hotspot, w, h); } #endif void Sprite::reset() { time = 0; } int Sprite::get_current_frame() const { unsigned int frame = static_cast<int>(fmodf(time, surfaces.size()*frame_delay)/frame_delay); return frame % surfaces.size(); } int Sprite::get_width() const { return surfaces[get_current_frame()]->w; } int Sprite::get_height() const { return surfaces[get_current_frame()]->h; } /* EOF */ --- NEW FILE: moving_object.h --- // $Id: moving_object.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_MOVING_OBJECT_H #define SUPERTUX_MOVING_OBJECT_H #include "special/base.h" #include "special/game_object.h" #include "math/vector.h" //#include "rectangle.h" /** * Base class for all dynamic/moving game objects. This class contains things * for handling the bounding boxes and collision feedback. */ class MovingObject : public GameObject { public: MovingObject(); virtual ~MovingObject(); /** this function is called when the object collided with any other object */ virtual void collision(const MovingObject& other_object, int collision_type) = 0; Vector get_pos() const { return Vector(base.x, base.y); } base_type base; base_type old_base; protected: #if 0 // this will be used in my collision detection rewrite later /// the current position of the object Vector pos; /// the position we want to move until next frame Vector new_pos; /// the bounding box relative to the current position Rectangle bounding_box; #endif }; #endif /*SUPERTUX_MOVING_OBJECT_H*/ --- NEW FILE: base.h --- // $Id: base.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_TYPE_H #define SUPERTUX_TYPE_H #include <string> #include "SDL.h" /* 'Base' type for game objects */ struct base_type { float x; float y; float width; float height; }; #endif /*SUPERTUX_TYPE_H*/ --- NEW FILE: sprite.h --- // $Id: sprite.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SPRITE_H #define SUPERTUX_SPRITE_H #include <string> #include <vector> #include "utils/lispreader.h" #include "video/surface.h" #include "math/vector.h" class Sprite { private: std::string name; int x_hotspot; int y_hotspot; /** Frames per second */ float fps; /** Number of seconds that a frame is displayed until it is switched to the next frame */ float frame_delay; float time; std::vector<Surface*> surfaces; void init_defaults(); public: /** cur has to be a pointer to data in the form of ((x-hotspot 5) (y-hotspot 10) ...) */ Sprite(lisp_object_t* cur); ~Sprite(); void reset(); /** Update the sprite and process to the next frame */ void update(float delta); void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT); int get_current_frame() const; float get_fps() { return fps; } ; int get_frames() { return surfaces.size(); } ; std::string get_name() const { return name; } int get_width() const; int get_height() const; Surface* get_frame(unsigned int frame) { if(frame < surfaces.size()) return surfaces[frame]; else return surfaces[0]; } }; #endif /*SUPERTUX_SPRITE_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ --- NEW FILE: timer.cpp --- // $Id: timer.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include "SDL.h" #include "special/timer.h" unsigned int st_pause_ticks, st_pause_count; unsigned int st_get_ticks(void) { if(st_pause_count != 0) return /*SDL_GetTicks()*/ - st_pause_ticks /*- SDL_GetTicks()*/ + st_pause_count; else return SDL_GetTicks() - st_pause_ticks; } void st_pause_ticks_init(void) { st_pause_ticks = 0; st_pause_count = 0; } void st_pause_ticks_start(void) { if(st_pause_count == 0) st_pause_count = SDL_GetTicks(); } void st_pause_ticks_stop(void) { if(st_pause_count == 0) return; st_pause_ticks += SDL_GetTicks() - st_pause_count; st_pause_count = 0; } bool st_pause_ticks_started(void) { if(st_pause_count == 0) return false; else return true; } Timer::Timer() { init(true); } void Timer::init(bool st_ticks) { period = 0; time = 0; get_ticks = st_ticks ? st_get_ticks : SDL_GetTicks; } void Timer::start(unsigned int period_) { time = get_ticks(); period = period_; } void Timer::stop() { if(get_ticks == st_get_ticks) init(true); else init(false); } int Timer::check() { if((time != 0) && (time + period > get_ticks())) return true; else { time = 0; return false; } } int Timer::started() { if(time != 0) return true; else return false; } int Timer::get_left() { return (period - (get_ticks() - time)); } int Timer::get_gone() { return (get_ticks() - time); } void Timer::fwrite(FILE* fi) { unsigned int diff_ticks; int tick_mode; if(time != 0) diff_ticks = get_ticks() - time; else diff_ticks = 0; ::fwrite(&period,sizeof(unsigned int),1,fi); ::fwrite(&diff_ticks,sizeof(unsigned int),1,fi); if(get_ticks == st_get_ticks) tick_mode = true; else tick_mode = false; ::fwrite(&tick_mode,sizeof(unsigned int),1,fi); } void Timer::fread(FILE* fi) { unsigned int diff_ticks; int tick_mode; ::fread(&period,sizeof(unsigned int),1,fi); ::fread(&diff_ticks,sizeof(unsigned int),1,fi); ::fread(&tick_mode,sizeof(unsigned int),1,fi); if (tick_mode) get_ticks = st_get_ticks; else get_ticks = SDL_GetTicks; if (diff_ticks != 0) time = get_ticks() - diff_ticks; else time = 0; } /* EOF */ --- NEW FILE: game_object.h --- // $Id: game_object.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_GAMEOBJECT_H #define SUPERTUX_GAMEOBJECT_H #include <string> class DrawingContext; /** * Base class for all game objects. This contains functions for: * -querying the actual type of the object * -a flag that indicates if the object wants to be removed. Objects with this * flag will be removed at the end of each frame. This is alot safer than * having some uncontrollable "delete this" in the code. * -an action function that is called once per frame and allows the object to * update it's state. * * Most GameObjects will also implement the DrawableObject interface so that * they can actually be drawn on screen. */ class GameObject // TODO rename this once the game has been converted { 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 and should be * the base for all timed things. */ virtual void action(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; } private: /** this flag indicates if the object should be removed at the end of the * frame */ bool wants_to_die; }; #endif /*SUPERTUX_GAMEOBJECT_H*/ --- NEW FILE: stringlist.cpp --- // $Id: stringlist.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include "string.h" #include "stdlib.h" #include "special/stringlist.h" void string_list_init(string_list_type* pstring_list) { pstring_list->num_items = 0; pstring_list->active_item = -1; pstring_list->item = NULL; } char* string_list_active(string_list_type* pstring_list) { if(pstring_list == NULL) return ""; if(pstring_list->active_item != -1) return pstring_list->item[pstring_list->active_item]; else return ""; } void string_list_add_item(string_list_type* pstring_list,const char* str) { char *pnew_string; pnew_string = (char*) malloc(sizeof(char)*(strlen(str)+1)); strcpy(pnew_string,str); ++pstring_list->num_items; pstring_list->item = (char**) realloc(pstring_list->item,sizeof(char**)*pstring_list->num_items); pstring_list->item[pstring_list->num_items-1] = pnew_string; if(pstring_list->active_item == -1) pstring_list->active_item = 0; } void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig) { int i; string_list_free(pstring_list); for(i = 0; i < pstring_list_orig.num_items; ++i) string_list_add_item(pstring_list,pstring_list_orig.item[i]); } int string_list_find(string_list_type* pstring_list,const char* str) { int i; for(i = 0; i < pstring_list->num_items; ++i) { if(strcmp(pstring_list->item[i],str) == 0) { return i; } } return -1; } void string_list_sort(string_list_type* pstring_list) { int i,j,y; for(j = 0; j < pstring_list->num_items; ++j) for(i = 0; i < pstring_list->num_items-1; ++i) { y = strcmp(pstring_list->item[i],pstring_list->item[i+1]); if(y == 0) { continue; } else if(y < 0) { continue; } else if(y > 0) { char* char_pointer; char_pointer = pstring_list->item[i]; pstring_list->item[i] = pstring_list->item[i+1]; pstring_list->item[i+1] = char_pointer; continue; } } } void string_list_free(string_list_type* pstring_list) { if(pstring_list != NULL) { int i; for(i=0; i < pstring_list->num_items; ++i) free(pstring_list->item[i]); free(pstring_list->item); pstring_list->item = NULL; pstring_list->num_items = 0; pstring_list->active_item = -1; } } --- NEW FILE: sprite_manager.h --- // $Id: sprite_manager.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_SPRITE_MANAGER_H #define SUPERTUX_SPRITE_MANAGER_H #include <map> #include "special/sprite.h" class SpriteManager { private: typedef std::map<std::string, Sprite*> Sprites; Sprites sprites; public: SpriteManager(const std::string& filename); ~SpriteManager(); void load_resfile(const std::string& filename); /** loads a sprite. * WARNING: You must not delete the returned object. */ Sprite* load(const std::string& name); }; #endif /*SUPERTUX_SPRITE_MANAGER_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ |