| 
					
				 | 
			
			
				@@ -13,6 +13,8 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 seed=12345 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 player={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	x=20, y=50, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    vx=0, vy=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    speed=1.5, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     inv=0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     show=1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	fire=0, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -64,6 +66,10 @@ active_enemies={} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 t=0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 math.randomseed(seed) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- create a mapping for darkening palette colors 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+-- note: this is for the default sweetie16 palette 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+drk={[0]=0,0,1,2,3,6,7,15,0,8,9,10,13,14,15,0} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function drawParallelogram(x, y, w, h, skewpx, color) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     tri(x+skewpx, y, x+w, y+h, x, y+h, color) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -215,7 +221,7 @@ function drawPlayer() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     local randFactor = math.random(10,100) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     local spawnOffsetY = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    local lineStart = math.random(player.x+20, 260) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    local lineStart = math.random(player.x//1+20, 260) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if player.gun_down then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         spawnOffsetY = 18 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         -- vulcan tilts downward so we get to do trig! yay! 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -314,19 +320,17 @@ function drawUI() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function drawWater(waterHeight) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    -- TODO: ripples, distortion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for i=0,waterHeight-1 do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        local row = (135 - i - waterHeight) * 120 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        local rowDest = (135 + i - waterHeight + 1) * 120 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        memcpy(rowDest, row, 120) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				--- shiftValue   1, 0, -1, -2   From brightest to darkest, respectively. 0 is no change 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-function filterColor(inputColor, shiftValue) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if shiftValue == 0 then return end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	tm=time()/200 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for x=0,239 do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for y=waterHeight,135 do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			-- introduce some wobble 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ox=x+2*math.sin(tm+y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			oy=waterHeight-(y-waterHeight)-1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			oc=pix(ox,oy) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			-- darken reflected pixel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			pix(x,y,drk[oc]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function drawDebug() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -335,26 +339,35 @@ function drawDebug() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function update() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if btn(0) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if player.y > 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            player.y=player.y-2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	player.vx = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	player.vy = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if btn(0) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vy=-player.speed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if btn(1) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if player.y < 120 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            player.y=player.y+2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if btn(1) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vy=player.speed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if btn(2) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if player.x > 1 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            player.x=player.x-2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if btn(2) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vx=-player.speed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if btn(3) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if player.x < 216 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            player.x=player.x+2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vx=player.speed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    -- slow down diagonal movements 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if player.vx * player.vy ~= 0 then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vx = player.vx * 0.707 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		player.vy = player.vy * 0.707 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     -- A: fire main gun 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if btn(4) then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if player.fire == 0 then 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -430,7 +443,7 @@ function TIC() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     cls(0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     drawPlayer() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     drawEnemies() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    -- drawWater(10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    drawWater(120) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     drawUI() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     drawDebug() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 |