Replaced .reset(new Surface()) with a factory method
[supertux.git] / src / object / player.cpp
index 4db9d11..575113e 100644 (file)
 #include "object/sprite_particle.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "supertux/game_session.hpp"
-#include "supertux/main.hpp"
+#include "supertux/globals.hpp"
 #include "supertux/sector.hpp"
 #include "supertux/tile.hpp"
 #include "trigger/climbable.hpp"
 
-#include <cmath>
+#include <math.h>
 
 //#define SWIMMING
 
@@ -103,12 +103,51 @@ bool no_water = true;
 }
 
 Player::Player(PlayerStatus* _player_status, const std::string& name) :
+  deactivated(),
+  controller(),
   scripting_controller(0), 
   player_status(_player_status), 
+  duck(),
+  dead(),
+  dying(),
+  backflipping(),
+  backflip_direction(),
+  peekingX(),
+  peekingY(),
+  swimming(),
+  speedlimit(),
   scripting_controller_old(0),
+  jump_early_apex(),
+  on_ice(),
+  ice_this_frame(),
+  dir(),
+  old_dir(),
+  last_ground_y(),
+  fall_mode(),
+  on_ground_flag(),
+  jumping(),
+  can_jump(),
+  jump_button_timer(), 
+  wants_buttjump(),
+  does_buttjump(),
+  invincible_timer(),
+  skidding_timer(),
+  safe_timer(),
+  kick_timer(),
+  shooting_timer(),
+  dying_timer(),
+  growing(),
+  backflip_timer(),
+  physic(),
+  visible(),
   grabbed_object(NULL), 
+  sprite(),
+  airarrow(),
+  floor_normal(),
   ghost_mode(false), 
   edit_mode(false), 
+  unduck_hurt_timer(),
+  idle_timer(),
   idle_stage(0),
   climbing(0)
 {
@@ -116,7 +155,7 @@ Player::Player(PlayerStatus* _player_status, const std::string& name) :
   controller = g_main_controller;
   scripting_controller.reset(new CodeController());
   sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
-  airarrow.reset(new Surface("images/engine/hud/airarrow.png"));
+  airarrow = Surface::create("images/engine/hud/airarrow.png");
   idle_timer.start(IDLE_TIME[0]/1000.0f);
 
   sound_manager->preload("sounds/bigjump.wav");
@@ -182,7 +221,7 @@ Player::expose(HSQUIRRELVM vm, SQInteger table_idx)
   if (name.empty())
     return;
 
-  Scripting::expose_object(vm, table_idx, dynamic_cast<Scripting::Player *>(this), name, false);
+  scripting::expose_object(vm, table_idx, dynamic_cast<scripting::Player *>(this), name, false);
 }
 
 void
@@ -191,7 +230,7 @@ Player::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
   if (name.empty())
     return;
 
-  Scripting::unexpose_object(vm, table_idx, name);
+  scripting::unexpose_object(vm, table_idx, name);
 }
 
 float
@@ -1141,9 +1180,7 @@ Player::collision(GameObject& other, const CollisionHit& hit)
   if(hit.left || hit.right) {
     try_grab(); //grab objects right now, in update it will be too late
   }
-#ifdef DEBUG
   assert(dynamic_cast<MovingObject*> (&other) != NULL);
-#endif
   MovingObject* moving_object = static_cast<MovingObject*> (&other);
   if(moving_object->get_group() == COLGROUP_TOUCHABLE) {
     TriggerBase* trigger = dynamic_cast<TriggerBase*> (&other);
@@ -1329,7 +1366,7 @@ Player::bounce(BadGuy& )
     physic.set_velocity_y(-300);
 }
 
-//Scripting Functions Below
+//scripting Functions Below
 
 void
 Player::deactivate()