X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap.cpp;h=360cc3cc0d45351253f98c7c8c3f95a6856f8640;hb=4c53a552c13dbe9d587e34e3cf48e82877d09288;hp=198bfca6195472cdc5538f54806bcc0389afa714;hpb=1db9b1a8cf477ba8a676eb2046342ae02c3d3b96;p=supertux.git diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 198bfca61..360cc3cc0 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -169,7 +169,7 @@ TileManager::TileManager() std::cerr << "Warning: no image specified for tile " << id << ".\nIgnoring...\n" << std::endl; - for(int i = 0; i < filenames.size(); i++) + for(int i = 0; static_cast(i) < filenames.size(); i++) { Surface* image = new Surface( datadir + "/images/worldmap/" + filenames[i], true); @@ -631,6 +631,9 @@ WorldMap::load_map() } lisp_free(root_obj); + + delete tux; + tux = new Tux(this); } void WorldMap::get_level_title(Level& level) @@ -678,7 +681,8 @@ void WorldMap::get_input() { enter_level = false; - + SDLKey key; + SDL_Event event; while (SDL_PollEvent(&event)) { @@ -695,32 +699,22 @@ WorldMap::get_input() break; case SDL_KEYDOWN: - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - on_escape_press(); - break; - case SDLK_LCTRL: - case SDLK_RETURN: - enter_level = true; - break; + key = event.key.keysym.sym; - case SDLK_LEFT: - tux->set_direction(D_WEST); - break; - case SDLK_RIGHT: - tux->set_direction(D_EAST); - break; - case SDLK_UP: - tux->set_direction(D_NORTH); - break; - case SDLK_DOWN: - tux->set_direction(D_SOUTH); - break; - - default: - break; - } + if(key == SDLK_ESCAPE) + on_escape_press(); + else if(key == SDLK_RETURN || key == keymap.power) + enter_level = true; + else if(key == SDLK_LEFT || key == keymap.power) + tux->set_direction(D_WEST); + else if(key == SDLK_RIGHT || key == keymap.right) + tux->set_direction(D_EAST); + else if(key == SDLK_UP || key == keymap.up || + key == keymap.jump) + // there might be ppl that use jump as up key + tux->set_direction(D_NORTH); + else if(key == SDLK_DOWN || key == keymap.down) + tux->set_direction(D_SOUTH); break; case SDL_JOYHATMOTION: @@ -876,7 +870,7 @@ WorldMap::update(float delta) // do a shriking fade to the level shrink_fade(Vector((level->pos.x*32 + 16 + offset.x),(level->pos.y*32 + 16 + offset.y)), 500); - GameSession session(datadir + "/levels/" + level->name, + GameSession session(level->name, ST_GL_LOAD_LEVEL_FILE, level->vertical_flip, &level->statistics); @@ -1143,16 +1137,17 @@ WorldMap::draw_status(DrawingContext& context) { if (i->pos == tux->get_tile_pos()) { - if(i->title == "") - get_level_title(*i); + if(i->title == "") + get_level_title(*i); - context.draw_text(white_text, i->title, - Vector(screen->w/2, screen->h - white_text->get_height() - 30), - CENTER_ALLIGN, LAYER_FOREGROUND1); + context.draw_text(white_text, i->title, + Vector(screen->w/2, + screen->h - white_text->get_height() - 30), + CENTER_ALLIGN, LAYER_FOREGROUND1); - i->statistics.draw_worldmap_info(context); - } + i->statistics.draw_worldmap_info(context); break; + } } for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { @@ -1161,7 +1156,8 @@ WorldMap::draw_status(DrawingContext& context) /* Display an in-map message in the map, if any as been selected */ if(!i->map_message.empty() && !i->passive_message) context.draw_text(gold_text, i->map_message, - Vector(screen->w/2, screen->h - white_text->get_height() - 60), + Vector(screen->w/2, + screen->h - white_text->get_height() - 60), CENTER_ALLIGN, LAYER_FOREGROUND1); break; } @@ -1261,6 +1257,7 @@ WorldMap::savegame(const std::string& filename) writer->write_string("map", map_filename); writer->write_int("lives", player_status.lives); writer->write_int("distros", player_status.lives); + writer->write_int("max-score-multiplier", player_status.max_score_multiplier); writer->start_list("tux"); @@ -1334,6 +1331,7 @@ WorldMap::loadgame(const std::string& filename) reader.read_int("lives", player_status.lives); reader.read_int("distros", player_status.distros); + reader.read_int("max-score-multiplier", player_status.max_score_multiplier); if (player_status.lives < 0) player_status.lives = START_LIVES;