Log In  


I'll preface this by saying that I am a (very) novice programmer who is really enjoying creating games with Pico-8.

I think that this question is more of a structural one. I don't know how to handle a break in game action so that I can do a simple animation when - say - my main character / spaceship is destroyed.

Lets say that I just want to do something that I imagine is pretty straight forward - say use CLS() with different colours (CLS(1), CLS(2), CLS(3) ... etc.) so that the screen flashes six or seven times when my spaceship is destroyed.

I know how to create the animation that I want through code, but I don't know where to put it / how to structure the _update() or the _draw() to "pause" the game so that the animation can run and then the game can pick up from where it was before.

I'm not sure that I've explained myself all that well here but if anybody has any guidance, I'd appreciate it.

D.



I'm actually have basically the same question at the moment. I'm working on a remake of Atari Combat, and I've hit a speed bump when it comes to the hit animation.

In the original, when a tank gets hit, there's an animation where it spins in place for a bit, and all other action stops until the animation plays out.

I'm not really clear how to pause the normal lifecycle and where to hook in to make that happen.

I can paste the WIP cart if it helps.


you can just keep track of your game status:

gs_run=0
gs_blown=1

gamestate=gs_run
x,y=0,60
count=0

function _update60()
	if (gamestate==gs_run) then
		x=(x+1)%128		
		if (btnp(5)) then
			x=0
			gamestate=gs_blown
			count=10 --10 frames
		end
	elseif (gamestate==gs_blown) then
		count-=1
		if (count==0) gamestate=gs_run
	end
end

function _draw()
	if (gamestate==gs_run) then
		cls()
		print('\142',x,y)	
	elseif (gamestate==gs_blown) then
		cls(rnd(15))
	end
end

Hey - thanks for the replies. The game state approach worked for me.

I just added a fourth "mode" to my game states and had an "update_explosion" function and an "draw_explosion" function and then, after the animation, rolled back to "game on" mode.

Thanks again for the help!

D.


I eventually solved it with a coroutine that triggers on hit, and then having _update skip normal updates as long as the coroutine is unfinished.



[Please log in to post a comment]