+ if (old_level_state != level->solved && level->auto_path)
+ { // Try to detect the next direction to which we should walk
+ // FIXME: Mostly a hack
+ Direction dir = D_NONE;
+
+ const Tile* tile = at(tux->get_tile_pos());
+
+ if (tile->getData() & Tile::WORLDMAP_NORTH
+ && tux->back_direction != D_NORTH)
+ dir = D_NORTH;
+ else if (tile->getData() & Tile::WORLDMAP_SOUTH
+ && tux->back_direction != D_SOUTH)
+ dir = D_SOUTH;
+ else if (tile->getData() & Tile::WORLDMAP_EAST
+ && tux->back_direction != D_EAST)
+ dir = D_EAST;
+ else if (tile->getData() & Tile::WORLDMAP_WEST
+ && tux->back_direction != D_WEST)
+ dir = D_WEST;
+
+ if (dir != D_NONE)
+ {
+ tux->set_direction(dir);
+ //tux->update(delta);
+ }
+
+ std::cout << "Walk to dir: " << dir << std::endl;
+ }
+ }
+
+ break;
+ case GameSession::ES_LEVEL_ABORT:
+ level_finished = false;
+ /* In case the player's abort the level, keep it using the old
+ status. But the minimum lives and no bonus. */
+ player_status.distros = old_player_status.distros;
+ player_status.lives = std::min(old_player_status.lives, player_status.lives);
+ player_status.bonus = player_status.NO_BONUS;
+
+ break;
+ case GameSession::ES_GAME_OVER:
+ {
+ level_finished = false;
+ /* draw an end screen */
+ /* TODO: in the future, this should make a dialog a la SuperMario, asking
+ if the player wants to restart the world map with no score and from
+ level 1 */
+ char str[80];
+
+ DrawingContext context;
+ context.draw_gradient(Color (200,240,220), Color(200,200,220),
+ LAYER_BACKGROUND0);
+
+ context.draw_text(blue_text, _("GAMEOVER"),
+ Vector(screen->w/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
+
+ sprintf(str, _("COINS: %d"), player_status.distros);
+ context.draw_text(gold_text, str,
+ Vector(screen->w/2, screen->w - 32), CENTER_ALLIGN,
+ LAYER_FOREGROUND1);
+
+ total_stats.draw_message_info(context, _("Total Statistics"));
+
+ context.do_drawing();
+
+ SDL_Event event;
+ wait_for_event(event,2000,6000,true);
+
+ quit = true;
+ player_status.reset();
+ break;
+ }
+ case GameSession::ES_NONE:
+ assert(false);
+ // Should never be reached
+ break;