How to draw rectangle for longer?

28 views Asked by At

I'm making a PICO-8 game where I have a reversed boss fight (you're the boss). One of the abilities for the boss is drawing a red rectangle over the entire screen and damaging every enemy NPC hero. Unfortunately, the rectangle won't show up.

Originally, I thought the rectangle was just drawing for too short a time frame, so I made it longer, but that didn't change anything. Making the number in the for loop too big just froze the screen temporarily.

Here's my code:

fire_wave_cooldown = 0

function fire_wave()
  if time() - fire_wave_cooldown > 4 then
    fire_wave_cooldown = time()  
    for i=1, 50 do
      rectfill(0, 0, 128, 128, 8)
    end
  end
end

Thanks for any help!

1

There are 1 answers

0
Tinius Treider On

You might be calling this before the _draw() function—and if _draw() function contains a call to cls(), your rectangle is simply getting removed.