Browse Source

basic star particles

Mike Hoskins 3 years ago
parent
commit
a4b97f737d
1 changed files with 68 additions and 59 deletions
  1. 68 59
      alter-ego-by-kyuchumimo.lua

+ 68 - 59
alter-ego-by-kyuchumimo.lua

@@ -89,7 +89,7 @@ v=0
 cls()
 map()
 
---PALETTE VARIABLES
+--PALETTE STUFF
 local basepalette = {
     0x1a1c2c, 0x29366f, 0x3b5dc9, 0x493c2b, 0x5d275d, 0x38b764, 0xb13e53, 0x333c57, 0x41a6f6, 0xef7d57, 0x94b0c2, 0xa7f070, 0xe06f8b, 0x73eff7, 0xffcd75, 0xf4f4f4
 }
@@ -121,6 +121,47 @@ function fade_in(et)
 	if t==(et+(0.4*60)) then return pal(1) end
 end
 
+-- PARTICLE/VFX STUFF
+waterlevel = 120 -- y coordinate of the water
+particletype='stars' -- snow|rain|stars
+particles = {}
+local starcolors = { 1, 2, 13, 15}
+function particleinit()
+    if particletype == 'stars' then
+        for i = 0,15 do
+            table.insert(particles, {
+                x = math.random() * 240,
+                y = math.random() * waterlevel,
+                twinkle = math.random() > 0.49, -- randomly pick true/false
+                color = starcolors[math.random(#starcolors)],
+                t = 0,
+            })
+        end
+    end
+end
+
+function particleupdate()
+    if particletype == 'stars' then
+        for i = 1,#particles do
+            local p = particles[i]
+            if not p.twinkle then goto continue end
+            ::continue::
+            if t % 15 == 0 and math.random() > 0.1 then
+                p.color = starcolors[math.random(#starcolors)]
+            end
+        end
+    end
+end
+
+function particledraw()
+    for i = 1,#particles do
+        local p = particles[i]
+        pix(p.x, p.y, p.color)
+    end
+end
+
+particleinit()
+
 --(shx: Xpos, shy: Ypos, shf: flip, sht: timer) CHECK THIS
 function skullh(shx,shy,shf,sht)
 	--local shx
@@ -388,7 +429,7 @@ level(m)
 
 function TIC()
 
---MUSIC (For loop use t%(spd*rows*#patterns used)==0)
+	--MUSIC (For loop use t%(spd*rows*#patterns used)==0)
 	--TITLE SCREEN
 	if m==1 and t==0 then music(0,-1,-1,false) end
 	--LEVELS 1-10
@@ -398,20 +439,20 @@ function TIC()
 	--LEVELS 21-???
 	if m>=22 and t==0 then music(3) end
 
---TIMER
+	--TIMER
 	if ptrig==0 then t=t+1 end
 
---CREDITS
+	--CREDITS
 	if m==0 then
-	 --if t==(-0.3*60)+1 then return cls(10) end
-	 --if t==(-0.2*60) then return cls() end
+		--if t==(-0.3*60)+1 then return cls(10) end
+		--if t==(-0.2*60) then return cls() end
 		--if t==(-0.1*60) then return cls(10) end
-  --if t<(0*60) then return end
+		--if t<(0*60) then return end
 		map(0,0,30,17)
 		print(t,0,0,15,true,1,true)
 		print(et,0,6,15,true,1,true)
 		fade_in(0)
-	 if t==(3*60) or keyp(50) then et=t end
+    if t==(3*60) or keyp(50) then et=t end
 		if t>(et+(3*60)) and et>=0 then 
 			m=m+1
 			t=0
@@ -422,7 +463,7 @@ function TIC()
 		end
 	end
 	
---TITLE SCREEN
+	--TITLE SCREEN
 	if m==1 then
 		l=5
 		--REMAP
@@ -441,6 +482,9 @@ function TIC()
 
 		fade_in(0)
 		
+        particleupdate()
+		particledraw()
+		
 		if t<0.4*60 then return end 
 			print("DEBUG: Press X/A and Y/S to switch levels",8,131)
 			print(et,0,0,15,true,1,true)
@@ -456,64 +500,28 @@ function TIC()
 			fade_out(et)
 			return
 		end
+
 	end
 
---LEVEL DISPLAY
+	--LEVEL DISPLAY
 	if m>1 then
 		fade_in(0)
 		--REMAP
 		cls()
-		map(30*m%240,17*(m//8),30,17,0,0,0,1,
+		map(30*m%240,17*(m//8),30,17,0,0,0,1)
+    
+        particleupdate()
+        particledraw()
 
-		function(tile)
-		if tile>=80 and tile<=111 and anix==0 and aniy==0 and px==0 and aepx==0 then
-			return tile*(t%38//19)
-		end
-		if tile==6 or tile==22 or tile==38 or tile==54 or tile==8 or tile==24 then
-			return tile+(t%38//19)
-		else
-			if tile~=6 and tile~=22 and tile~=38 and tile~=54 and tile~=8 and tile~=24 and not (tile>=64 and tile<=79) then return tile end
-		end
-		end)
-
-  --PIXELS	DISPLAY
-		map(30*m%240,17*(m//8),30,17,0,0,0,1,
-		function(tile)
-		if tile==64 or tile==72 then
-			return tile+(t%20//2.5)
-		end
-		if tile==65 or tile==73 then
-			return tile+(((t+2.5)%20//2.5)-1)
-		end
-		if tile==66 or tile==74 then
-			return tile+(((t+5)%20//2.5)-2)
-		end
-		if tile==67 or tile==75 then
-			return tile+(((t+7.5)%20//2.5)-3)
-		end
-		if tile==68 or tile==76 then
-			return tile+(((t+10)%20//2.5)-4)
-		end
-		if tile==69 or tile==77 then
-			return tile+(((t+12.5)%20//2.5)-5)
-		end
-		if tile==70 or tile==78 then
-			return tile+(((t+15)%20//2.5)-6)
-		end
-		if tile==71 or tile==79 then
-			return tile+(((t+17.5)%20//2.5)-7)
-		end
-		end)
-
---SKULLH LIMITS(1-28,1-14)
+	--SKULLH LIMITS(1-28,1-14)
 	--skullh(12,10,0,0)
- --if btn(5) then	skullh(25,3,0,0) end
+	--if btn(5) then	skullh(25,3,0,0) end
 	--skullh(20,6,0,0)
 	
---LEVEL CLEAR
+	--LEVEL CLEAR
 	if px==0 and aepx==0 and anix==0 and aniy==0 then
 		if et<0 then
-		 sfx(52,36,90,0)
+			sfx(52,36,90,0)
 			for i=0,29 do
 				mset((30*m%240)+i,(17*(m//8)),0)
 			end
@@ -546,7 +554,7 @@ function TIC()
 	mset((30*m%240)+7,(17*(m//8)),112+s)
 	end
 
---GAME OVER
+	--GAME OVER
 	if l==0 then
 		map(210,119,30,17)
 		sfx(-1,-1,-1,0)
@@ -585,7 +593,7 @@ function TIC()
 		level(m)
 	end
 	
- --FALL
+	--FALL
 	if not ((mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==1 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==2 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==17 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==18 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==10 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==11 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==26 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==27 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==37 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==48 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==49 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==16 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==32 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==37) and anix==0 and aniy==0 and strig==0 then
 		if ftrig==0 and l>0 then sfx(57,82,-1,0) end
 		ftrig=1
@@ -593,6 +601,7 @@ function TIC()
 		aniy=-80
 		spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
 	end
+
 	--NOTHING
 	if anix==0 and aniy==0 and t>(2*60) then
 		if ftrig==1 and strig==0 then sfx(58,24,-1,0) end
@@ -644,7 +653,7 @@ function TIC()
 		if btn(3) and anix==0 and aniy==0 and not ((mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==1 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==2 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==17 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==18 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==10 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==11 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==26 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==27) then
 			ftrig=0
 			--BRIDGE
-			ifmget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
+			if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
 				sfx(61,0,-1,3)
 				mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
 				btrig=1
@@ -667,7 +676,7 @@ function TIC()
 				else
 					sfx(59,60,-1,3)
 				end
-			end
+            end
 		end
 		if btnp(6) and m<=21 then
 			m=m+1