x=64 y=30 r=5 g=0.1 dx=2 dy=0 floor=100 elastic=0.95 air_res=0.999 function _update() dx=dx*air_res dy=dy+g x=x+dx y=y+dy if y>(floor-r) then dy=-(dy*elastic) y=(floor-r) end if x<r then dx=-(dx*elastic) x=r end if x>(128-r) then dx=-(dx*elastic) x=128-r --mouse check if stat(32)==x then print("aaaaaaaaa") end end function _draw() cls() rectfill(0,floor,128,128,5) circfill(x,y,r,8) poke(0x5f2d, 1) spr(0,stat(32)-1,stat(33)-1) print(stat(34)) end |
if you can please tell me how to fix this

3


Here's a tip that I use - if you open anything (if statement, function, parentheses, etc) instantly close it. Then you can type inside it knowing that you won't forget to close it. Pico-8 has a trick for this as well: type "function my_function()" or "if bool then" or "while bool do" and then press SHIFT + ENTER. This auto-completes the statement and moves your cursor inside it so you can start typing.



If there appears an UNCLOSE
error, it's usual that you forget to add an end
in the if, loop or function blocks. And yeah, that's what I often meet when I try to run my demo cart.
Look at the code below and you'll figure out where you forgot an end
.
function _update() dx=dx*air_res dy=dy+g x=x+dx y=y+dy if y>(floor-r) then dy=-(dy*elastic) y=(floor-r) end if x<r then dx=-(dx*elastic) x=r end if x>(128-r) then dx=-(dx*elastic) x=128-r --mouse check if stat(32)==x then print("aaaaaaaaa") end end |
[Please log in to post a comment]