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 .
Lacotemale
Citizen
Posts: 75 Joined: Sat Mar 08, 2014 9:01 pm
Post
by Lacotemale » Sat Oct 18, 2014 1:08 pm
Hey all,
Really obvious thing but I started a game using absolute position values only to realise everything would get messed up on maximize. Ive started reworking stuff to be positioned from the center of the screen and im just wondering is this correct?
I come from a coding background, so game development is something im still pretty new to. I don't know what is good/bad practice on certain things just yet.
So im doing offsets like this going forward:
Code: Select all
s_w,s_h = love.window.getDimensions( )
x = (s_w/2) - 16 --16 being half sprite width
y = (s_h/2) - 24 --24 being half sprite height
love.graphics.draw(menuBG, x-360, y-150)
Good or bad? Opinions?
undef
Party member
Posts: 438 Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:
Post
by undef » Sat Oct 18, 2014 2:19 pm
You're still drawing to absolute positions.
Code: Select all
love.graphics.draw(menuBG, x-360, y-150)
Think about it, on a 5k resolution 150 pixels is negligible, on 800*600 on the other hand it's s_w/4.
better:
Code: Select all
love.graphics.draw(menuBG, x-offsetX, y-offsetY) -- offsetX and offsetY being a value relative to the screen size
Lacotemale
Citizen
Posts: 75 Joined: Sat Mar 08, 2014 9:01 pm
Post
by Lacotemale » Thu Oct 23, 2014 7:43 pm
Right, gotcha and I guess you mean using those s_w etc vars to calculate the percentage.
Thanks!
Users browsing this forum: Google [Bot] and 195 guests