Last active
May 13, 2020 16:48
-
-
Save sourencho/493ba7c8cda2ad2010d9b98afd3d7636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _init() | |
basket_sprite=1 | |
player_sprite=2 | |
fruit_sprite=3 | |
player_x=64 | |
player_y=100 | |
fruits={} | |
fruit_interval=16 | |
fruit_count=4 | |
gravity=1 | |
points=0 | |
for i=1,fruit_count do | |
fruit={ | |
sprite=fruit_sprite, | |
x=flr(rnd(120)), | |
y=10 | |
} | |
add(fruits,fruit) | |
end | |
end | |
function _update() | |
if btn(0) and player_x >= 2 then | |
player_x-=2 | |
end | |
if btn(1) and player_x <= (128-8-2) then | |
player_x+=2 | |
end | |
end | |
function _draw() | |
cls(12) | |
rectfill(0,108,127,127,3) | |
spr(player_sprite,player_x,player_y) | |
spr(basket_sprite,player_x,player_y-8) | |
for fruit in all(fruits) do | |
spr(fruit.sprite, fruit.x, fruit.y) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment