| 
					
				 | 
			
			
				@@ -12,29 +12,106 @@ local bullet_timer_start = 10 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 local player_bullets = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 local player = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	x=0,y=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	x=20,y=60, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	vx=0,vy=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	speed=1.5, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	sp=256, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fire_t=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fire_held=false, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	gun_type=1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	gun_level=1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	gunpods={}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+local grad_palettes = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	{ 1, 2, 3, 4, 12 }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	{ 7, 6, 5, 4, 12 }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	{ 8, 9, 10, 11, 12 }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function mod(a, b) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return math.floor(a-(math.floor(a/b)*b)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function draw_gradient(xpos, ypos, width, height, startindex, gradient) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	local idx = startindex or 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	local grad = gradient or 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	local band_w = width / 5 --# of colors in each gradient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	local cur_band = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for i=0,width-1 do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if cur_band >= band_w then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			idx = idx + 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			cur_band = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		cur_band = cur_band + 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if idx > 5 then idx = 1 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		line(xpos + i, ypos, xpos + i - height, ypos + height, grad_palettes[grad][idx]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 -- TODO: various types 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function add_bullet() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	sfx(0, 'D-6', 10, 0, 11, 4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	table.insert(player_bullets, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		x=player.x + 10, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		y=player.y + 5, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		y=player.y, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		vx = 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		vy = 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function add_gunpod() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if #player.gunpods < 5 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		table.insert(player.gunpods, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			x=0,y=0,vx=0,vy=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			sprs={ 259,260,261,262,263 }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			fr=1,t=0,frametime=5, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function draw_player() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	spr(player.sp, player.x, player.y, 0, 1, 0, 0, 2, 2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	local engine_spr = 274 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.vx > 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		engine_spr = 306 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	elseif player.vx < 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		engine_spr = 290 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.vy > 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.sp = 272 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	elseif player.vy < 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.sp = 288 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.sp = 256 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	-- draw engine fire then player 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	spr(engine_spr, player.x-8, player.y+1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	spr(player.sp, player.x, player.y, 0, 1, 0, 0, 2, 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	-- draw gunpods 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if #player.gunpods > 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for key,pod in ipairs(player.gunpods) do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pod.t = pod.t + 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if mod(pod.t, pod.frametime) == 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				pod.fr = pod.fr + 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if pod.fr > #pod.sprs then pod.fr = 1 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			spr(pod.sprs[pod.fr], pod.x, pod.y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			-- TODO: move this into an update 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			local targx = player.x + 4 - pod.x 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			local targy = player.y - 10 - pod.y 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pod.vx = targx / 3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pod.vy = targy / 3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pod.x = pod.x + pod.vx 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pod.y = pod.y + pod.vy 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+add_gunpod() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function draw_bullets() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for key,val in ipairs(player_bullets) do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		spr(258, val.x, val.y, 0) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,6 +143,11 @@ function handle_input() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	player.x = player.x + player.vx 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	player.y = player.y + player.vy 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.x < 5 then player.x = 5 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.x > 220 then player.x = 220 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.y < 5 then player.y = 5 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.y > 128 then player.y = 128 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	player.fire_held = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if btn(4) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if player.fire_t <= 0 then 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -78,6 +160,11 @@ function handle_input() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		player.fire_t = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	-- debug 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if btnp(5) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.gun_type = mod(player.gun_type + 1, 3) + 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function TIC() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,10 +181,12 @@ function TIC() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	draw_player() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	draw_bullets() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	dbg(tostring(player.fire_t), 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	draw_gradient(10, 40, 10, 5, mod(t/3, 5) + 1, player.gun_type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	dbg("type:"..tostring(player.gun_type), 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	dbg(tostring(player.fire_held), 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	dbg(tostring(player.vx), 2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	dbg(tostring(player.vy), 3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	dbg(tostring(mod(t/3, 5) + 1), 2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	-- dbg(tostring(player.vy), 3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	t=t+1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -106,11 +195,21 @@ function dbg(msg, line_no) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 -- <SPRITES> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				--- 000:00000000000000000000000000000000ede00000ecdef0000edddef00fcccc8b 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				--- 001:000000000000000000000000000000000000000000000000000000009cde0000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 000:00000000eccef0000edddefa0fcccc8bcf9deededfb8cddd00db8cdd00008cce 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 001:000000000000000090000000aa9deecc99eedcddddcccdf0ccf0000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 -- 002:0000000000000000000000004040440030303300000000000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				--- 016:cf9edd99dfb8eeee00db8ddd00008cce00000000000000000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				--- 017:aaeddcefeeeccde0ccde00000000000000000000000000000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 003:00dd00000eeedddd023eeee02344320023443200023eddd00feefeee00ff0000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 004:000000000f1eeddd02331ee023443200234eddd00feefeee00f1000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 005:000000000022000002332eef23dd31f0231ddddd0fe1eee00022000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 006:000000000022000002dd2000231ddddd23e1eeee02ee20000022000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 007:0000000000de00000f1ddddd2341eee02344320002331ee00f1eeddd00000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 016:dccefeed0ddddefa0fcccc8acf9deededfbbcddd0000bcdd00008ccc00000dd0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 017:d00000009eedd000aaaaeecc9aa9dccdddcccdf0ccd00000d000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 018:0000000000000880000889ab08899abc000889ab000008800000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 032:ecdf00000edddf0000edddc00bbcfeeddcc99feeee8888880bc99f99000bfeee 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 033:000000000000000009aa0000cdc99e00eeedddcc88888eef9eeeedd0df000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 034:00000000000000000000089a000089ab0000089a000000000000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- 050:00000000000099a000889abb8889accc00889abb000099a00000000000000000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 -- </SPRITES> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 -- <WAVES> 
			 |