From 14189a67ae4dace2910ce708d30e7adc9fbaed6d Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 9 Jun 2021 17:22:05 -0400 Subject: [PATCH] make drops flow a little better --- drip.p8 | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/drip.p8 b/drip.p8 index a63af33..d8f068c 100644 --- a/drip.p8 +++ b/drip.p8 @@ -13,9 +13,9 @@ end function _init() -- button-press initial delay - poke(0x5f5c, 2) + poke(0x5f5c, 1) -- button-press repeat - poke(0x5f5d, 2) + poke(0x5f5d, 1) init_world() end @@ -25,16 +25,16 @@ function _update() end function update_player() - if (btn(0)) then + if btn(0) then player.x -= 1 end - if (btn(1)) then + if btn(1) then player.x += 1 end - if (btn(2)) then + if btn(2) then player.y -= 1 end - if (btn(3)) then + if btn(3) then player.y += 1 end if (player.y < 0) player.y = 0 @@ -46,6 +46,7 @@ function update_player() drop = {} drop.x = player.x drop.y = player.y + drop.momentum = 0 found_drop = false for i=1,#drops do if (drops[i].x == player.x and drops[i].y == player.y) then @@ -59,20 +60,31 @@ function update_player() end end -function update_drop(drop) - drop.y += 1 - return drop.y < 128 -end - function update_drops() - new_drops = {} + cls() + draw_drops() for i=1,#drops do - result = update_drop(drops[i]) - if result then - add(new_drops, drops[i]) - end + drop = drops[i] + try_left = rnd() < 0.5 + if pget(drop.x, drop.y+1) == black then + 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 - drops = new_drops end function _draw() @@ -89,6 +101,12 @@ end function draw_drops() 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 function draw_drop(drop)