hijong park
Member
I'm trying to implement prediction shot for the enemies to make it more challenging. I did some experiments with point_distance and lengthdir_x / lengthdir_y to make it, but It never worked well. So I searched for prediction shot examples and found this one:
This one works precisely, which is good. But the problem is that this method only gets the direction of the bullet to move for prediction shots, not the x and y coordinates the bullet would move to. I need to get the positions of the predict shooting bullets, so enemies won't end up firing their bullet at the wall when there's a wall in the predicted position.
Are there any possible ways to make the prediction shooting by getting x and y positions of it?
Code:
predir = point_direction(x,y,player.x,player.y)
alpha = object0.speed / shootspeed;
phi = degtorad(object0.direction - predir);
beta = alpha * sin(phi);
if (abs(beta) >= 1) {
return (-1);
}
predir += radtodeg(arcsin(beta));
This one works precisely, which is good. But the problem is that this method only gets the direction of the bullet to move for prediction shots, not the x and y coordinates the bullet would move to. I need to get the positions of the predict shooting bullets, so enemies won't end up firing their bullet at the wall when there's a wall in the predicted position.
Are there any possible ways to make the prediction shooting by getting x and y positions of it?