add momentum to sideways movement
This commit is contained in:
parent
14189a67ae
commit
0d902cb2bd
39
drip.p8
39
drip.p8
@ -15,7 +15,7 @@ function _init()
|
|||||||
-- button-press initial delay
|
-- button-press initial delay
|
||||||
poke(0x5f5c, 1)
|
poke(0x5f5c, 1)
|
||||||
-- button-press repeat
|
-- button-press repeat
|
||||||
poke(0x5f5d, 1)
|
poke(0x5f5d, 2)
|
||||||
init_world()
|
init_world()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -66,22 +66,35 @@ function update_drops()
|
|||||||
for i=1,#drops do
|
for i=1,#drops do
|
||||||
drop = drops[i]
|
drop = drops[i]
|
||||||
try_left = rnd() < 0.5
|
try_left = rnd() < 0.5
|
||||||
|
if drop.momentum == 0 then
|
||||||
|
if try_left then
|
||||||
|
drop.momentum = -1
|
||||||
|
else
|
||||||
|
drop.momentum = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
if pget(drop.x, drop.y+1) == black then
|
if pget(drop.x, drop.y+1) == black then
|
||||||
drop.y += 1
|
drop.y += 1
|
||||||
elseif try_left and drop.x > 0 then
|
elseif try_left and drop.x > 0 and
|
||||||
if pget(drop.x-1, drop.y+1) == black then
|
pget(drop.x-1, drop.y+1) == black then
|
||||||
|
drop.x -= 1
|
||||||
|
drop.y += 1
|
||||||
|
elseif drop.x < 127 and
|
||||||
|
pget(drop.x+1, drop.y+1) == black then
|
||||||
|
drop.x += 1
|
||||||
|
drop.y += 1
|
||||||
|
elseif drop.momentum == -1 then
|
||||||
|
if drop.x > 0 and pget(drop.x-1, drop.y) == black then
|
||||||
drop.x -= 1
|
drop.x -= 1
|
||||||
drop.y += 1
|
else
|
||||||
elseif pget(drop.x-1, drop.y) == black then
|
drop.momentum = 0
|
||||||
drop.x -= 1
|
end
|
||||||
end
|
elseif drop.momentum == 1 then
|
||||||
elseif drop.x < 127 then
|
if drop.x < 127 and pget(drop.x+1, drop.y) == black 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
|
drop.x += 1
|
||||||
end
|
else
|
||||||
|
drop.momentum = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if drop.y > 127 then drop.y = 127 end
|
if drop.y > 127 then drop.y = 127 end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user