pico-8/picogora.p8

108 lines
2.2 KiB
Plaintext
Raw Normal View History

2021-06-10 20:17:14 +00:00
pico-8 cartridge // http://www.pico-8.com
version 32
__lua__
-- game code
function init_world()
player = {}
player.x = 64
player.y = 16
player.spr = 1
2021-06-10 20:34:33 +00:00
drops = {}
2021-06-10 20:17:14 +00:00
end
function _init()
-- button-press initial delay
poke(0x5f5c, 1)
-- button-press repeat
poke(0x5f5d, 2)
init_world()
end
function _update()
update_player()
2021-06-10 20:34:33 +00:00
update_drops()
2021-06-10 20:17:14 +00:00
end
function update_player()
if btn(0) then
player.x -= 1
end
if btn(1) then
player.x += 1
end
if btn(2) then
player.y -= 1
end
if btn(3) then
player.y += 1
end
if (player.y < 0) player.y = 0
if (player.y > 127) player.y = 127
if (player.x < 0) player.x = 0
if (player.x > 127) player.x = 127
2021-06-10 20:34:33 +00:00
if btnp(🅾️) then
2021-06-10 20:17:14 +00:00
drop = {}
drop.x = player.x
drop.y = player.y
2021-06-10 20:34:33 +00:00
add(drops, drop)
2021-06-10 20:17:14 +00:00
end
end
function update_drops()
new_drops = {}
for i=1,#drops do
drop = drops[i]
2021-06-10 20:34:33 +00:00
drop.y += 1
if drop.y < 128 then
2021-06-10 20:17:14 +00:00
add(new_drops, drop)
end
end
drops = new_drops
end
function _draw()
2021-06-10 20:34:33 +00:00
cls(blue)
foreach(drops, draw_drop)
2021-06-10 20:17:14 +00:00
spr(player.spr,player.x-1,player.y-1)
2021-06-10 20:34:33 +00:00
print("drops: "..#drops, 1, 6, white)
2021-06-10 20:17:14 +00:00
end
function draw_drop(drop)
2021-06-10 20:34:33 +00:00
pset(drop.x, drop.y, white)
2021-06-10 20:17:14 +00:00
end
2021-06-10 20:34:33 +00:00
2021-06-10 20:17:14 +00:00
-->8
-- library
black = 0
dark_blue = 1
dark_purple = 2
dark_green = 3
brown = 4
dark_gray = 5
light_gray = 6
white = 7
red = 8
orange = 9
yellow = 10
green = 11
blue = 12
indigo = 13
pink = 14
peach = 15
function print_ctr(s,y,c)
print(s,64 - #s * 2,y,c)
end
__gfx__
000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000aaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
007007000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000