the NOT falling down a wall with low frame-rate bug is fixed. (and hopefully this...
authorTobias Gläßer <tobi.web@gmx.de>
Sun, 14 Mar 2004 22:45:36 +0000 (22:45 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Sun, 14 Mar 2004 22:45:36 +0000 (22:45 +0000)
SVN-Revision: 225

src/collision.c
src/player.c
src/special.c
src/special.h

index a616f84..fbde783 100644 (file)
@@ -89,7 +89,7 @@ int collision_object_map(base_type* pbase)
 int collision_swept_object_map(base_type* old, base_type* current)
 {
   int steps; /* Used to speed up the collision tests, by stepping every 16pixels in the path. */
-  int h; 
+  int h;
   float i;
   float lpath; /* Holds the longest path, which is either in X or Y direction. */
   float xd,yd; /* Hold the smallest steps in X and Y directions. */
@@ -165,7 +165,6 @@ int collision_swept_object_map(base_type* old, base_type* current)
 
       if(collision_object_map(old))
         {
-
           switch(h)
             {
             case 1:
@@ -193,15 +192,22 @@ int collision_swept_object_map(base_type* old, base_type* current)
               current->x = xt;
               if(!collision_object_map(current))
                 break;
-
               current->x = temp;
               temp = current->y;
               current->y = yt;
 
               if(!collision_object_map(current))
-                break;
-
-              current->y = temp;
+                {
+                  break;
+                }
+              else
+                {
+                  current->y = temp;
+                  while(!collision_object_map(current))
+                    current->y += yd;
+                 current->y -= yd;
+                  break;
+                }
 
               break;
             default:
@@ -260,7 +266,7 @@ void collision_handler()
     }
 
 
-    
+
   /* CO_BADGUY & CO_PLAYER check */
   for(i = 0; i < num_bad_guys; ++i)
     {
@@ -270,8 +276,8 @@ void collision_handler()
             {
               /* We have detected a collision and now call the collision functions of the collided objects. */
               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)
+                  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 ea629eb..1f876f3 100644 (file)
@@ -141,7 +141,7 @@ void player_action(player_type* pplayer)
   player_input(pplayer);
 
   /* Move tux: */
-  
+
   pplayer->previous_base = pplayer->base;
 
   pplayer->base.x += pplayer->base.xm * frame_ratio;
@@ -362,7 +362,7 @@ void player_handle_horizontal_input(player_type *pplayer, int dir)
 {
 
   if ((dir ? (pplayer->base.xm < -SKID_XM) : (pplayer->base.xm > SKID_XM)) && !timer_started(&pplayer->skidding_timer) &&
-      pplayer->dir == !dir)
+      pplayer->dir == !dir && player_on_ground(pplayer))
     {
       timer_start(&pplayer->skidding_timer, SKID_TIME);
 
index ce0193a..8121f7e 100644 (file)
@@ -48,6 +48,7 @@ void bullet_init(bullet_type* pbullet, float x, float y, float xm, int dir)
 
   pbullet->base.y = y;
   pbullet->base.ym = BULLET_STARTING_YM;
+  pbullet->old_base = pbullet->base;
 }
 
 void bullet_action(bullet_type* pbullet)
@@ -57,24 +58,22 @@ void bullet_action(bullet_type* pbullet)
       pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio;
       pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio;
 
-      if (issolid(pbullet->base.x, pbullet->base.y))
+      collision_swept_object_map(&pbullet->old_base,&pbullet->base);
+      
+      if (issolid(pbullet->base.x, pbullet->base.y + 4) || issolid(pbullet->base.x, pbullet->base.y))
         {
-          if (issolid(pbullet->base.x, pbullet->base.y - pbullet->base.ym))
-            pbullet->base.alive = NO;
-          else
-            {
-              if (pbullet->base.ym >= 0)
-                {
-                  pbullet->base.y = (int)(pbullet->base.y / 32) * 32 - 8;
-                }
               pbullet->base.ym = -pbullet->base.ym;
-            }
+             pbullet->base.y = (int)(pbullet->base.y / 32) * 32;
         }
 
       pbullet->base.ym = pbullet->base.ym + GRAVITY;
 
       if (pbullet->base.x < scroll_x ||
-          pbullet->base.x > scroll_x + screen->w)
+          pbullet->base.x > scroll_x + screen->w ||
+         pbullet->base.y < 0 ||
+         pbullet->base.y > screen->h ||
+         issolid(pbullet->base.x + 4, pbullet->base.y + 2) ||
+         issolid(pbullet->base.x, pbullet->base.y + 2))
         {
           pbullet->base.alive = NO;
         }
index 596fe1a..379979d 100644 (file)
@@ -42,6 +42,7 @@ upgrade_type;
 typedef struct bullet_type
   {
     base_type base;
+    base_type old_base;
   }
 bullet_type;