Log In  
Follow
SocksTheprogrammer

Im trying to make an inverse or reverse for this function to countdown. How do I make a countdown timer?

function _update()
print(time())
if time() >= 10 then
time=0
end
end

2 comments



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)

Here is the code if any of you are wondering:

function _init()

x=24 y=24 -- position (in tiles)
dx=0 dy=0 -- velocity
f=0 -- frame number
d=1 -- direction (-1, 1)
acc=0.5
boost=.5
end

function _draw()
cls(1)

-- move camera to current room
room_x = flr(x/16)
room_y = flr(y/16)
camera(room_x128,room_y128)

-- draw the whole map (128⁙32)
map()

-- draw the player
spr(65+f, -- frame index
x8-4,y8-4, -- x,y (pixels)
1,1,d==-1 -- w,h, flip
)
end

function _update()

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(dxdx+dydy)
f= (f+spd*2) % 4 -- 4 frames
if (spd < 0.05) f=0

-- collect apple
if (mget(x,y)==10) then
mset(x,y,14)
sfx(0)
end

end

I wanted to add something along the lines of
--jump
if (btnp(x)) then
player.dy=player.boost

Am I missing something?

3 comments