Posted April 27, 2024 by Lucas Castro
#pico-8 #tutorial
Just added a simple blow up effect to the game!
When the boy turns a frog, the game only replaced his sprite, exactly like this:
Now it's doing an effect like a blow up, explosion, or magic:
I understand the same ideia could be used in other games, and I am sharing here how I did and some conclusions.
The general idea is to use a white circle that grows and, in a given moment, clear the screen, giving the explosion feeling.
In the init function, create an empty table that will store all the active effects.
effects={}
When the event happen, in my case when the boy hits the frog, add the effect to the table:
add(effects,{key="blowup",x=_x,y=_y,t=0})
Where:
In the update function, I added a simple loop to increase the "t" attribute.
for e in all(effects) do if e.key=="blowup" then if e.t<8 then e.t+=1 else del(effects,e) end end end
This will be used to track the frame of the animation.
The animation starts is composed by 3 elements:
The code:
for e in all(effects) do if e.key=="blowup" then if e.t<7 then circfill(e.x*8,y*8,e.t*3,7) else circ(e.x*8,y*8,e.t*3,7) end end if e.t==4 or e.t==5 then cls(7) end end
The code details:
In slow down, the result is this:
It's simple and enough. Matches with the simplicity of the game.
I hope you have liked. If so, feel free to comment this Tutorial.