Browse Source

fixing up particles

pixelbath 3 years ago
parent
commit
77e458b749
1 changed files with 23 additions and 13 deletions
  1. 23 13
      alter-ego-by-kyuchumimo.lua

+ 23 - 13
alter-ego-by-kyuchumimo.lua

@@ -125,12 +125,15 @@ function fade_in(et)
 end
 
 -- PARTICLE/VFX STUFF
-waterlevel = 120 -- y coordinate of the water
-particletype='snow' -- snow|rain|stars
 particles = {}
+particletype = 'stars'
 local starcolors = { 1, 2, 13, 15}
-function particleinit(numparticles)
+-- numparticles = number of particles to show
+-- particletype = rain|snow|stars
+function particleinit(numparticles, type)
     -- initialize
+    particles = {}
+    particletype = type
     for i = 0, numparticles do
         table.insert(particles, {
             x = math.random() * 240,
@@ -151,6 +154,9 @@ function particleinit(numparticles)
     if particletype == 'rain' then
 		for i = 1, #particles do
             particles[i].vel = math.random(3) + 1
+            if particles[i].vel > 2.5 then
+                particles[i].color = 8
+            end
         end
     end
     if particletype == 'snow' then
@@ -181,8 +187,9 @@ function particleupdate()
 				p.x = math.random() * 240
 			end
 			p.lasty = p.y
-			p.lastx = p.x
-			p.y = p.y + p.vel
+            p.lastx = p.x
+            p.x = p.x - p.vel / 5
+			p.y = p.y + p.vel * 1.5
 		end
     end
     if particletype == 'snow' then
@@ -193,7 +200,7 @@ function particleupdate()
 				p.lasty = 0
 				p.x = math.random() * 240
 			end
-            p.x = p.x + (math.random() - 0.5)
+            p.x = p.x - (math.random() - 0.4)
             p.y = p.y + p.vel
         end
     end
@@ -203,7 +210,7 @@ function particledraw()
 	if (particletype == 'rain') then
 		for i = 1,#particles do
 			local p = particles[i]
-			line(p.x, p.y, p.lastx, p.lasty, color)
+			line(p.x, p.y, p.lastx, p.lasty, p.color)
 		end
 		return
 	end
@@ -213,7 +220,8 @@ function particledraw()
     end
 end
 
-particleinit(150)
+-- init here for title screen
+particleinit(150, 'stars')
 
 --(shx: Xpos, shy: Ypos, shf: flip, sht: timer) CHECK THIS
 function skullh(shx,shy,shf,sht)
@@ -258,12 +266,14 @@ function level(m)
 	et=-255
 	strig=0
 	ftrig=0
+    t=0
+
+    if m <= 2 then 
+        particleinit(150, 'stars')
+    else
+        particleinit(120, 'rain')
+    end
 
-	--HELLO WORLD, PERFECT REFLECT, END
-	if m==2 or m==12 or m==22 then
-		t=0
-	end
-	
 	if m > 0 then
 		local data = leveldata[m]
 		s = data.s