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> <p> -- move camera to current room<br /> room_x = flr(x/16)<br /> room_y = flr(y/16)<br /> camera(room_x<em>128,room_y</em>128)</p> <p> -- draw the whole map (128⁙32)<br /> map()</p> <p> -- draw the player<br /> spr(65+f, -- frame index<br /> x<em>8-4,y</em>8-4, -- x,y (pixels)<br /> 1,1,d==-1 -- w,h, flip<br /> )<br /> end</p> <p>function _update()</p> <p> ac=0.1 -- acceleration</p> <p> if (btn(⬅️)) dx-= ac d=-1<br /> if (btn(➡️)) dx+= ac d= 1<br /> if (btn(⬆️)) dy-= ac<br /> if (btn(⬇️)) dy+= ac</p> <p> -- move (add velocity)<br /> x+=dx y+=dy</p> <p> -- friction (lower for more)<br /> dx <em>=.7<br /> dy </em>=.7</p> <p> -- advance animation according<br /> -- to speed (or reset when<br /> -- standing almost still)<br /> spd=sqrt(dx<em>dx+dy</em>dy)<br /> f= (f+spd*2) % 4 -- 4 frames<br /> if (spd &lt; 0.05) f=0</p> <p> -- collect apple<br /> if (mget(x,y)==10) then<br /> mset(x,y,14)<br /> sfx(0)<br /> end</p> <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