M
Matt93
Guest
I'm creating a slingshot, similar to Angry Birds. At the moment, there is no limit as to how far back I can drag the slingshotr. I want to only be able to pull back the slingshot 300 pixels, but also want the player to still move with the mouse when it's beyond this point, without being able to actually pull back the slingshot any further. Like in Angry Birds when the bird will continue to tilt, even when your finger has pulled the slingshot to its limit. I think you need trig functions to do this, so have been trying with lengthdir_x and lengthdir_y. I have this so far in the player object.
I don't know what to put in the else statement. Any help would be really great, as I'm quite stuck on this. Cheers!
Code:
if (held) //set to true when player clicked
{
throw = true; //player can be thrown
dir = point_direction(obj_sling.x, obj_sling.y, mouse_x, mouse_y);
dist = point_distance(obj_sling.x, obj_sling.y, mouse_x, mouse_y);
if (dist < 300) //within distance
{
x = mouse_x + lengthdir_x(0, dir)
y = mouse_y + lengthdir_y(0, dir)
}
else
{
}
}