From ee5c2bb3126a03535cd2c560446b7c56ff9f4d7e Mon Sep 17 00:00:00 2001 From: Dejvino Date: Mon, 12 Aug 2024 08:03:09 +0200 Subject: [PATCH] moonbus: hot and cold particles --- moonbus.p8 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index 3b22d63..b2def34 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -130,7 +130,7 @@ function _update() if plr_engine != -1 then sfx(2,2) plr_fuel=max(0,min(1,plr_fuel-fuel_cons)) - generate_particle(plr_pos) + generate_particle(true) else sfx(-1,2) end @@ -207,10 +207,10 @@ function _update() plr_speed.x*=0.5 plr_alive=false if (dist(plr_speed) > 1) then - for i=1,10 do generate_particle() end + for i=1,10 do generate_particle(false) end sfx(0) else - for i=1,20 do generate_particle() end + for i=1,20 do generate_particle(false) end plr_speed.x=0 plr_speed.y=0 plr_static=true @@ -275,7 +275,7 @@ function _draw() local p=part.p local px,py=to_scrn(p) --pset(px,py,ttl > 10 and 8 or 5) - circ(px,py,cos(part.age/20)*0.6+1.5,part.age < 10 and 8 or (part.age < part.limit/2 and 5 or 1)) + circ(px,py,cos(part.age/20)*0.6+1.5,part.age < 20 and 8 or (part.age < part.limit/2 and 5 or 1)) end print(#particles, 32,50,11) @@ -405,12 +405,13 @@ function next_target() plr_target={x=mp.x,y=maph-mp.y+1} end -function generate_particle() +function generate_particle(hot) + hot=hot or false add(particles,{ p=plus(plus(plr_pos,{x=0.25,y=-0.85}),{x=rnd(),y=rnd()},0.5), spd=plus(mul({x=rnd(2)-1,y=rnd(2)-1},0.1),mul(plr_speed,rnd(0.5))), - age=rnd(20), - limit=80+flr(rnd(40)) + age=rnd(20) + (hot and 0 or 20), + limit=80+flr(rnd(40)) + (hot and 0 or 20) }) end