hopefully fixed the crash on exit, keep sectors script bundled in the sector and...
[supertux.git] / src / object / player.cpp
index bde9ccb..1769811 100644 (file)
@@ -41,6 +41,7 @@
 #include "object/bullet.hpp"
 #include "trigger/trigger_base.hpp"
 #include "control/joystickkeyboardcontroller.hpp"
+#include "scripting/wrapper_util.hpp"
 #include "main.hpp"
 #include "platform.hpp"
 #include "badguy/badguy.hpp"
@@ -106,6 +107,7 @@ Player::Player(PlayerStatus* _player_status)
   smalltux_gameover = sprite_manager->create("images/creatures/tux_small/smalltux-gameover.sprite");
   smalltux_star = sprite_manager->create("images/creatures/tux_small/smalltux-star.sprite");
   bigtux_star = sprite_manager->create("images/creatures/tux_big/bigtux-star.sprite");
+
   init();
 }
 
@@ -120,9 +122,9 @@ void
 Player::init()
 {
   if(is_big())
-    bbox.set_size(31.8, 63.8);
+    bbox.set_size(31.8, 62.8);
   else
-    bbox.set_size(31.8, 31.8);
+    bbox.set_size(31.8, 30.8);
   adjust_height = 0;
 
   dir = RIGHT;
@@ -150,6 +152,19 @@ Player::init()
 }
 
 void
+Player::expose(HSQUIRRELVM vm, int table_idx)
+{
+  Scripting::Player* interface = static_cast<Scripting::Player*> (this);
+  expose_object(vm, table_idx, interface, "Tux", false);
+}
+
+void
+Player::unexpose(HSQUIRRELVM vm, int table_idx)
+{
+  Scripting::unexpose_object(vm, table_idx, "Tux");
+}
+
+void
 Player::set_controller(Controller* controller)
 {
   this->controller = controller;
@@ -180,7 +195,7 @@ Player::update(float elapsed_time)
       if(moving_object) {
         moving_object->set_pos(pos);
       } else {
-        msg_debug("Non MovingObjetc grabbed?!?");
+        msg_debug << "Non MovingObjetc grabbed?!?" << std::endl;
       }
       grabbed_object->ungrab(*this, dir);
       grabbed_object = 0;
@@ -525,7 +540,7 @@ Player::set_bonus(BonusType type, bool animate)
     return;
   
   if(player_status->bonus == NO_BONUS) {
-    adjust_height = 63.8;
+    adjust_height = 62.8;
     if(animate)
       growing_timer.start(GROWING_TIME);
   }
@@ -556,7 +571,7 @@ Player::draw(DrawingContext& context)
 {
   if(!visible)
     return;
-  
+
   TuxBodyParts* tux_body;
           
   if (player_status->bonus == GROWUP_BONUS)
@@ -599,7 +614,7 @@ Player::draw(DrawingContext& context)
     else // dir == RIGHT
       tux_body->set_action("buttjump-right");
     }
-  else if (physic.get_velocity_y() != 0 && !on_ground())
+  else if (!on_ground())
     {
     if(dir == LEFT)
       tux_body->set_action("jump-left");
@@ -711,6 +726,14 @@ Player::collision(GameObject& other, const CollisionHit& hit)
   }
  
   if(other.get_flags() & FLAG_SOLID) {
+    /*
+    printf("Col %p: HN: %3.1f %3.1f D %.1f P: %3.1f %3.1f M: %3.1f %3.1f\n",
+        &other,
+        hit.normal.x, hit.normal.y, hit.depth,
+        get_pos().x, get_pos().y,
+        movement.x, movement.y);
+    */
+    
     if(hit.normal.y < 0) { // landed on floor?
       if(physic.get_velocity_y() < 0)
         physic.set_velocity_y(0);
@@ -826,7 +849,7 @@ Player::kill(HurtMode mode)
         {
           //growing_timer.start(GROWING_TIME);
           safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */);
-          adjust_height = 31.8;
+          adjust_height = 30.8;
           duck = false;
           player_status->bonus = NO_BONUS;
         }
@@ -836,7 +859,7 @@ Player::kill(HurtMode mode)
       physic.enable_gravity(true);
       physic.set_acceleration(0, 0);
       physic.set_velocity(0, 700);
-      player_status->lives -= 1;
+      player_status->coins -= 25;
       player_status->bonus = NO_BONUS;
       dying = true;
       dying_timer.start(3.0);
@@ -941,3 +964,4 @@ void Player::walk(float speed)
 {
   physic.set_velocity_x(speed);
 }
+