Updated addon repository URL and improved debug output on download
[supertux.git] / src / worldmap / tux.cpp
index 5c1fcf9..365b985 100644 (file)
@@ -1,5 +1,5 @@
 //  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
@@ -21,6 +21,7 @@
 #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"
@@ -33,7 +34,7 @@ static const float map_message_TIME = 2.8f;
 Tux::Tux(WorldMap* worldmap_) :
   back_direction(),
   worldmap(worldmap_),
-  sprite(),
+  sprite(SpriteManager::current()->create("images/worldmap/common/tux.sprite")),
   controller(),
   input_direction(),
   direction(),
@@ -42,8 +43,6 @@ Tux::Tux(WorldMap* worldmap_) :
   moving(),
   ghost_mode()
 {
-  sprite = sprite_manager->create("images/worldmap/common/tux.sprite");
-
   offset = 0;
   moving = false;
   direction = D_NONE;
@@ -59,7 +58,7 @@ Tux::~Tux()
 void
 Tux::draw(DrawingContext& context)
 {
-  switch (worldmap->get_player_status()->bonus) {
+  switch (worldmap->get_savegame().get_player_status()->bonus) {
     case GROWUP_BONUS:
       sprite->set_action(moving ? "large-walking" : "large-stop");
       break;
@@ -69,6 +68,12 @@ Tux::draw(DrawingContext& context)
     case ICE_BONUS:
       sprite->set_action(moving ? "ice-walking" : "ice-stop");
       break;
+    case AIR_BONUS:
+      sprite->set_action(moving ? "air-walking" : "air-stop");
+      break;
+    case EARTH_BONUS:
+      sprite->set_action(moving ? "earth-walking" : "earth-stop");
+      break;
     case NO_BONUS:
       sprite->set_action(moving ? "small-walking" : "small-stop");
       break;
@@ -164,7 +169,7 @@ Tux::tryStartWalking()
 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) ||
@@ -290,14 +295,14 @@ Tux::tryContinueWalking(float elapsed_time)
 void
 Tux::updateInputDirection()
 {
-  Controller* controller = g_input_manager->get_controller();
-  if(controller->hold(Controller::UP))
+  Controller* controller_ = InputManager::current()->get_controller();
+  if(controller_->hold(Controller::UP))
     input_direction = D_NORTH;
-  else if(controller->hold(Controller::DOWN))
+  else if(controller_->hold(Controller::DOWN))
     input_direction = D_SOUTH;
-  else if(controller->hold(Controller::LEFT))
+  else if(controller_->hold(Controller::LEFT))
     input_direction = D_WEST;
-  else if(controller->hold(Controller::RIGHT))
+  else if(controller_->hold(Controller::RIGHT))
     input_direction = D_EAST;
 }