Annotated code


--initialize

	--turn off button repeat if held down
	poke(0x5f5c,255)
	
	--x and y coords for each possible target location
	h={32,96,64,64}
	u={64,64,32,96}
	--index for randomly chosen target location
	i=0
	--starting countdown timer
	t=40
	--score counter
	s=0
	--target button prompt
	b=4
	--countdown timer after each round
	m=30
	--lives counter
	l=9
	--score string and circle shorthand
	j='score:'
	o=circ
	
	--choose new target location and button prompt
	function n()
		i=ceil(rnd(4))
		b=rnd({4,5})
	end

	--set initial random target	
	n()

--game loop

::_::

--update
	
	--reset kitty coords
	x=61
	y=64
	--update target coords
	z=h[i]
	w=u[i]
	--decrement timer
	t-=1
	--reset target color to grey
	k=13
	
	--player misses, lose a life, reset timer, turn target red, new target
	if(t<5) n() l-=1 t=m k=8

	--move kitty if correct direction held	
	if(btn(i-1)) x=z y=w
	
	--player hits, score point, lower max timer, turn target green, new target
	if(t<9 and btnp(b) and x==z and btn()<48) s+=1 m-=0.25 n() t=m k=11
	
	--clamp timer minimum
	if(m<16)m=16

--draw

	cls()
	
	--game not over
	if l>0 then 
	
		--draw kitty
		?"🐱",x,y-4,14
		
		--prompt player to move during initial round
		if(t>30) ?'move!'

		--draw kitty's...neck?..body?..use your imagination!
		line(64,64,x,y)

		--draw target button prompt		
		?("🅾️❎")[b-3],z-3,w-2,b+6
		
		--draw shrinking and target circles
		o(z,w,5,k)
		o(z,w,8)
		o(z,w,t,t%10)
		
		--print score
		?j..s,0,0,14
		
		--print vert row of hearts for life counter
		for i=1,l do print("♥") end 
	
	--game over
	else

		--print score
		?j..s,x-14,y
		--bouncing kitty
		?'🐱',x,y*cos(t/m)/8+48,14
	
	end

	flip()

--reset game loop

goto _

Get #TWEETCAT

Leave a comment

Log in with itch.io to leave a comment.