Browse Source

stop sliding after some time passes without a fall

main
Colin McMillen 3 years ago
parent
commit
615e8ffb65
  1. 24
      drip.p8

24
drip.p8

@ -47,6 +47,7 @@ function update_player()
drop.x = player.x
drop.y = player.y
drop.momentum = 0
drop.fall_time = 0
found_drop = false
for i=1,#drops do
if (drops[i].x == player.x and drops[i].y == player.y) then
@ -75,22 +76,28 @@ function update_drops()
end
if pget(drop.x, drop.y+1) == black then
drop.y += 1
drop.momentum = 0
drop.fall_time = 0
elseif try_left and drop.x > 0 and
pget(drop.x-1, drop.y+1) == black then
drop.x -= 1
drop.y += 1
drop.fall_time = 0
elseif drop.x < 127 and
pget(drop.x+1, drop.y+1) == black then
drop.x += 1
drop.y += 1
drop.fall_time = 0
elseif drop.momentum == -1 then
if drop.x > 0 and pget(drop.x-1, drop.y) == black then
drop.fall_time += 1
if drop.x > 0 and pget(drop.x-1, drop.y) == black and drop.fall_time < 10 then
drop.x -= 1
else
drop.momentum = 0
end
elseif drop.momentum == 1 then
if drop.x < 127 and pget(drop.x+1, drop.y) == black then
drop.fall_time += 1
if drop.x < 127 and pget(drop.x+1, drop.y) == black and drop.fall_time < 10 then
drop.x += 1
else
drop.momentum = 0
@ -104,8 +111,8 @@ function _draw()
cls()
draw_drops()
draw_player()
print("cpu: "..stat(1), 0, 0, light_gray)
print("drops: "..#drops, 0, 6, light_gray)
--print("cpu: "..stat(1), 0, 0, light_gray)
--print("drops: "..#drops, 0, 6, light_gray)
end
function draw_player()
@ -114,11 +121,12 @@ end
function draw_drops()
foreach(drops,draw_drop)
circfill(94, 94, 3, green)
line(20, 20, 90, 60)
line(20, 21, 90, 61)
circfill(93, 94, 3, green)
circfill(97, 105, 2, orange)
line(20, 20, 90, 60, peach)
line(20, 21, 90, 61, peach)
print("hello there", 63, 63, yellow)
print("hello everybody", 63, 63, yellow)
end

Loading…
Cancel
Save