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).
SVN-Revision: 1535
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;
context = new DrawingContext();
+ if(debug_mode)
+ flip_level = true;
+
restart_level();
}
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.", "");
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);
bool game_pause;
std::string levelname;
+ bool flip_level;
// the sector and spawnpoint we shoudl spawn after this frame
std::string newsector;
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 */
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)));
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);
}
delete level;
-
- if(vertical_flip)
- {
- for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
- i->second->do_vertical_flip();
- }
}
void
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
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");
}
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));
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);
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*/
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;
}
}
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);
}
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())
{
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;