Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game_w=128
- game_h=128
- function _init()
- plat={}
- plat.w=game_w
- plat.h=game_h
- plat.x=0
- plat.y=game_h/2
- player={}
- player.w=8
- player.h=8
- player.x=game_w/2
- player.y=plat.y-player.h
- player.spr=1
- player.spd=2
- player.vy=0
- player.start_vy=-5
- player.in_air=false
- grav=.5
- end
- function _update()
- if btn(➡️) then
- if player.x+player.w<game_w then
- player.x+=player.spd
- end
- end
- if btn(⬅️) then
- if player.x>0 then
- player.x-=player.spd
- end
- end
- if btnp(❎) then
- if player.vy==0 then
- player.vy=player.start_vy
- player.in_air=true
- end
- end
- if player.in_air then
- player.y+=player.vy
- player.vy+=grav
- end
- if player.y+player.h>=plat.y then
- player.vy=0
- player.in_air=false
- end
- end
- function _draw()
- cls()
- rectfill(plat.x,plat.y,plat.x+plat.w-1,plat.y+plat.h-1,7)
- spr(player.spr,player.x,player.y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement