how to make a shape disapear?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ColdSweat558
Prole
Posts: 2
Joined: Tue Sep 20, 2022 12:09 am

how to make a shape disapear?

Post by ColdSweat558 »

shape example: love.graphics.rectangle(mode, x, y, width, height)
use this to explain to me
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: how to make a shape disapear?

Post by pgimeno »

Every frame, the screen is cleared and you have to redraw everything that you want to be on the screen

If you want to make a shape disappear, don't draw it when you no longer want it to appear.

Here's an example to make a rectangle disappear at the end of a given time (4 seconds). When the timer expires, the 'if' condition is no longer true, and the rectangle is not drawn.

Code: Select all

local disappear_time = 4

function love.update(dt)
  if disappear_time > 0 then
    disappear_time = disappear_time - dt
  end
end

function love.draw()
  if disappear_time > 0 then
    love.graphics.rectangle("fill", 200, 200, 400, 200)
  end
end
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: how to make a shape disapear?

Post by darkfrei »

1. Make a list of objects.
2. Draw all objects from this list
3. Delete some objects from the list.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
ColdSweat558
Prole
Posts: 2
Joined: Tue Sep 20, 2022 12:09 am

Re: how to make a shape disapear?

Post by ColdSweat558 »

thanks pgimeno
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests