clean restart for picogora
This commit is contained in:
parent
bc0a76c495
commit
f715861f14
113
picogora.p8
113
picogora.p8
@ -4,12 +4,12 @@ __lua__
|
|||||||
-- game code
|
-- game code
|
||||||
|
|
||||||
function init_world()
|
function init_world()
|
||||||
drops = {}
|
|
||||||
frozen_drops = {}
|
|
||||||
player = {}
|
player = {}
|
||||||
player.x = 64
|
player.x = 64
|
||||||
player.y = 16
|
player.y = 16
|
||||||
player.spr = 1
|
player.spr = 1
|
||||||
|
|
||||||
|
drops = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function _init()
|
function _init()
|
||||||
@ -21,8 +21,8 @@ function _init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _update()
|
function _update()
|
||||||
update_drops()
|
|
||||||
update_player()
|
update_player()
|
||||||
|
update_drops()
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_player()
|
function update_player()
|
||||||
@ -43,76 +43,20 @@ function update_player()
|
|||||||
if (player.x < 0) player.x = 0
|
if (player.x < 0) player.x = 0
|
||||||
if (player.x > 127) player.x = 127
|
if (player.x > 127) player.x = 127
|
||||||
|
|
||||||
if (btnp(🅾️)) then
|
if btnp(🅾️) then
|
||||||
drop = {}
|
drop = {}
|
||||||
drop.x = player.x
|
drop.x = player.x
|
||||||
drop.y = player.y
|
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
|
|
||||||
found_drop = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (not found_drop) then
|
|
||||||
add(drops, drop)
|
add(drops, drop)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_drops()
|
function update_drops()
|
||||||
cls()
|
|
||||||
draw_drops()
|
|
||||||
for i=1,#drops do
|
|
||||||
drop = drops[i]
|
|
||||||
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
|
|
||||||
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
|
|
||||||
drop.fall_time += 1
|
|
||||||
if drop.x > 0 and pget(drop.x-1, drop.y) == black then
|
|
||||||
drop.x -= 1
|
|
||||||
else
|
|
||||||
drop.momentum = 0
|
|
||||||
end
|
|
||||||
elseif drop.momentum == 1 then
|
|
||||||
drop.fall_time += 1
|
|
||||||
if drop.x < 127 and pget(drop.x+1, drop.y) == black then
|
|
||||||
drop.x += 1
|
|
||||||
else
|
|
||||||
drop.momentum = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if drop.y > 127 then drop.y = 127 end
|
|
||||||
end
|
|
||||||
|
|
||||||
new_drops = {}
|
new_drops = {}
|
||||||
for i=1,#drops do
|
for i=1,#drops do
|
||||||
drop = drops[i]
|
drop = drops[i]
|
||||||
if drop.fall_time > 64 then
|
drop.y += 1
|
||||||
add(frozen_drops, drop)
|
if drop.y < 128 then
|
||||||
else
|
|
||||||
add(new_drops, drop)
|
add(new_drops, drop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -120,52 +64,17 @@ function update_drops()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _draw()
|
function _draw()
|
||||||
cls()
|
cls(blue)
|
||||||
draw_drops()
|
foreach(drops, draw_drop)
|
||||||
draw_player()
|
|
||||||
--print("cpu: "..stat(1), 0, 0, light_gray)
|
|
||||||
--print("drops: "..#drops, 0, 6, light_gray)
|
|
||||||
--print("frozen: "..#frozen_drops, 0, 12, light_gray)
|
|
||||||
end
|
|
||||||
|
|
||||||
function draw_player()
|
|
||||||
spr(player.spr,player.x-1,player.y-1)
|
spr(player.spr,player.x-1,player.y-1)
|
||||||
end
|
print("drops: "..#drops, 1, 6, white)
|
||||||
|
|
||||||
function draw_drops()
|
|
||||||
foreach(frozen_drops,draw_drop)
|
|
||||||
foreach(drops,draw_drop)
|
|
||||||
circfill(94, 94, 3, green)
|
|
||||||
circfill(98, 105, 2, orange)
|
|
||||||
line(98, 115, 98, 122, pink)
|
|
||||||
line(105, 122)
|
|
||||||
line(105, 115)
|
|
||||||
|
|
||||||
line(70, 64, 90, 60, dark_purple)
|
|
||||||
line(70, 65, 90, 61, dark_purple)
|
|
||||||
|
|
||||||
line(60, 30, 80, 50, indigo)
|
|
||||||
line(60, 31, 80, 51, indigo)
|
|
||||||
|
|
||||||
line(64, 90, 74, 90)
|
|
||||||
line(70, 86)
|
|
||||||
line(68, 86, 64, 90)
|
|
||||||
|
|
||||||
ovalfill(54, 95, 74, 100, pink)
|
|
||||||
|
|
||||||
line(70, 116, 93, 112, green)
|
|
||||||
line(70, 115, 93, 111, green)
|
|
||||||
line(70, 116, 60, 112, green)
|
|
||||||
line(70, 115, 60, 111, green)
|
|
||||||
|
|
||||||
print("hello everybody", 63, 58, yellow)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw_drop(drop)
|
function draw_drop(drop)
|
||||||
pset(drop.x, drop.y, blue)
|
pset(drop.x, drop.y, white)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- library
|
-- library
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user