Making an image face a point

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
SamPerson12345
Prole
Posts: 41
Joined: Sat Aug 30, 2008 5:35 pm

Making an image face a point

Post by SamPerson12345 »

I'm making a top down shooter and I wanted the player image to face the cross hair. The problem is I have no idea how to get an angle with two points. Can someone please help?
User avatar
conman420
Prole
Posts: 33
Joined: Sun Aug 31, 2008 8:46 pm

Re: Making an image face a point

Post by conman420 »

Use this math:

Code: Select all

	local x2, y2 = position
	local x1, y1 = position
       local ang = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
We need lua syntaxing code boxes!
User avatar
SamPerson12345
Prole
Posts: 41
Joined: Sat Aug 30, 2008 5:35 pm

Re: Making an image face a point

Post by SamPerson12345 »

Thanks for that :3.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 5 guests