ContinuumGame/continuum.p8

449 lines
18 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pico-8 cartridge // http://www.pico-8.com
version 36
__lua__
-- continuum
-- by lightmotif
poke(0x5f2c,3)
function _init_rain()
rain={}
rainminx=0
rainminy=0
rainmaxx=64
rainmaxy=64
israining=false
cool={1,12,7}
local totalrain=64
for i=1,totalrain do
local rndspd=flr(rnd(3)+1)
add(rain,{
x=rnd(64),
y=rnd(64),
spd=rndspd
})
end
end
--<<<=======init========>>>
function _init()
_init_rain()
make_player()
sx = 0 sy = 13
px = 28 py = 28
sun = {}
sun.sprt = 14
sun.tmr = 1
sun.x = sx
sun.y = sy
day = true
crossbar = false
crossbarnum = 0
skyclr1 = 1
skyclr2 = 12
plyr = {}
plyr.x = px
plyr.y = py
plyr.sprt = 32
plyr.tmr = 1
plyr.flp = false
plyani = {}
plyani.f1 = 32
plyani.f2 = 33
plyr.ymov = false
shake=0
confirm_trigger=false
cancel_trigger=false
camx=0
camy=0
end
--<<<=====update======>>>
function _update()
camx = peek2(0x5f28)
camy = peek2(0x5f2a)
if (crossbar==false) then
move_player()
--if (btn(0)) then plyr.x=plyr.x-1 plyani.f1=34 plyani.f2=35 plyr.flp=true plyr.ymov=false end --⬅️
--if (btn(1)) then plyr.x=plyr.x+1 plyani.f1=34 plyani.f2=35 plyr.flp=false plyr.ymov=false end --➡️
--if (btn(2)) then plyr.y=plyr.y-1 plyani.f1=36 plyani.f2=36 plyr.flp=false plyr.ymov=true end --⬆️
--if (btn(3)) then plyr.y=plyr.y+1 plyani.f1=33 plyani.f2=33 plyr.flp=false plyr.ymov=true end --⬇️
end
if crossbar then
if (crossbarnum==0) then
if (btn(0)) then crossbarnum=1 end --⬅️ Measure
if (btn(1)) then crossbarnum=2 end --➡Act
if (btn(2)) then crossbarnum=3 end --⬆Build
if (btn(3)) then crossbarnum=4 end --⬇Plant
end
if (crossbarnum>0) then
if btn(0) then i=0 end
if btn(1) then i=1 end
if btn(2) then i=2 end
if btn(3) then i=3 end
if (crossbarnum==1) then _measure(i) end
if (crossbarnum==2) then _act(i) end
if (crossbarnum==3) then _build(i) end
if (crossbarnum==4) then _plant(i) end
--if btnp(0) or btnp(1) or btnp(2) or btnp(3) then crossbar=false crossbarnum=0 end
end
end
if (btn(5)) then crossbar=true sfx(0,3,0) end --❎
if (btn(4)) then crossbar=false sfx(1,3,0) crossbarnum=0 end --🅾️
if btnp(5) then sfx(0,3) sfx(-1,3) end
if btnp(4) then sfx(1,3) sfx(-1,3) end --shake+=1
local dayfactor=160 --320
sun.x = sun.tmr/6
if sun.tmr<=dayfactor then
sun.y = sun.y-8/dayfactor
end
if sun.tmr>dayfactor then
sun.y = sun.y+8/dayfactor
end
_update_rain()
end
--<<<====draw======>>>
function _draw()
cls()
pal()
--center camera on player
camera_follow()
--do the shaking
doshake()
--sky
rectfill(0,5,64,17,skyclr2)
rectfill(0,5,64,7,skyclr1)
spr(sun.sprt,sun.x,sun.y)
--map
rectfill(0,17,64,64,4)
map(0,0,0,12,33,18)
--player
spr(p.sprt,p.x,p.y)
-- spr(plyr.sprt,plyr.x,plyr.y,1,1,plyr.flp)
--celestial bodies
sun.tmr = sun.tmr+1
if sun.tmr>=320 then --64
sun.x = 0
sun.y = 13
if day then
sun.sprt = 24
skyclr1 = 0
skyclr2 = 1
day = false
else
sun.sprt = 14
skyclr1 = 1
skyclr2 = 12
day = true
end
sun.tmr = 0
end
plyr.tmr = plyr.tmr+1
if plyr.tmr>=5 then
if (plyr.ymov) plyr.flp=false
plyr.sprt = plyani.f1
end
if plyr.tmr>=10 then
if (plyr.ymov) plyr.flp=true
plyr.sprt = plyani.f2
plyr.tmr = 0
end
--crossbar
if crossbar then
--outlines
rect(plyr.x-1,plyr.y-9,plyr.x+8,plyr.y-1,10)
rect(plyr.x+8,plyr.y-1,plyr.x+16,plyr.y+8,11)
rect(plyr.x-1,plyr.y+8,plyr.x+8,plyr.y+16,12)
rect(plyr.x-9,plyr.y-1,plyr.x-1,plyr.y+8,8)
if (crossbarnum==0) then --mainmenu
spr(0,plyr.x,plyr.y-8)
spr(2,plyr.x+8,plyr.y)
spr(1,plyr.x,plyr.y+8)
spr(18,plyr.x-8,plyr.y)
end
if (crossbarnum==1) then --measure
spr(13,plyr.x,plyr.y-8)
spr(15,plyr.x+8,plyr.y)
spr(20,plyr.x,plyr.y+8)
spr(5,plyr.x-8,plyr.y)
end
if (crossbarnum==2) then --act
spr(9,plyr.x,plyr.y-8)
spr(5,plyr.x+8,plyr.y)
spr(19,plyr.x,plyr.y+8)
spr(26,plyr.x-8,plyr.y)
end
if (crossbarnum==3) then --build
spr(6,plyr.x,plyr.y-8)
spr(16,plyr.x+8,plyr.y)
spr(11,plyr.x,plyr.y+8)
spr(5,plyr.x-8,plyr.y)
end
if (crossbarnum==4) then --plant
spr(17,plyr.x,plyr.y-8)
spr(21,plyr.x+8,plyr.y)
spr(22,plyr.x,plyr.y+8)
spr(23,plyr.x-8,plyr.y)
end
--colors 10,11,12,8
end
--draw rain
if(israining) then _draw_rain() end
--menu
rectfill(0,0,64,5,0)
spr(48,0,0)
line(5,2,14,2,10)
spr(49,16,0)
line(21,2,30,2,8)
spr(50,32,0)
line(37,2,46,2,12)
print(camx,48,0,10)
print(camy,56,0,11)
end
function doshake()
local shakex=16-rnd(32)
local shakey=16-rnd(32)
shakex*=shake
shakey*=shake
camera(shakex,shakey)
shake=shake*0.95
if (shake<0.05) shake=0
end
function _update_rain()
for drp in all(rain) do
drp.y+=drp.spd+2
if(drp.y>=rainmaxy) then
drp.y=rainminy
drp.x=(flr(rnd(64)))
drp.spd=flr(rnd(3)+1)
end
end
end
-- 2,1,3,0 Up,Right,Down,Left
function _build(button)
--israining=true
print(tostring(button),0,16,10)
--energy
--battery
--house
--water
end
function _act(button)
--gather
--water
--remove
--upgrade
end
function _plant(button)
--crops
--grass
--shrub
--tree
end
function _measure(button)
--temp
--wind
--soil
--water
end
function _draw_rain()
for drp in all(rain) do
if(drp.spd==3) then
line(drp.x,drp.y-3,drp.x,drp.y-5,cool[1])
line(drp.x,drp.y-1,drp.x,drp.y-3,cool[2])
pset(drp.x,drp.y,cool[3])
end
if(drp.spd==2) then
line(drp.x,drp.y-1,drp.x,drp.y-2,cool[1])
pset(drp.x,drp.y,cool[2])
end
if(drp.spd==1) then
line(drp.x,drp.y-1,drp.x,drp.y-1,cool[1])
pset(drp.x,drp.y,cool[2])
end
end
end
-->8
--player functions
function make_player()
p={}
p.x=28
p.y=28
p.dx=0
p.dy=0
p.w=7
p.h=7
p.sprt=32
end
function move_player()
if (btn()) p.dx-=1
if (btn()) p.dx+=1
if (btn()) p.dy-=1
if (btn()) p.dy+=1
if (can_move(p.x+p.dx,p.y,p.w,p.h)) then
p.x+=p.dx
end
if (can_move(p.x,p.y+p.dy,p.w,p.h)) then
p.y+=p.dy
end
p.dx,p.dy=0,0
end
-->8
--collision functions
function can_move(x,y,w,h)
if (solid(x,y-12)) return false
if (solid(x+w,y-12)) return false
if (solid(x,y+h-12)) return false
if (solid(x+w,y+h-12)) return false
return true
end
function solid(x,y)
local map_x=flr(x/8)
local map_y=flr(y/8)
local map_sprite=mget(map_x,map_y)
local flag=fget(map_sprite)
return flag==1
end
-->8
--camera follow functions
--this function will move the
--camera to always put the
--player at the center.
function camera_follow()
--the camera shows 128 pixels
--across and 128 pixels down.
--by default, the pixels it
--shows start at coordinate
--0,0 and go to 127,127. this
--is why pixel coordinate 8,4
--would also show up the screen
--at coordinate 8,4.
--you can change which block of
--pixels are shown with the
--camera() function. by giving
--the camera() function a new
--x,y coordinate, you can
--tell the camera to start
--drawing from that new
--coordinate instead. if you
--used camera(100,100) then the
--camera would draw the pixel
--at 100,100 to the screen
--coordinate 0,0. this means
--that pset(108,104,1) would
--draw a pixel at screen
--coordinate 8,4.
--since the camera position is
--where the top-left corner of
--the screen is, if we want to
--keep the player in the middle
--of the screen, we need to
--set the camera's x,y to the
--player's x,y minus 60.
cam_x=p.x-28
cam_y=p.y-28
--if the player is on the
--edge of the map, keeping
--player centered means you'll
--see past the edge of the map.
--we can use the mid() function
--to make sure the camera
--position can't move past
--coordinates that would show
--past the edge of the map.
cam_x=mid(0,cam_x,896)
cam_y=mid(0,cam_y,128)
--change the camera position
camera(cam_x,cam_y)
end
__gfx__
65566600000003b0004400000007000070000070000c000000007a9000007770000800000666650077777777000880000011110000007000000a900000006d00
6666656000003b3004ff4440000700000700070000c6c0000007a9000007777700088008000056d0711111110888888001999910000766000a0000900006d000
655650560003b3b04f444ff4000700000070700000c66c00007a900007c7777700008800000005657171717c11111111179899e10007650000099000006d0660
00045000003b3b004ffff44400757000000700000cc666c007aaaaa0777c77c7000089800000505571111ccc8888888817789ee100078500a09aa90906d06dd6
00045000003b30004fff4ff40705070000070000ccc66cc000000a90c777777c0808998000050005717c7c7c8884488817778ee100068500909aa90a06d000d6
00045000044400004ffff4407005007000070000ccccccc00000a9000cccccc0008aaa9800500005777777770884488017778ee1000585000009900006dd60d6
0004500004f200004fff4f4000050000000500000ccccc00000a900000101010008a7a80050000010220022008814880171111e1005e8e50090000a000660d60
000450000222000004fff000001510000015100000ccc000000a000000c0c0c000088800500000001111111108844880011111100005e5000009a0000000d600
0000000000003b0000011000008888000000000000000000000000000033b330000aaa0000000000000cc0000033b330ff33b33f000060004444444400000000
000000000000b300001771000877788000000000000000000000000003b3331300a9999000a0000000c77c0003b33813f3b33313500666004406566400000000
566666600088320001777610877788881444f44100000000003bb300033131310a999119000000000c7777c003813138f3313131556666654650050600000000
53b3b3b608ee88200177761087788878144444410000b000037b33103b3311030a991111000000a0c777777c3b3318033b3311f3533366336500066000000000
13b3b3b508e888200016610087888778144444f10b0b303003b33b30030440000a9911110000a000ccc77ccc03044000f3f44fff333333336656005400000000
1111111008888220000110008888777814f44441003b3b000333b130000420000a999119000a9a0000c77c0000042000fff42fff333333334660560600000000
00000000008822000006500008877780014444100000000003b3331000042000019999910000a00000c77c000004200011142111333333334005650400000000
0000000000022000000650000088880000111100000000000031310000242200001999100000000000cccc000024220011242211444444444460004400000000
0006600000066000000666000000000000066000fffff9ffcccccccc444444443333333344244444444444444444444444444444444444444444444444444444
0076670000766700006766600006660000766700ff9fffffcc77cc77222222223b3b333344444244414141414b434b4b4121412143b343b34444444444444344
09711790097117900679761000676660097667909ffffff977cc77cc4444444433b33b33244444444444444444444444423141313b313b31444444444b434b44
0076670000766700006766600679761000766700ffff9fffcccccccc222222223333333344424424414141414343434b41124112431443144444444444b44b43
0006600000066000000666000067666007555579ff9fffffcccccccc4444444433333333424444444444444444444444444444444444444444444444439444b4
0755557000755590000575000005579090555500fffff9ffcc77cc7722222222333b3b334444444441414141434b43434112421143b343b34131413144944494
9066660909066600000696000096666000666600f9ffffff77cc77cc444444443b33b333244442444444444444444444423141323b313b314131413141414141
0090090000090000000669900099009900000900fff9ff9fcccccccc22222222333333334424444241414141434b434b41124121431443144414441444144414
000a0000003300000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00a000000e30000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0aaa00008ee200000c6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00a0000088820000cc6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0a000000082000000cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0000000000000000000000000000000000000000000000000000000000010000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252525252525252525252525252525252525252525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252525252525252525252525252525252525252525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252629292929292925252525292925252525252525252525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252929292929292929252529292925252525252525252525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252929292929292929292929292525252525252529292525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252529292929292929292929252525252525252929292925252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252929292929292929252525252525252929292925252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252929292929292929252525252525252929292925252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525292929292929292929292525252525252929292925252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252529292929292929292929292925252525252929292925252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252929292929292929292929292925252525252529292525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252529292925252525252525252525252525252525252525252525262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252525252525252525252525252525252525252525252526262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1d25252525252525252525252525252525252525252525252525252626262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2626262626262626262626262626262626262626262626262626262626262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2626262626262626262626262626262626262626262626262626262626262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2626262626262626262626262626262626262626262626262626262626262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2626262626262626262626262626262626262626262626262626262626262626262600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000026260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
010200003327036271362750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010c00002927526200262750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000