E
Electrino
Guest
Hi,
I was making a PacMan style game but where the walls move vertically and horizontally and I've ran into a few problems with the basic collision code I was using.
Here's the code I used:
for movement I used the basic vspeed and hspeed and the wall objects are checked solid...for the collision detection I used the following in obj_player's step:
This code works fine as long as the walls are static... But once they start moving the obj_player can either stop the movement of the walls by touching them (this only happens sometimes!?) or can clip inside the wall (if the wall collides with obj_player).
Any suggestions on how I'd improve this code?
I was making a PacMan style game but where the walls move vertically and horizontally and I've ran into a few problems with the basic collision code I was using.
Here's the code I used:
for movement I used the basic vspeed and hspeed and the wall objects are checked solid...for the collision detection I used the following in obj_player's step:
Code:
if hspeed !=0
if !place_free(x+hspeed,y)
{
if hspeed>0 move_contact_solid(0,hspeed)
if hspeed<0 move_contatct)solid(180,-hspeed)
hspeed=0
}
if vspeed!=0
if !place_free(x+hspeed,y+vspeed)
{
if vspeed>0 move_contact_solid(270,vspeed)
if vspeed<0 move_contatct)solid(90,-vspeed)
vspeed=0
}
Any suggestions on how I'd improve this code?