// SuperTux - A Jump'n Run
-// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmail.com>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
//
// This program is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
#include "scripting/squirrel_util.hpp"
#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
#include "supertux/globals.hpp"
#include "supertux/player_status.hpp"
+#include "supertux/savegame.hpp"
#include "supertux/tile.hpp"
#include "worldmap/level.hpp"
#include "worldmap/tux.hpp"
Tux::Tux(WorldMap* worldmap_) :
back_direction(),
worldmap(worldmap_),
- sprite(),
+ sprite(SpriteManager::current()->create("images/worldmap/common/tux.sprite")),
controller(),
input_direction(),
direction(),
moving(),
ghost_mode()
{
- sprite = sprite_manager->create("images/worldmap/common/tux.sprite");
-
offset = 0;
moving = false;
direction = D_NONE;
void
Tux::draw(DrawingContext& context)
{
- switch (player_status->bonus) {
+ switch (worldmap->get_savegame().get_player_status()->bonus) {
case GROWUP_BONUS:
sprite->set_action(moving ? "large-walking" : "large-stop");
break;
case FIRE_BONUS:
sprite->set_action(moving ? "fire-walking" : "fire-stop");
break;
+ case ICE_BONUS:
+ sprite->set_action(moving ? "ice-walking" : "ice-stop");
+ break;
+ case AIR_BONUS:
+ sprite->set_action(moving ? "ice-walking" : "ice-stop");
+ break;
+ case EARTH_BONUS:
+ sprite->set_action(moving ? "fire-walking" : "fire-stop");
+ break;
case NO_BONUS:
sprite->set_action(moving ? "small-walking" : "small-stop");
break;
// We got a new direction, so lets start walking when possible
Vector next_tile;
- if ((!level || level->solved)
+ if ((!level || level->solved || level->perfect)
&& worldmap->path_ok(input_direction, tile_pos, &next_tile)) {
tile_pos = next_tile;
moving = true;
bool
Tux::canWalk(int tile_data, Direction dir)
{
- return ghost_mode ||
+ return ghost_mode ||
((tile_data & Tile::WORLDMAP_NORTH && dir == D_NORTH) ||
(tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) ||
(tile_data & Tile::WORLDMAP_EAST && dir == D_EAST) ||
void
Tux::updateInputDirection()
{
- if(g_main_controller->hold(Controller::UP))
+ Controller* controller_ = InputManager::current()->get_controller();
+ if(controller_->hold(Controller::UP))
input_direction = D_NORTH;
- else if(g_main_controller->hold(Controller::DOWN))
+ else if(controller_->hold(Controller::DOWN))
input_direction = D_SOUTH;
- else if(g_main_controller->hold(Controller::LEFT))
+ else if(controller_->hold(Controller::LEFT))
input_direction = D_WEST;
- else if(g_main_controller->hold(Controller::RIGHT))
+ else if(controller_->hold(Controller::RIGHT))
input_direction = D_EAST;
}