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 .
FranckEinstein
Prole
Posts: 2 Joined: Fri Aug 05, 2022 8:17 am
Post
by FranckEinstein » Fri Aug 05, 2022 8:37 am
I would like to stop the progression of the rectangle when it approach the border. My var have a good value but not the rectangle in the screen
Code: Select all
function love.load()
x, y, w, h = 20, 20, 60, 20
width, height = love.window.getMode( )
end
function love.update(dt)
if w < width-x then
w = w + 1
end
if h < height-y then
h = h + 1
end
end
function love.draw()
love.graphics.setColor(0, 0.4, 0.4)
love.graphics.rectangle("fill", x, y, w, h)
print(w,h)
end
milon
Party member
Posts: 472 Joined: Thu Jan 18, 2018 9:14 pm
Post
by milon » Mon Aug 08, 2022 5:31 pm
I does stop
at the edge though, with no visible gap. If you want a black buffer around the rectangle, modify love.update to something like this:
Code: Select all
function love.update(dt)
if w < width-x*2 then
w = w + 1
end
if h < height-y*2 then
h = h + 1
end
end
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
milon
Party member
Posts: 472 Joined: Thu Jan 18, 2018 9:14 pm
Post
by milon » Mon Aug 08, 2022 5:48 pm
No worries! And you're welcome. I've had plenty of those moments myself - we all have!
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Users browsing this forum: No registered users and 8 guests