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. */
if(collision_object_map(old))
{
-
switch(h)
{
case 1:
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:
}
-
+
/* CO_BADGUY & CO_PLAYER check */
for(i = 0; i < num_bad_guys; ++i)
{
{
/* 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);
}
player_input(pplayer);
/* Move tux: */
-
+
pplayer->previous_base = pplayer->base;
pplayer->base.x += pplayer->base.xm * frame_ratio;
{
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);
pbullet->base.y = y;
pbullet->base.ym = BULLET_STARTING_YM;
+ pbullet->old_base = pbullet->base;
}
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;
}
typedef struct bullet_type
{
base_type base;
+ base_type old_base;
}
bullet_type;