bad_guy vs. player collision fixes.
authorTobias Gläßer <tobi.web@gmx.de>
Sun, 14 Mar 2004 15:39:54 +0000 (15:39 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Sun, 14 Mar 2004 15:39:54 +0000 (15:39 +0000)
SVN-Revision: 215

src/badguy.c
src/collision.c
src/gameloop.c
src/player.c
src/player.h

index ad763e7..c6b4772 100644 (file)
@@ -569,7 +569,9 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
     case CO_BADGUY:
       pbad_c = (bad_guy_type*) p_c_object;
       if (pbad->mode == NORMAL)
-        pbad->dir = !pbad->dir;
+      {
+      /* do nothing */
+      }
       else
         {
           /* We're in kick mode, kill the other guy: */
@@ -592,6 +594,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
               timer_start(&pbad->timer,4000);
               physic_set_state(&pplayer_c->vphysic,PH_VT);
               physic_set_start_vy(&pplayer_c->vphysic,2.);
+             pplayer_c->base.y = pbad->base.y - pplayer_c->base.height;
 
               add_score(pbad->base.x - scroll_x, pbad->base.y,
                         50 * score_multiplier);
@@ -613,6 +616,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
 
                   physic_set_state(&pplayer_c->vphysic,PH_VT);
                   physic_set_start_vy(&pplayer_c->vphysic,2.);
+                 pplayer_c->base.y = pbad->base.y - pplayer_c->base.height;
                 }
               else if (pbad->mode == FLAT)
                 {
@@ -632,7 +636,8 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
 
               physic_set_state(&pplayer_c->vphysic,PH_VT);
               physic_set_start_vy(&pplayer_c->vphysic,2.);
-
+             pplayer_c->base.y = pbad->base.y - pplayer_c->base.height;
+             
               add_score(pbad->base.x - scroll_x,
                         pbad->base.y,
                         25 * score_multiplier);
index e3c0449..a616f84 100644 (file)
@@ -259,6 +259,8 @@ void collision_handler()
         }
     }
 
+
+    
   /* CO_BADGUY & CO_PLAYER check */
   for(i = 0; i < num_bad_guys; ++i)
     {
@@ -267,7 +269,9 @@ void collision_handler()
           if(bad_guys[i].dying == NO && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0) == YES )
             {
               /* We have detected a collision and now call the collision functions of the collided objects. */
-              if (tux.base.y + tux.base.height < bad_guys[i].base.y + 8 > 0 && bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD)
+              if (tux.previous_base.y < tux.base.y &&
+             tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 &&
+             bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD)
                 {
                   badguy_collision(&bad_guys[i], &tux, CO_PLAYER);
                 }
index b41f7a4..3eddc5e 100644 (file)
@@ -710,7 +710,7 @@ int gameloop(char * subset, int levelnb, int mode)
         }
 
       if(debug_mode && debug_fps == YES)
-        SDL_Delay(160);
+        SDL_Delay(50);
 
       /*Draw the current scene to the screen */
       /*If the machine running the game is too slow
index bd01d32..ea629eb 100644 (file)
@@ -141,6 +141,8 @@ void player_action(player_type* pplayer)
   player_input(pplayer);
 
   /* Move tux: */
+  
+  pplayer->previous_base = pplayer->base;
 
   pplayer->base.x += pplayer->base.xm * frame_ratio;
   pplayer->base.y += pplayer->base.ym * frame_ratio;
index 80fc737..36b678e 100644 (file)
@@ -77,6 +77,7 @@ typedef struct player_type
  int lives;
  base_type base;
  base_type old_base;
+ base_type previous_base;
  timer_type invincible_timer;
  timer_type skidding_timer;
  timer_type safe_timer;