Coroutines Implemented for Planting
This commit is contained in:
parent
a805969790
commit
74ecb35c65
95
continuum.p8
95
continuum.p8
@ -57,6 +57,9 @@ function _init()
|
|||||||
confirm_trigger=false
|
confirm_trigger=false
|
||||||
cancel_trigger=false
|
cancel_trigger=false
|
||||||
|
|
||||||
|
menu_cor = cocreate(open_menu)
|
||||||
|
close_menu_cor = cocreate(close_menu)
|
||||||
|
|
||||||
palt(0,0)
|
palt(0,0)
|
||||||
end
|
end
|
||||||
--<<<=====update======>>>
|
--<<<=====update======>>>
|
||||||
@ -70,41 +73,23 @@ function _update()
|
|||||||
_toggle_rain()
|
_toggle_rain()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (btnp(4) and costatus(close_menu_cor) ~= "dead") then coresume(close_menu_cor) end --🅾️
|
||||||
|
if (btnp(4) and costatus(close_menu_cor) == "dead") then close_menu_cor = cocreate(close_menu) coresume(close_menu_cor) end --🅾️
|
||||||
|
|
||||||
if (crossbar==false) then
|
if (crossbar==false) then
|
||||||
move_player()
|
move_player()
|
||||||
-- while btn(0) do p.ymov=false end
|
if (btnp(5) and costatus(menu_cor) ~= "dead") then coresume(menu_cor) end --❎
|
||||||
-- while btn(1) do p.ymov=false end
|
if (btnp(5) and costatus(menu_cor) == "dead") then menu_cor = cocreate(open_menu) coresume(menu_cor) end --❎
|
||||||
-- while btn(2) do p.ymov=true end
|
|
||||||
-- while btn(3) do p.ymov=true end
|
|
||||||
end
|
end
|
||||||
if crossbar then
|
|
||||||
if (crossbarnum==0) then
|
if (crossbar and (btnp(0) or btnp(1) or btnp(2) or btnp(3))) then
|
||||||
if (btn(0)) then crossbarnum=1 end --⬅️ Measure
|
coresume(menu_cor)
|
||||||
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
|
end
|
||||||
if (crossbarnum>0) then
|
if (crossbarnum>0 and (btnp(0) or btnp(1) or btnp(2) or btnp(3))) then
|
||||||
if btn(0) then i=0 end
|
coresume(menu_cor)
|
||||||
if btn(1) then i=1 end
|
end
|
||||||
if btn(2) then i=2 end
|
-- if btnp(5) then sfx(0,3,-2) end
|
||||||
if btn(3) then i=3 end
|
-- if btnp(4) then sfx(1,3,-2) end --shake+=1
|
||||||
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
|
|
||||||
--plant
|
|
||||||
if (crossbarnum==4 and btnp(2)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,46) _close_menu() end --crops
|
|
||||||
if (crossbarnum==4 and btnp(1)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,42) _close_menu() end --grass
|
|
||||||
if (crossbarnum==4 and btnp(3)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,44) _close_menu() end --shrubs
|
|
||||||
if (crossbarnum==4 and btnp(0)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,46) _close_menu() end --trees
|
|
||||||
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,-2) end
|
|
||||||
if btnp(4) then sfx(1,3,-2) end --shake+=1
|
|
||||||
--if (crossbarnum==4 and btnp(3)) then sfx(0,3,0) crossbarnum=0 crossbar=false end
|
--if (crossbarnum==4 and btnp(3)) then sfx(0,3,0) crossbarnum=0 crossbar=false end
|
||||||
local dayfactor=160 --320
|
local dayfactor=160 --320
|
||||||
sun.x = sun.tmr/6
|
sun.x = sun.tmr/6
|
||||||
@ -210,7 +195,7 @@ function _draw()
|
|||||||
line(21+cam_x,2+cam_y,30+cam_x,2+cam_y,8)
|
line(21+cam_x,2+cam_y,30+cam_x,2+cam_y,8)
|
||||||
spr(50,32+cam_x,0+cam_y)
|
spr(50,32+cam_x,0+cam_y)
|
||||||
line(37+cam_x,2+cam_y,46+cam_x,2+cam_y,12)
|
line(37+cam_x,2+cam_y,46+cam_x,2+cam_y,12)
|
||||||
-- print(d20,48+cam_x,cam_y,10)
|
print(crossbarnum,48+cam_x,cam_y,10)
|
||||||
-- print(camy,56+cam_x,cam_y,11)
|
-- print(camy,56+cam_x,cam_y,11)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -352,9 +337,6 @@ end
|
|||||||
-->8
|
-->8
|
||||||
--camera follow functions
|
--camera follow functions
|
||||||
|
|
||||||
--this function will move the
|
|
||||||
--camera to always put the
|
|
||||||
--player at the center.
|
|
||||||
function camera_follow()
|
function camera_follow()
|
||||||
|
|
||||||
cam_x=p.x-28
|
cam_x=p.x-28
|
||||||
@ -368,6 +350,49 @@ cam_y=mid(0,cam_y,76)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-->8
|
||||||
|
--menu coroutines
|
||||||
|
function open_menu()
|
||||||
|
crossbar = true
|
||||||
|
sfx(0,3,0)
|
||||||
|
yield()
|
||||||
|
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
|
||||||
|
sfx(0,3,0)
|
||||||
|
yield()
|
||||||
|
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
|
||||||
|
end
|
||||||
|
sfx(0,3,0)
|
||||||
|
yield()
|
||||||
|
if (crossbarnum==4 and btnp(2)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,46) close_menu() end --crops
|
||||||
|
if (crossbarnum==4 and btnp(1)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,42) close_menu() end --grass
|
||||||
|
if (crossbarnum==4 and btnp(3)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,44) close_menu() end --shrubs
|
||||||
|
if (crossbarnum==4 and btnp(0)) then mset(flr(p.x+3)/8,flr(p.y+5)/8-1,46) close_menu() end --trees
|
||||||
|
sfx(0,3,0)
|
||||||
|
coresume(close_menu_cor)
|
||||||
|
if (costatus(close_menu_cor)=="dead") then close_menu_cor = cocreate(close_menu) end
|
||||||
|
yield()
|
||||||
|
end
|
||||||
|
|
||||||
|
function close_menu()
|
||||||
|
crossbar = false
|
||||||
|
crossbarnum = 0
|
||||||
|
sfx(1,3,0)
|
||||||
|
yield()
|
||||||
|
end
|
||||||
|
|
||||||
__gfx__
|
__gfx__
|
||||||
65566600000003b0004400000007000070000070000c000000007a9000007770000800000666650077777777000880000011110000007000000a900000006d00
|
65566600000003b0004400000007000070000070000c000000007a9000007770000800000666650077777777000880000011110000007000000a900000006d00
|
||||||
6666656000003b3004ff4440000700000700070000c6c0000007a9000007777700088008000056d0711111110888888001999910000766000a0000900006d000
|
6666656000003b3004ff4440000700000700070000c6c0000007a9000007777700088008000056d0711111110888888001999910000766000a0000900006d000
|
||||||
|
Loading…
Reference in New Issue
Block a user