Page 1 of 1
Keep coordinate fullscreen mode
Posted: Wed May 27, 2020 2:58 pm
by VFBStudio
Hello !
My game runs in 720p for desktop
Is it possible to keep the same coordinates if we switch to fullscreen mode? like a panel in a window?
I want the coordinates to start in my panel (x0,y0), like a "letterbox".
I join you 2 screens to illustrate my request
Thank you in advance,
VFB
https://image.noelshack.com/fichiers/20 ... forum1.jpg
https://image.noelshack.com/fichiers/20 ... forum2.png
Re: Keep coordinate fullscreen mode
Posted: Wed May 27, 2020 9:18 pm
by pgimeno
I'm not sure if I've understood correctly what you're asking, but you can try combining
love.graphics.setScissor with
love.graphics.translate.
Something like this (use F11 to toggle fullscreen mode):
Code: Select all
-- This is just a demonstrative effect
local circles = {}
local nCircles = 20
local circleRadius = 80
function love.draw()
-- Here's the gist
if love.window.getFullscreen() then
local diffX = love.graphics.getWidth() - 1280
local diffY = love.graphics.getHeight() - 720
love.graphics.setScissor(diffX / 2, diffY / 2, 1280, 720)
love.graphics.translate(diffX / 2, diffY / 2)
else
love.graphics.setScissor()
end
-- Now draw something for demonstrative purposes
for i = 1, nCircles do
love.graphics.setColor(circles[i][5], circles[i][6], circles[i][7])
love.graphics.circle("fill", circles[i][1], circles[i][2], circleRadius)
end
end
function love.load()
love.window.setMode(1280, 720)
for i = 1, nCircles do
local direction = math.pi * 2 * love.math.random()
local speed = love.math.random() * 200 + 50
local vx = math.cos(direction) * speed
local vy = math.sin(direction) * speed
local hue = love.math.random() * 6
local hue = love.math.random() * 6
local r = math.min(math.max(math.abs(hue - 3) - 1, 0), 1)
hue = (hue + 2) % 6
local g = math.min(math.max(math.abs(hue - 3) - 1, 0), 1)
hue = (hue + 2) % 6
local b = math.min(math.max(math.abs(hue - 3) - 1, 0), 1)
circles[i] = {love.math.random(1, 1280) - 1,
love.math.random(1, 720) - 1,
vx, vy, r, g, b}
end
end
function love.update(dt)
for i = 1, nCircles do
local circle = circles[i]
local saveX = circle[1]
local saveY = circle[2]
circle[1] = saveX + circle[3] * dt
circle[2] = saveY + circle[4] * dt
if circle[1] >= 1280 or circle[1] < 0 then
circle[3] = -circle[3]
circle[1] = saveX
end
if circle[2] >= 720 or circle[2] < 0 then
circle[4] = -circle[4]
circle[2] = saveY
end
end
end
function love.keyreleased(k)
if k == "f11" then
if love.window.getFullscreen() then
love.window.setMode(1280, 720)
else
love.window.setFullscreen(true)
end
end
return k == "escape" and love.event.quit()
end
(Edited to remove a leftover variable)
Re: Keep coordinate fullscreen mode
Posted: Tue Jun 02, 2020 10:23 pm
by VFBStudio
Thanks pgimeno ! it's working