Image Positioning

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
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Image Positioning

Post by Lacotemale »

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?
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Image Positioning

Post by undef »

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
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Image Positioning

Post by Lacotemale »

Right, gotcha and I guess you mean using those s_w etc vars to calculate the percentage. :)

Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 195 guests