r152 - trunk/src/objects

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Sep 6 07:37:46 EDT 2005


Author: jonas
Date: 2005-09-06 07:37:46 -0400 (Tue, 06 Sep 2005)
New Revision: 152

Modified:
   trunk/src/objects/erik.cpp
   trunk/src/objects/olaf.cpp
   trunk/src/objects/olaf.h
Log:
improved erik's run handling, added private members to olaf to save the different base positions

Modified: trunk/src/objects/erik.cpp
===================================================================
--- trunk/src/objects/erik.cpp	2005-09-06 11:07:57 UTC (rev 151)
+++ trunk/src/objects/erik.cpp	2005-09-06 11:37:46 UTC (rev 152)
@@ -116,11 +116,6 @@
 
 void Erik::in_sp2() {
     //TODO: check STATE_WATER
-    if (state&(STATE_MLEFT|STATE_MRIGHT)) {
-        if (state&STATE_MRIGHT) run_right=true;
-        else run_right=false;
-        setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,(state&STATE_LEFT) ? anim_erik_run_left : anim_erik_run_right));
-    }
 }
 
 void Erik::in_left(Uint16 dt) {
@@ -128,6 +123,9 @@
         if (state&STATE_LEFT) event->reset();
         //changed directions, TODO: play decelerate animation
         else cancelEvent();
+    } else if (input->keyState(KEY_SP2)) {
+        run_right=false;
+        setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,anim_erik_run_left));
     }
     Player::in_left(dt);
 }
@@ -137,6 +135,9 @@
         if (!(state&STATE_LEFT)) event->reset();
         //changed directions, TODO: play decelerate animation
         else cancelEvent();
+    } else if (input->keyState(KEY_SP2)) {
+        run_right=true;
+        setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,anim_erik_run_right));
     }
     Player::in_right(dt);
 }

Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp	2005-09-06 11:07:57 UTC (rev 151)
+++ trunk/src/objects/olaf.cpp	2005-09-06 11:37:46 UTC (rev 152)
@@ -34,6 +34,8 @@
     au_big=scenario->sndcache->loadWAV("unblob.wav");
     au_fart=scenario->sndcache->loadWAV("fart1.wav");
     au_hit=scenario->sndcache->loadWAV("fathit.wav");
+    normal_size=anim_orig->getFrameDim();
+    small_size=anim_small_right->getFrameDim();
 }
 
 Olaf::~Olaf() { }
@@ -106,10 +108,10 @@
     SDL_Rect tmppos=pos;
     //Assume both images have the same dimension
     //IDEA: left/right edge instead of bottom?
-    tmppos.x+=(Sint16)((tmppos.w-(small ? anim_small_left : anim_orig)->getFrameDim().w)/2);
-    tmppos.y+=tmppos.h-(small ? anim_small_left : anim_orig)->getFrameDim().h;
-    tmppos.w=(small ? anim_small_left : anim_orig)->getFrameDim().w;
-    tmppos.h=(small ? anim_small_left : anim_orig)->getFrameDim().h;
+    tmppos.x+=(Sint16)((tmppos.w-(small ? small_size.w : normal_size.w))/2);
+    tmppos.y+=tmppos.h-(small ? small_size.h : normal_size.h);
+    tmppos.w=(small ? small_size.w : normal_size.w);
+    tmppos.h=(small ? small_size.h : normal_size.h);
     if (!(checkMove(tmppos,true).enter&DIR_ALL)) {
         pos=tmppos;
         if (small) {

Modified: trunk/src/objects/olaf.h
===================================================================
--- trunk/src/objects/olaf.h	2005-09-06 11:07:57 UTC (rev 151)
+++ trunk/src/objects/olaf.h	2005-09-06 11:37:46 UTC (rev 152)
@@ -58,4 +58,6 @@
         Mix_Chunk* au_fart;
         //@}
         Sint16 fart;
+        SDL_Rect small_size;
+        SDL_Rect normal_size;
 };




More information about the lostpenguins-commits mailing list