X
xorphinindi
Guest
I've seen a lot of threads about this problem where setting bullets to high speeds in scrolling shooter games causes the bullets to skip over objects. In my game, I have arrows that fire in the direction of my cursor at any angle and the high speed caused them to partially move through the wall before stopping (and sometimes before hitting the wall), but I think it was essentially the same problem. The only difference would be that instead of just stopping when hitting the wall, the bullet would destroy itself.
My solution primarily came from this video. What I have now certainly isn't the perfect solution, but I feel that looking for much more accuracy would be pushing the limits of the software. I hope this helps anyone with a similar problem.
The arrow create event:
The arrow step event:
My solution primarily came from this video. What I have now certainly isn't the perfect solution, but I feel that looking for much more accuracy would be pushing the limits of the software. I hope this helps anyone with a similar problem.
The arrow create event:
Code:
/// Handle Motion
var dir = point_direction(x, y, mouse_x, mouse_y);
image_angle = dir;
direction = dir;
arrowSpeed = 50;
hsp = cos(degtorad(dir)) * arrowSpeed;
vsp = -sin(degtorad(dir)) * arrowSpeed;
Code:
/// Perfect collision with wall
// Horizontal Collision
if (place_meeting(x + hsp, y, objWall))
{
while (!place_meeting(x + sign(hsp), y, objWall))
{
x += sign(hsp);
}
hsp = 0;
vsp = 0;
}
x += hsp;
// Vertical Collision
if (place_meeting(x, y + vsp, objWall))
{
while (!place_meeting(x, y + sign(vsp), objWall))
{
y += sign(vsp);
}
vsp = 0;
hsp = 0;
}
y += vsp;