最初的想法是让球在墙壁物体上反射,并在反弹后保持相同的速度。提前致谢。
if (place_meeting(x,y + vsp,o_wall))
{
while (!place_meeting(x,y-sign(vsp),o_wall))
{
y = y * sign(vsp);
}
vsp = -vsp;
}
y = y + vsp;
if (place_meeting(x + hsp,y,o_wall))
{
while (!place_meeting(x+sign(hsp),y,o_wall))
{
x = x * sign(hsp);
}
hsp = -hsp;
}
x = x + hsp;