(Solved) Figuring out the position with Y and X

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Stepper
Prole
Posts: 3
Joined: Thu Jul 12, 2012 8:45 pm

(Solved) Figuring out the position with Y and X

Post by Stepper »

I have been struggling with figuring out the position for x and y. And I do not know how to know the exact position of the screen where to put it. I always play around till I have the good positions
Last edited by Stepper on Fri Jul 13, 2012 1:28 pm, edited 1 time in total.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Figuring out the position with Y and X

Post by Santos »

Try this, it will tell you what x and y position your mouse is at!

Code: Select all

function love.draw()
	-- Put other things here!

	love.graphics.print('x: '..love.mouse.getX(), 8, 8)
	love.graphics.print('y: '..love.mouse.getY(), 8, 20)
end
Stepper
Prole
Posts: 3
Joined: Thu Jul 12, 2012 8:45 pm

Re: Figuring out the position with Y and X

Post by Stepper »

What if I am also coding for other langauges? How do I do that?

THANKS, Also, it works great.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Figuring out the position with Y and X

Post by Santos »

I don't quite understand what you mean sorry. Do you mean how would you find the X and Y positions in other languages? If so, you could:
  • Find out how to print text to the screen
  • Find out how to get the x and y position of the mouse
  • Print the numbers of the x and y position of the mouse to the screen
I think most other languages/frameworks use a similar coordinate system to LÖVE, with the top left corner being (x: 0, y: 0), and the x and y values increasing as you go right and down respectively, so (x: 10, y: 20) would be 10 pixels from the right of the screen, and 20 pixels down.

Sorry if I've misunderstood! :oops:
Stepper
Prole
Posts: 3
Joined: Thu Jul 12, 2012 8:45 pm

Re: Figuring out the position with Y and X

Post by Stepper »

Tried it, and thanks. I just did it in Java and C++.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 0 guests