SocksTheprogrammer [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=63597 Untitled <p>Im trying to make an inverse or reverse for this function to countdown. How do I make a countdown timer?</p> <p>function _update()<br /> print(time())<br /> if time() &gt;= 10 then<br /> time=0<br /> end<br /> end</p> https://www.lexaloffle.com/bbs/?tid=46981 https://www.lexaloffle.com/bbs/?tid=46981 Tue, 15 Mar 2022 05:37:49 UTC adding jump w/ y axis movement <p>I am playing around with the wander demo so I can experiment with y axis movement to make a beat em up style game but i still want to be able to jump (in cases to dodge and platform in certain sections)</p> <p>Here is the code if any of you are wondering:</p> <p>function _init()</p> <p>x=24 y=24 -- position (in tiles)<br /> dx=0 dy=0 -- velocity<br /> f=0 -- frame number<br /> d=1 -- direction (-1, 1)<br /> acc=0.5<br /> boost=.5<br /> end</p> <p>function _draw()<br /> cls(1)</p> <pre><code>-- move camera to current room room_x = flr(x/16) room_y = flr(y/16) camera(room_x*128,room_y*128) -- draw the whole map (128⁙32) map() -- draw the player spr(65+f, -- frame index x*8-4,y*8-4, -- x,y (pixels) 1,1,d==-1 -- w,h, flip )</code></pre> <p>end</p> <p>function _update()</p> <pre><code>ac=0.1 -- acceleration if (btn(⬅️)) dx-= ac d=-1 if (btn(➡️)) dx+= ac d= 1 if (btn(⬆️)) dy-= ac if (btn(⬇️)) dy+= ac -- move (add velocity) x+=dx y+=dy -- friction (lower for more) dx *=.7 dy *=.7 -- advance animation according -- to speed (or reset when -- standing almost still) spd=sqrt(dx*dx+dy*dy) f= (f+spd*2) % 4 -- 4 frames if (spd &lt; 0.05) f=0 -- collect apple if (mget(x,y)==10) then mset(x,y,14) sfx(0) end</code></pre> <p>end</p> <p>I wanted to add something along the lines of<br /> --jump<br /> if (btnp(x)) then<br /> player.dy=player.boost</p> <p>Am I missing something?</p> https://www.lexaloffle.com/bbs/?tid=46733 https://www.lexaloffle.com/bbs/?tid=46733 Thu, 24 Feb 2022 05:30:34 UTC