## [SOLVED] Using Push scaling library with SUIT GUI, can't align Mouse position

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Ketzo
Prole
Posts: 3
Joined: Sat Jul 13, 2019 12:03 am

### [SOLVED] Using Push scaling library with SUIT GUI, can't align Mouse position

I'm wanting to design my game at 1920,1080 because thats what my art dude said he's most comfortable working at.

Initially I was worried, as I would have rather just sclaed up the game, but after seeing the PUSH scaling libray:
https://github.com/Ulydev/push I thought it would be easy to scale the game to different resolutions and thought that was the end of my worries.

At 1920x1080 the game looks and works fine, all the things scale perfectly with lower resolutions even with the SUIT designed UI, the UI reacts when the mouse goes over it etc...

However, if I scale the resolution down to 1280x720 its as if there is a mouse offset to the right. I can no longer hover over the button to select it but have to select it around 400+ pixels to the right (and down).

I tried to use the code recommended in the Push library of push:toGame to give scaled coordinates, but it doesn't prevent the offset, it just updates the mouse coordinates to scale to the internal resolution (rather than the screen resolution coordinates I would get if I just used love.mouse.getPosition).

Any ideas on how to solve this conundrum? Ultimately i'd rather have a keyboard controlled UI anyway, but until I get some art i'm working with placeholder GUI's so I can make an abstracted version of the game.

Here's some code showing what I'm working on, i've snipped out the bits I don't think are relevant though.

Code: Select all

main.lua file

window_width, window_height = 1920,1080
window_set_up(window_width,window_height, false) (just a basic set up function that contains the Push window set up code)

--states
gamestate.registerEvents()

end

function love.update(dt)

end

function love.draw()

push:start()
mouseX, mouseY = love.mouse.getPosition()
mouseX, mouseY = push:toGame(mouseX, mouseY)
suit.draw()
push:finish()
end

--window_width = 1920
--window_height = 1080

if input:pressed("space") then suit.Button("Start Game",860, 190, 200, 200).hit = true end
if input:pressed("esc") then love.event.quit() end
if suit.Button("Start Game", 860, 190, 200, 200).hit == true
then
gamestate.switch(game)
end
end

suit.Label(mouseX.."\n"..mouseY, mouseX+15,mouseY+15, 100,100)
end


Sorry for the poor code, if its easier I can just upload the whole file(s) but i'd rather not plague you with my spaghetti -testing things out- code.
Last edited by Ketzo on Sun Jul 14, 2019 1:11 am, edited 1 time in total.

4vZEROv
Citizen
Posts: 79
Joined: Wed Jan 02, 2019 8:44 pm

### Re: Using Push scaling library with SUIT GUI, can't align Mouse position

I don't use push but in the doc there are those functions that should do the trick

Convert coordinates:

Code: Select all

push:toGame(x, y) --convert coordinates from screen to game (useful for mouse position)
--push:toGame will return nil for the values that are outside the game - be sure to check that before using them
push:toReal(x, y) --convert coordinates from game to screen


pgimeno
Party member
Posts: 2122
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Using Push scaling library with SUIT GUI, can't align Mouse position

I don't use PUSH or SUIT either, but I think this function may help:

No idea how it's used, though. The docs are quite terse on that. If it doesn't help, maybe overriding getMousePosition works (https://suit.readthedocs.io/en/latest/c ... sePosition).

This is really a question for the SUIT creator.

Ketzo
Prole
Posts: 3
Joined: Sat Jul 13, 2019 12:03 am

### Re: Using Push scaling library with SUIT GUI, can't align Mouse position

So I did use the Push:toGame(x,y) function but it didn't work which is why i'm on this forum, although i may try use it again as pgimeno suggests, otherwise i'll just switch to GSPOT or something.

Massive thanks for the replies by the way.

Ketzo
Prole
Posts: 3
Joined: Sat Jul 13, 2019 12:03 am

### Re: Using Push scaling library with SUIT GUI, can't align Mouse position

pgimeno wrote:
Sat Jul 13, 2019 4:44 pm
I don't use PUSH or SUIT either, but I think this function may help:

No idea how it's used, though. The docs are quite terse on that. If it doesn't help, maybe overriding getMousePosition works (https://suit.readthedocs.io/en/latest/c ... sePosition).

This is really a question for the SUIT creator.