Hi. Going through the Smoke Particle section of zine #1 and found an error I couldn't solve. If you copy paste the following code..
function make_smoke(x,y,init_size,col) local s = {} s.x=x s.y=y s.col=col s.width = init_size s.width_final = init_size + rnd(3)+1 s.t=0 s.max_t = 30+rnd(10) s.dx = (rnd(.8).4) s.dy = rnd(.05) s.ddy = .02 add(smoke,s) return s end function _init() smoke = {} cursorx = 50 cursory = 50 color = 7 end function move_smoke(sp) if (sp.t > sp.max_t) then del(smoke,sp) end if (sp.t > sp.max_t15) then sp.width +=1 sp.width = min(sp.width,sp.width_final) end sp.x = sp.x + sp.dx sp.y = sp.y + sp.dy sp.dy= sp.dy+ sp.ddy sp.t = sp.t + 1 end function _update () foreach(smoke, move_smoke) if btn(0,0) then cursorx=1 end if btn(1,0) then cursorx+=1 end if btn(2,0) then cursory-=1 end if btn(3,0) then cursory+=1 end if btn(4,0) then color = flr(rand(16)) end make_smoke(cursorx,cursory,rnd(4),color) end function draw_smoke(s) circfill(s.x, s.y,s.width, s.col) end function _draw() cls() foreach(smoke, draw_smoke) end |
Hi. I'm trying to learn about collisions using the DOM8VERSE section of zine 3 but I'm getting weird error messages whenever I try and use a foreach.
For example, when I try this:
function _update()
if btnp(5, 0) then
add(objects, bulletconstruct(player1.position.x,player1.position.y))
end
foreach(objects, function(obj)
obj.update(obj)
end
end
.. I get ')' expected ( to close '(' at line 0.0003891 near 'end'
I've tried adding and taking away brackets, as well as 'end' statements but I can't get it to work. Thought it was strange as I'm copy pasting zine 3 code.
Anyone know the solution?