[Super-tux-commit] supertux/src background.cpp,1.16,1.17 camera.cpp,1.16,1.17 camera.h,1.13,1.14 def
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-26 13:56:53
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20618/src Modified Files: background.cpp camera.cpp camera.h defines.h gameloop.cpp gameobjs.h level.cpp player.cpp player.h sector.cpp tile_manager.cpp tile_manager.h worldmap.h Removed Files: collision.cpp collision.h Log Message: fixed broken 1-time animations in sprites, fixed collision code returning no-collision if both objects didn't move, some cleanups Index: tile_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile_manager.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- tile_manager.cpp 20 Nov 2004 22:14:39 -0000 1.8 +++ tile_manager.cpp 26 Nov 2004 13:56:31 -0000 1.9 @@ -17,7 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. - #include <config.h> #include <assert.h> Index: background.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/background.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- background.cpp 23 Nov 2004 14:36:39 -0000 1.16 +++ background.cpp 26 Nov 2004 13:56:30 -0000 1.17 @@ -47,6 +47,7 @@ Background::~Background() { + printf("bgfree.\n"); delete image; } @@ -89,6 +90,7 @@ this->imagefile = name; this->speed = speed; + printf("seti %p\n", this); delete image; image = new Surface(datadir + "/images/background/" + name, false); } @@ -108,17 +110,10 @@ Background::draw(DrawingContext& context) { if(type == GRADIENT) { - /* In case we are using OpenGL just draw the gradient, else (software mode) - use the cache. */ - if(use_gl) - context.draw_gradient(gradient_top, gradient_bottom, layer); - else - { - context.push_transform(); - context.set_translation(Vector(0, 0)); - context.draw_surface(image, Vector(0, 0), layer); - context.pop_transform(); - } + context.push_transform(); + context.set_translation(Vector(0, 0)); + context.draw_surface(image, Vector(0, 0), layer); + context.pop_transform(); } else if(type == IMAGE) { if(!image) return; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- sector.cpp 25 Nov 2004 16:38:31 -0000 1.49 +++ sector.cpp 26 Nov 2004 13:56:31 -0000 1.50 @@ -69,10 +69,13 @@ song_title = "Mortimers_chipdisko.mod"; player = new Player(); add_object(player); + + printf("seccreated: %p.\n", this); } Sector::~Sector() { + printf("secdel: %p.\n", this); for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { delete *i; @@ -110,25 +113,11 @@ background = new Background(reader); return background; } else if(name == "camera") { - if(camera) { - std::cerr << "Warning: More than 1 camera defined in sector.\n"; - return 0; - } - camera = new Camera(this); - camera->read(reader); + Camera* camera = new Camera(this); + camera->parse(reader); return camera; } else if(name == "tilemap") { - TileMap* tilemap = new TileMap(reader); - - if(tilemap->is_solid()) { - if(solids) { - std::cerr << "Warning multiple solid tilemaps in sector.\n"; - return 0; - } - solids = tilemap; - fix_old_tiles(); - } - return tilemap; + return new TileMap(reader); } else if(name == "particles-snow") { SnowParticleSystem* partsys = new SnowParticleSystem(); partsys->parse(reader); @@ -565,15 +554,6 @@ std::remove(bullets.begin(), bullets.end(), bullet), bullets.end()); } -#if 0 - InteractiveObject* interactive_object = - dynamic_cast<InteractiveObject*> (*i); - if(interactive_object) { - interactive_objects.erase( - std::remove(interactive_objects.begin(), interactive_objects.end(), - interactive_object), interactive_objects.end()); - } -#endif delete *i; i = gameobjects.erase(i); } else { @@ -585,17 +565,30 @@ for(std::vector<GameObject*>::iterator i = gameobjects_new.begin(); i != gameobjects_new.end(); ++i) { - Bullet* bullet = dynamic_cast<Bullet*> (*i); - if(bullet) - bullets.push_back(bullet); -#if 0 - InteractiveObject* interactive_object - = dynamic_cast<InteractiveObject*> (*i); - if(interactive_object) - interactive_objects.push_back(interactive_object); -#endif + Bullet* bullet = dynamic_cast<Bullet*> (*i); + if(bullet) + bullets.push_back(bullet); - gameobjects.push_back(*i); + TileMap* tilemap = dynamic_cast<TileMap*> (*i); + if(tilemap && tilemap->is_solid()) { + if(solids == 0) { + solids = tilemap; + fix_old_tiles(); + } else { + std::cerr << "Another solid tilemaps added. Ignoring."; + } + } + + Camera* camera = dynamic_cast<Camera*> (*i); + if(camera) { + if(this->camera != 0) { + std::cerr << "Warning: Multiple cameras added. Ignoring."; + continue; + } + this->camera = camera; + } + + gameobjects.push_back(*i); } gameobjects_new.clear(); } Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- player.h 24 Nov 2004 23:10:03 -0000 1.95 +++ player.h 26 Nov 2004 13:56:31 -0000 1.96 @@ -23,7 +23,6 @@ #include "timer.h" #include "video/surface.h" -#include "collision.h" #include "special/moving_object.h" #include "special/sprite.h" #include "math/physic.h" Index: tile_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile_manager.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- tile_manager.h 23 Nov 2004 16:49:13 -0000 1.6 +++ tile_manager.h 26 Nov 2004 13:56:31 -0000 1.7 @@ -89,5 +89,3 @@ }; #endif - -/* EOF */ Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- gameobjs.h 22 Nov 2004 21:35:04 -0000 1.42 +++ gameobjs.h 26 Nov 2004 13:56:31 -0000 1.43 @@ -26,7 +26,6 @@ #include "timer.h" #include "scene.h" #include "math/physic.h" -#include "collision.h" #include "special/game_object.h" #include "special/moving_object.h" #include "serializable.h" Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.202 retrieving revision 1.203 diff -u -d -r1.202 -r1.203 --- gameloop.cpp 25 Nov 2004 19:48:25 -0000 1.202 +++ gameloop.cpp 26 Nov 2004 13:56:31 -0000 1.203 @@ -50,7 +50,6 @@ #include "player.h" #include "level.h" #include "scene.h" -#include "collision.h" #include "tile.h" #include "particlesystem.h" #include "resources.h" Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- worldmap.h 23 Nov 2004 02:00:52 -0000 1.50 +++ worldmap.h 26 Nov 2004 13:56:31 -0000 1.51 @@ -16,7 +16,6 @@ // 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_WORLDMAP_H #define SUPERTUX_WORLDMAP_H --- collision.h DELETED --- Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- defines.h 20 Nov 2004 22:14:38 -0000 1.50 +++ defines.h 26 Nov 2004 13:56:31 -0000 1.51 @@ -25,14 +25,11 @@ enum Direction { LEFT = 0, RIGHT = 1 }; -/* Direction (keyboard/joystick) states: */ - +/* keyboard/joystick states: */ #define UP 0 #define DOWN 1 /* Dying types: */ - -/* ---- NO 0 */ enum DyingType { DYING_NOT = 0, DYING_SQUISHED = 1, @@ -40,25 +37,14 @@ }; /* Speed constraints: */ -#define MAX_WALK_XM 230 -#define MAX_RUN_XM 320 #define MAX_LIVES 99 -#define WALK_SPEED 100 - /* gameplay related defines */ - #define START_LIVES 4 #define MAX_FIRE_BULLETS 2 #define MAX_ICE_BULLETS 1 #define FROZEN_TIME 3.0 -#define WALK_ACCELERATION_X 300 -#define RUN_ACCELERATION_X 400 - -#define SKID_XM 200 -#define SKID_TIME .3 - #endif /*SUPERTUX_DEFINES_H*/ --- collision.cpp DELETED --- Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.210 retrieving revision 1.211 diff -u -d -r1.210 -r1.211 --- player.cpp 25 Nov 2004 20:18:16 -0000 1.210 +++ player.cpp 26 Nov 2004 13:56:31 -0000 1.211 @@ -40,13 +40,18 @@ #include "gameloop.h" #include "trigger/trigger_base.h" -// behavior definitions: -#define TILES_FOR_BUTTJUMP 3 -// animation times (in ms): -#define SHOOTING_TIME .150 +static const int TILES_FOR_BUTTJUMP = 3; +static const float SHOOTING_TIME = .150; +/// time before idle animation starts +static const float IDLE_TIME = 2.5; -// time before idle animation starts -#define IDLE_TIME 2.500 +static const float WALK_ACCELERATION_X = 300; +static const float RUN_ACCELERATION_X = 400; +static const float SKID_XM = 200; +static const float SKID_TIME = .3; +static const float MAX_WALK_XM = 230; +static const float MAX_RUN_XM = 320; +static const float WALK_SPEED = 100; // growing animation Surface* growingtux_left[GROWING_FRAMES]; Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- level.cpp 25 Nov 2004 19:48:25 -0000 1.109 +++ level.cpp 26 Nov 2004 13:56:31 -0000 1.110 @@ -126,36 +126,36 @@ void Level::save(const std::string& filename) { - std::string filepath = "levels/" + filename; - int last_slash = filepath.find_last_of('/'); - FileSystem::fcreatedir(filepath.substr(0,last_slash).c_str()); - filepath = st_dir + "/" + filepath; - ofstream file(filepath.c_str(), ios::out); - LispWriter* writer = new LispWriter(file); + std::string filepath = "levels/" + filename; + int last_slash = filepath.find_last_of('/'); + FileSystem::fcreatedir(filepath.substr(0,last_slash).c_str()); + filepath = st_dir + "/" + filepath; + ofstream file(filepath.c_str(), ios::out); + LispWriter* writer = new LispWriter(file); - writer->write_comment("Level made using SuperTux's built-in Level Editor"); + writer->write_comment("Level made using SuperTux's built-in Level Editor"); - writer->start_list("supertux-level"); + writer->start_list("supertux-level"); - int version = 2; - writer->write_int("version", version); + int version = 2; + writer->write_int("version", version); - writer->write_string("name", name); - writer->write_string("author", author); - writer->write_int("time", timelimit); - writer->write_string("end-sequence-animation", - end_sequence_type == FIREWORKS_ENDSEQ_ANIM ? "fireworks" : "none"); + writer->write_string("name", name); + writer->write_string("author", author); + writer->write_int("time", timelimit); + writer->write_string("end-sequence-animation", + end_sequence_type == FIREWORKS_ENDSEQ_ANIM ? "fireworks" : "none"); - for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) { - writer->start_list("sector"); - i->second->write(*writer); - writer->end_list("sector"); - } + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) { + writer->start_list("sector"); + i->second->write(*writer); + writer->end_list("sector"); + } - writer->end_list("supertux-level"); + writer->end_list("supertux-level"); - delete writer; - file.close(); + delete writer; + file.close(); } Level::~Level() Index: camera.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- camera.h 20 Nov 2004 22:14:38 -0000 1.13 +++ camera.h 26 Nov 2004 13:56:30 -0000 1.14 @@ -44,7 +44,7 @@ virtual ~Camera(); /// parse camera mode from lisp file - void read(LispReader& reader); + void parse(LispReader& reader); /// write camera mode to a lisp file virtual void write(LispWriter& writer); Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- camera.cpp 20 Nov 2004 22:14:37 -0000 1.16 +++ camera.cpp 26 Nov 2004 13:56:30 -0000 1.17 @@ -52,7 +52,7 @@ } void -Camera::read(LispReader& reader) +Camera::parse(LispReader& reader) { std::string modename; |