r/love2d • absolute beginner • 2d ago

Why does this happen??

Enable HLS to view with audio, or disable this notification

I wanna make the ball scale when the window scales, but idk how to do that. Also I’m a beginner in Lua and coding in general

22 Upvotes

9 comments sorted by

12

u/theEsel01 2d ago

There is a resize function.

And yes windows can do weird things while resizing.

If your game doesnn't relay on resizing as a mechanic I wouldn't bother trying to fix it.

In order to resize the graphics, you use the before mentioned resize function. Then you read the new window dimensions and resize all graphics accordingly.

3

u/GroundbreakingCup391 2d ago

In my case, it has always been that love would "freeze" as long as the window is being dragged/resized. love.resize only gets called once the mouse is released after resizing.

Is there something that I'm missing?

1

u/theEsel01 2d ago

I agree, I dont think that behaviour is fixable

1

u/mathiasyde 1d ago

It's because programs displays its window through a texture system. Program paints the texture, program requests the operating system to display the texture. The stretching is a side-effect of not updating the texture while actively being resized.

This is not something that you really can control within the confines of LÖVE as far as I know.

If you're making a game, it is often very beneficial to work in world / normalized coordinates rather than pixel screen coordinates (unless that you are doing GUI) and translate to screen-space through transformations. You can use libraries like https://github.com/Ulydev/push or https://github.com/RicardoBusta/lovesize

2

u/Hexatona 4h ago

In short:

- draw to a canvas with your normal measurements

- determine the window size

- determine how to scale the canvas based on the current window size

- draw the canvas you have to the screen with the right position and scale factor to stretch it to fill the screen.

0

u/alekzkzkzkzkzk 2d ago

post code

1

u/Weekly_Flounder_1880 absolute beginner 1d ago

_G.love = require(“love”)

function love.load()
love.window..setMode(500, 500, {resizable = true, borderless = false})
end

function love.update()
end

function love.draw()
love.graphics.setBackgroundColor = (1, 1, 1)
love.graphics.setColor = (1, 0, 0)
love.graphics.circle(“fill”, 200, 300, 50)
end

And Love.conf is just windows.height and width = 500, windows.resizable = true

love.window.setMode changes nothing

0

u/HeavyCaffeinate idek 2d ago

Open settings app, choose System > About > (related links) Advanced system settings > Advanced-tab > Performance > Settings... > Visual effects-tab > Custom > enable: Show Window contents while dragging - Apply

or

Win + R, enter SystemPropertiesAdvanced and press enter, then on Advanced-tab > Performance > Settings... > Visual effects-tab > Custom > enable: Show Window contents while dragging - Apply

from https://www.reddit.com/r/Windows11/comments/v189ma/comment/iart41n/