Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pico-8 cartridge // http://www.pico-8.com
- version 29
- __lua__
- --main functions
- poke(0x5f2d,1)
- --chooses what scene to load
- state="menu"
- --makes key presses work
- press=false
- spacebar="false"
- warning=false
- count=0
- --decides when colour appears
- timer=0
- appear=""
- --chooses the colour that appears
- scrn_col_val=""
- scrn_col_tbl={8,11,12}
- col_decide=0
- --stores the times for each colour
- red={}
- blue={}
- green={}
- red_avrg=0
- blu_avrg=0
- grn_avrg=0
- function _update60()
- if stat(31)==" " then
- press=true
- else
- press=false
- end
- --state transitions
- if state=="menu" and press==true then
- state="pre-warmup"
- end
- if state=="pre-warmup" and timer==300 then
- state="warmup"
- timer=0
- appear=flr(rnd(150))+150
- end
- if state=="warmup" and count==3 then
- state="pre-test"
- spacebar="false"
- timer=0
- end
- if state=="pre-test" and press==true and timer>140 then
- state="countdown"
- timer=181
- end
- if state=="countdown" and timer==300 then
- state="test"
- timer=0
- spacebar="false"
- end
- if state=="test" and count==18 then
- for i=1,5 do
- red_avrg+=red[i]
- blu_avrg+=blue[i]
- grn_avrg+=green[i]
- end
- state="results"
- spacebar="false"
- end
- --timer
- if state!="menu" then
- timer+=1
- end
- end
- function _draw()
- if spacebar=="false" and state=="test" or spacebar=="false" and state=="warmup" then
- cls(7)
- else
- cls(1)
- end
- textprint()
- if state=="results" then
- results()
- end
- --screen colouring
- if press==true and spacebar=="false" then
- if state=="warmup" or state=="test" then
- warning=true
- spacebar="start"
- appear=flr(rnd(150))+150
- press=false
- end
- end
- if timer==appear and spacebar=="false" then
- if state=="warmup" then
- scrn_col_val=0
- end
- if state=="test" then
- if #scrn_col_tbl==0 then
- for x in all({8,11,12}) do
- add(scrn_col_tbl,x)
- end
- end
- col_decide=flr(rnd(#scrn_col_tbl))+1
- scrn_col_val=scrn_col_tbl[col_decide]
- end
- if state!="pre-test" then
- spacebar="stop"
- end
- end
- if press==true and spacebar=="stop" then
- if state=="test" then
- if scrn_col_tbl[col_decide]==8 then
- add(red,timer-appear)
- elseif scrn_col_tbl[col_decide]==11 then
- add(green,timer-appear)
- elseif scrn_col_tbl[col_decide]==12 then
- add(blue,timer-appear)
- end
- del(scrn_col_tbl,scrn_col_tbl[col_decide])
- end
- scrn_col_val=""
- spacebar="start"
- appear=flr(rnd(150))+150
- count+=1
- press=false
- end
- if scrn_col_val!="" then
- rectfill(0,0,127,127,scrn_col_val)
- end
- if spacebar=="start" then
- if press==true then
- timer=0
- spacebar="false"
- warning=false
- end
- if count<18 then
- if warning==false then
- print("good job!",47,48,6)
- print("for the next one!",29,76,6)
- elseif warning==true then
- print("try not to press space before\nthe colour appears",5,48,6)
- end
- print("press space when you're ready",5,70,6)
- end
- end
- --[[debug
- for i=1,#green do
- print(green[i],1,1+i*6,10)
- end
- for i=1,#red do
- print(red[i],11,1+i*6,10)
- end
- for i=1,#blue do
- print(blue[i],21,1+i*6,10)
- end
- print(state,5,110,8)
- print(count,5,116,8)
- print(timer,5,122,8)
- print(appear,18,122,8)]]
- end
- -->8
- --text printers
- function textprint()
- if state=="menu" then
- print("for this test, you must press\nthe the spacebar as soon as\nthe screen changes\ncolour.",5,25,6)
- print("this test will take around 2-3\nminutes",5,65,6)
- print("press spacebar to begin!",13,92,6)
- elseif state=="pre-warmup" or state=="countdown" then
- if timer<181 then
- print("first, let's warm you up",17,54,6)
- print("get ready",47,66,6)
- end
- if timer>180 then
- print("three",53,51,6)
- end
- if timer>210 then
- print("two",57,57,6)
- end
- if timer>240 then
- print("one",57,63,6)
- end
- if timer>270 then
- print("go!",57,69,6)
- end
- elseif state=="pre-test" then
- print("now for the real test, make\nsure to press as quick as\npossible for accuracy.",5,33,6)
- if timer>139 then
- print("press spacebar to begin!",13,82,6)
- end
- end
- end
- -->8
- --results screen
- function results()
- print("thank you for participating in\nthis experiment! your results\nmean a hell of a lot to me.\nnow let me have a looksie at\nthese results.",5,25,6)
- for i=1,7 do
- line(i*18-2,70,i*18-2,102,13)
- end
- for i=1,5 do
- line(2,i*8+62,124,i*8+62,13)
- print("try"..i,i*18,72,6)
- print(round2dp(red[i]/60),i*18,80,7)
- print(round2dp(blue[i]/60),i*18,88,7)
- print(round2dp(green[i]/60),i*18,96,7)
- end
- line(2,70,2,102,13)
- rect(2,70,15,77,1)
- print("red",4,80,6)
- print("blu",4,88,6)
- print("grn",4,96,6)
- print("avrg",108,72,6)
- print(round2dp(red_avrg/300),108,80,7)
- print(round2dp(blu_avrg/300),108,88,7)
- print(round2dp(grn_avrg/300),108,96,7)
- end
- -->8
- --calculator functions
- function round2dp(x)
- return flr(x*100+0.5)/100
- end
- __gfx__
- 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Advertisement
Add Comment
Please, Sign In to add comment