make drops flow a little better
This commit is contained in:
parent
a0c8c7db53
commit
14189a67ae
52
drip.p8
52
drip.p8
@ -13,9 +13,9 @@ end
|
|||||||
|
|
||||||
function _init()
|
function _init()
|
||||||
-- button-press initial delay
|
-- button-press initial delay
|
||||||
poke(0x5f5c, 2)
|
poke(0x5f5c, 1)
|
||||||
-- button-press repeat
|
-- button-press repeat
|
||||||
poke(0x5f5d, 2)
|
poke(0x5f5d, 1)
|
||||||
init_world()
|
init_world()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,16 +25,16 @@ function _update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function update_player()
|
function update_player()
|
||||||
if (btn(0)) then
|
if btn(0) then
|
||||||
player.x -= 1
|
player.x -= 1
|
||||||
end
|
end
|
||||||
if (btn(1)) then
|
if btn(1) then
|
||||||
player.x += 1
|
player.x += 1
|
||||||
end
|
end
|
||||||
if (btn(2)) then
|
if btn(2) then
|
||||||
player.y -= 1
|
player.y -= 1
|
||||||
end
|
end
|
||||||
if (btn(3)) then
|
if btn(3) then
|
||||||
player.y += 1
|
player.y += 1
|
||||||
end
|
end
|
||||||
if (player.y < 0) player.y = 0
|
if (player.y < 0) player.y = 0
|
||||||
@ -46,6 +46,7 @@ function update_player()
|
|||||||
drop = {}
|
drop = {}
|
||||||
drop.x = player.x
|
drop.x = player.x
|
||||||
drop.y = player.y
|
drop.y = player.y
|
||||||
|
drop.momentum = 0
|
||||||
found_drop = false
|
found_drop = false
|
||||||
for i=1,#drops do
|
for i=1,#drops do
|
||||||
if (drops[i].x == player.x and drops[i].y == player.y) then
|
if (drops[i].x == player.x and drops[i].y == player.y) then
|
||||||
@ -59,20 +60,31 @@ function update_player()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_drop(drop)
|
|
||||||
drop.y += 1
|
|
||||||
return drop.y < 128
|
|
||||||
end
|
|
||||||
|
|
||||||
function update_drops()
|
function update_drops()
|
||||||
new_drops = {}
|
cls()
|
||||||
|
draw_drops()
|
||||||
for i=1,#drops do
|
for i=1,#drops do
|
||||||
result = update_drop(drops[i])
|
drop = drops[i]
|
||||||
if result then
|
try_left = rnd() < 0.5
|
||||||
add(new_drops, drops[i])
|
if pget(drop.x, drop.y+1) == black then
|
||||||
end
|
drop.y += 1
|
||||||
|
elseif try_left and drop.x > 0 then
|
||||||
|
if pget(drop.x-1, drop.y+1) == black then
|
||||||
|
drop.x -= 1
|
||||||
|
drop.y += 1
|
||||||
|
elseif pget(drop.x-1, drop.y) == black then
|
||||||
|
drop.x -= 1
|
||||||
|
end
|
||||||
|
elseif drop.x < 127 then
|
||||||
|
if pget(drop.x+1, drop.y+1) == black then
|
||||||
|
drop.x += 1
|
||||||
|
drop.y += 1
|
||||||
|
elseif pget(drop.x+1, drop.y) == black then
|
||||||
|
drop.x += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if drop.y > 127 then drop.y = 127 end
|
||||||
end
|
end
|
||||||
drops = new_drops
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function _draw()
|
function _draw()
|
||||||
@ -89,6 +101,12 @@ end
|
|||||||
|
|
||||||
function draw_drops()
|
function draw_drops()
|
||||||
foreach(drops,draw_drop)
|
foreach(drops,draw_drop)
|
||||||
|
circfill(94, 94, 3, green)
|
||||||
|
line(20, 20, 90, 60)
|
||||||
|
line(20, 21, 90, 61)
|
||||||
|
|
||||||
|
print("hello there", 63, 63, yellow)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw_drop(drop)
|
function draw_drop(drop)
|
||||||
|
Loading…
Reference in New Issue
Block a user