Thread: [Super-tux-commit] supertux/src gameloop.cpp,1.154,1.155 gameloop.h,1.52,1.53 level.cpp,1.96,1.97 le
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-07-07 17:56:11
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21175/src Modified Files: gameloop.cpp gameloop.h level.cpp level.h sector.cpp worldmap.cpp worldmap.h Log Message: Instead of setting the level to be flipped from the level file, it is now passed through the world. This way we can make a level designed to be played the two ways, and then the put them in the world map one after the other. I have played the castle level flipped, and I've to say it is soo damn cool! It is like you were playing a completely different level. It is also possible to set levels to be flipped by using --debug (this will be temporary). Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- sector.cpp 7 Jul 2004 11:39:35 -0000 1.15 +++ sector.cpp 7 Jul 2004 17:56:01 -0000 1.16 @@ -303,19 +303,19 @@ badguy->start_position.y = solids->get_height()*32 - badguy->start_position.y - 32; Trampoline* trampoline = dynamic_cast<Trampoline*> (*i); if(trampoline) - trampoline->base.y = solids->get_height()*32 - trampoline->base.y; + trampoline->base.y = solids->get_height()*32 - trampoline->base.y - 32; FlyingPlatform* flying_platform = dynamic_cast<FlyingPlatform*> (*i); if(flying_platform) - flying_platform->base.y = solids->get_height()*32 - flying_platform->base.y; + flying_platform->base.y = solids->get_height()*32 - flying_platform->base.y - 32; Door* door = dynamic_cast<Door*> (*i); if(door) - door->set_area(door->get_area().x, solids->get_height()*32 - door->get_area().y); + door->set_area(door->get_area().x, solids->get_height()*32 - door->get_area().y - 32); } for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end(); ++i) { SpawnPoint* spawn = *i; - spawn->pos.y = solids->get_height()*32 - spawn->pos.y; + spawn->pos.y = solids->get_height()*32 - spawn->pos.y - 32; } } Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- level.h 7 Jul 2004 11:39:35 -0000 1.60 +++ level.h 7 Jul 2004 17:56:01 -0000 1.61 @@ -49,8 +49,8 @@ const std::string& get_author() const { return author; } - bool is_level_flipped() - { return vertical_flip; } + /** Flips the level vertically */ + void do_vertical_flip(); void add_sector(Sector* sector); @@ -58,10 +58,6 @@ private: void load_old_format(LispReader& reader); - - /** If true, it will flip the level vertically, during the - parsing process */ - bool vertical_flip; }; #endif /*SUPERTUX_LEVEL_H*/ Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- gameloop.h 31 May 2004 13:43:30 -0000 1.52 +++ gameloop.h 7 Jul 2004 17:56:01 -0000 1.53 @@ -72,6 +72,7 @@ bool game_pause; std::string levelname; + bool flip_level; // the sector and spawnpoint we shoudl spawn after this frame std::string newsector; @@ -84,7 +85,7 @@ DrawingContext* context; Timer time_left; - GameSession(const std::string& level, int mode); + GameSession(const std::string& level, int mode, bool flip_level_ = false); ~GameSession(); /** Enter the busy loop */ Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- level.cpp 7 Jul 2004 11:39:35 -0000 1.96 +++ level.cpp 7 Jul 2004 17:56:01 -0000 1.97 @@ -61,8 +61,6 @@ return; } - vertical_flip = false; - for(lisp_object_t* cur = level->get_lisp(); !lisp_nil_p(cur); cur = lisp_cdr(cur)) { std::string token = lisp_symbol(lisp_car(lisp_car(cur))); @@ -75,8 +73,6 @@ author = lisp_string(data); } else if(token == "time") { time_left = lisp_integer(data); - } else if(token == "flip") { - vertical_flip = lisp_boolean(data); } else if(token == "sector") { Sector* sector = new Sector; sector->parse(reader); @@ -88,12 +84,6 @@ } delete level; - - if(vertical_flip) - { - for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) - i->second->do_vertical_flip(); - } } void @@ -102,18 +92,10 @@ reader.read_string("name", name); reader.read_string("author", author); reader.read_int("time", time_left); - vertical_flip = false; - reader.read_bool("flip", vertical_flip); Sector* sector = new Sector; sector->parse_old_format(reader); add_sector(sector); - - if(vertical_flip) - { - for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) - i->second->do_vertical_flip(); - } } void @@ -135,9 +117,6 @@ for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) { - if(vertical_flip) - i->second->do_vertical_flip(); - writer->start_list("sector"); i->second->write(*writer); writer->end_list("sector"); @@ -156,6 +135,13 @@ } void +Level::do_vertical_flip() +{ + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + i->second->do_vertical_flip(); +} + +void Level::add_sector(Sector* sector) { sectors.insert(std::make_pair(sector->get_name(), sector)); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- worldmap.cpp 14 Jun 2004 22:45:23 -0000 1.87 +++ worldmap.cpp 7 Jul 2004 17:56:01 -0000 1.88 @@ -428,6 +428,8 @@ reader.read_string("name", level.name); reader.read_int("x", level.x); reader.read_int("y", level.y); + level.vertical_flip = false; + reader.read_bool("flip", level.vertical_flip); levels.push_back(level); } @@ -646,7 +648,7 @@ shrink_fade(Vector((level->x*32 + 16 + offset.x),(level->y*32 + 16 + offset.y)), 500); GameSession session(datadir + "/levels/" + level->name, - ST_GL_LOAD_LEVEL_FILE); + ST_GL_LOAD_LEVEL_FILE, level->vertical_flip); switch (session.run()) { Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- worldmap.h 8 Jun 2004 14:59:50 -0000 1.32 +++ worldmap.h 7 Jul 2004 17:56:01 -0000 1.33 @@ -136,6 +136,9 @@ std::string title; bool solved; + /** Check if this level should be vertically flipped */ + bool vertical_flip; + /** Filename of the extro text to show once the level is successfully completed */ std::string extro_filename; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.154 retrieving revision 1.155 diff -u -d -r1.154 -r1.155 --- gameloop.cpp 7 Jul 2004 11:39:35 -0000 1.154 +++ gameloop.cpp 7 Jul 2004 17:56:00 -0000 1.155 @@ -59,9 +59,9 @@ GameSession* GameSession::current_ = 0; -GameSession::GameSession(const std::string& levelname_, int mode) +GameSession::GameSession(const std::string& levelname_, int mode, bool flip_level_) : level(0), currentsector(0), st_gl_mode(mode), - end_sequence(NO_ENDSEQUENCE), levelname(levelname_) + end_sequence(NO_ENDSEQUENCE), levelname(levelname_), flip_level(flip_level_) { current_ = this; @@ -74,6 +74,9 @@ context = new DrawingContext(); + if(debug_mode) + flip_level = true; + restart_level(); } @@ -100,6 +103,8 @@ level = new Level; level->load(levelname); + if(flip_level) + level->do_vertical_flip(); currentsector = level->get_sector("main"); if(!currentsector) st_abort("Level has no main sector.", ""); @@ -165,7 +170,7 @@ Vector(0, 400), LAYER_FOREGROUND1); - if(level->is_level_flipped()) + if(flip_level) context.draw_text_center(white_text, _("Level Vertically Flipped!"), Vector(0, 310), LAYER_FOREGROUND1); |