--# Board -- oKTUM 7.7 -- marke all and copy, then paste it in an new clean project function drawboard(val) --print(val) showplayer(val*3) noFill() strokeWidth(21-val) fb=255-((math.sin(val/3.1)*110)+140) -- print(fb) stroke(fb) --stroke(0, 94, 254, fb) x=0 y=0 w=WIDTH h=HEIGHT rect(x,y,w,h) x=0 y=h-400 rect(x,y,500,400) y=h-500+10 for i=0,3 do temp=135 if i==3 then temp=125 end rect(x+(125*i),y,temp,100) end strokeWidth(11-(val/2)) print(maxplayers) x0=525+((4-maxplayers)*113) y0=50 for i=0,maxplayers do x=x0+(i*113) line(x,y0,x,y0+(10*60)) end for i=0,10 do line(x0,y0+(i*60),x0+(maxplayers*113),y0+(i*60)) end end function showplayer(val) strokeWidth(5) fill(50) x0=525+((4-maxplayers)*113)+50 -- x0=525+50 y0=50 showText(dicenr,250,600,150,255 ) stroke(50) rect(505,655,490,90) ttx=0 for i=1,maxplayers do x=x0+((i-1)*113) showText("pLAYER "..i,x,y0+(11*60),15,255 ) fill(50) if aktplayer==0 then showText(playername[i],x,y0+(10.5*60),22,255 ) else if i == aktplayer then showText(playername[i],x,y0+(10.5*60),(val/3),255 ) else showText(playername[i],x,y0+(10.5*60),22,255 ) end end playersum[i]=0 for n=1,10 do rect(x-45,y0+(10.5*60)-(n*60)-27,100,55) if n<=aktround then if aktplayer==i and aktround==n then showText(playerdp[i][n],x+30,y0+(10.5*60)-(n*60)+8,(val/4),val+50) else if playerdp[i][n]~=-1 then showText(playerdp[i][n],x+40,y0+(10.5*60)-(n*60)+20,12,150 ) end end if playerpoints[i][n]~=-1 then showText(playerpoints[i][n],x-10,y0+(10.5*60)-(n*60)-10,24,255 ) end end if playerpoints[i][n]~=-1 then playersum[i]=playersum[i]+playerpoints[i][n] end end -- showText(playersum[i],x-10,y0-20,20,150 ) if aktplayer>= i then if aktplayer==i then if aktround~=1 then playersum[i]=playerpoints[i][aktround-1]+playerdp[i][aktround] end else playersum[i]=playerpoints[i][aktround] end else if aktround~=1 then playersum[i]=playerpoints[i][aktround-1] end end if playersum[i]>ttx then ttx=playersum[i] winner=i xm=x end end rect(525,20,460,25) if winner~=0 then showText("wILL wIN",xm,y0-20,15,150 ) end showText("pOINTS = "..dicesum,200,200,30,150 ) end function dice() -- rect(25,290,450,450) rnd=math.random(6) --showText(rnd,CurrentTouch.x,CurrentTouch.y,150,255 ) dicenr=rnd if dicenr~=1 then playerdp[aktplayer][aktround]=playerdp[aktplayer][aktround]+dicenr showplayer(20) dicesum =dicesum + dicenr else sound(DATA, "ZgBALQBBO0dERC5GQAipPgnUDT/YTyy+eQAYcUBAMi04Eg8B") playerdp[aktplayer][aktround]=0 nextplayer() showplayer(20) dicesum=0 end end function nextplayer() dicesum=0 if aktround==1 then playerpoints[aktplayer][aktround]=playerdp[aktplayer][aktround] else playerpoints[aktplayer][aktround]=playerpoints[aktplayer][aktround-1]+playerdp[aktplayer][aktround] end gamestate=9 dl=0 end function drawdice() rect(25,400,450,340) rnd=math.random(6) x=math.random(300) y=math.random(150) showText(rnd,x+100,HEIGHT-y-100,150,255 ) sound(DATA, "ZgNAPAAQNHl/PjAKAAAAAAAAAAAjnvk9JgBceUVDPjJEcRYw") end function drawppoints(val) i=aktplayer n=aktround x=x0+((i-1)*113) -- fill(241, 4, 4, 255) rect(x-45,y0+(10.5*60)-(n*60)-27,100,55) showText(playerpoints[i][n]+val,x-10,y0+(10.5*60)-(n*60)-10,24,255 ) showText(playerdp[i][n]-val,x+30,y0+(10.5*60)-(n*60)+8,playerdp[i][n]-val+3,250) end --# Funktionen -- funktionen d1=0 d2=0 d3=0 d4=0 d5=0 d6=0 d7=0 d8=0 l=0 r=0 function splashscreen() background(40, 40, 50) showText("wELCOME tO oKTUM#oKTUM iS wAITING FOR yOU",WIDTH/2,HEIGHT/2,24,255 ) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+1 if px>100 then px=100 end if timer>1 then showText("(tOUCH tO sTART)#(yOU cAN tOUCH hERE)",WIDTH/2,HEIGHT/2-52,24,tx) end sprite("Cargo Bot:Made With Codea",WIDTH/2,px ,260) sprite("Cargo Bot:Codea Icon",WIDTH/2,HEIGHT/2+200,260) end function infotmation() background(40, 40, 50) showText("oKTUM",WIDTH/2,HEIGHT-100,px,255 ) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) showText("fOR oNE pLAYER ? - nOT rEALY gOOD bUT iT'S wORK",WIDTH/2,500,24,d1) showText("fOR tWO pLAYER ? - yES wE cAN, bUT mORE pLAYER mORE fUN",WIDTH/2,450,24,d2) showText("fOR tHREE pLAYER ? - yEEE, bABY",WIDTH/2,400,24,d3) showText("fOR fOURE pLAYER ? - YES... uPS, i mEANT... yES. tHATS tHE rIGHT nUMBER oF pLAYERS",WIDTH/2,350,24,d4) if timer>1 then showText("(tOUCH aGAIN)",WIDTH/2,52,24,tx) end end function rules1() background(40, 40, 50) showText("oKTUM",WIDTH/2,HEIGHT-100,50,255 ) showText("rULES",WIDTH/2+100,HEIGHT-150,50,255 ) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) showText("wE hAVE oNE dICE",WIDTH/2,500,24,d1) showText("tHE pLAYER rOLLS tHE dICE",WIDTH/2,450,24,d2) showText("yOU cAN cOUNT aLL pOINTS oF tHE dICE ",WIDTH/2,400,24,d3) showText("bUT iF yOU rOLLE a sINGL, yOU wILL lOSE aLL pOINTS yOU cOUNT iN tHIS rOUND",WIDTH/2,350,24,d4) showText("aND tHE nEXT pLAYER hAS iTS tURN",WIDTH/2,300,24,d5) showText("bUT yOU cAN sAY tHE mAGIC wORD 'iKTIM'",WIDTH/2,250,24,d6) showText("aND tHE nEXT pLAYER hAS iTS tURN",WIDTH/2,200,24,d5) showText("aND aLL yOUR cOUNT wILL bE pOINTS fOR yOUR pLAYER",WIDTH/2,150,24,d7) -- if timer>1 then showText("(tOUCH mE pLEASE aGAIN)",WIDTH/2,52,24,tx) end end function rules2() background(40, 40, 50) showText("oKTUM",WIDTH/2,HEIGHT-100,50,255 ) showText("pLAYERS",WIDTH/2-100,HEIGHT-150,50,255 ) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) showText("oK i wILL aSK yOU nOW fOR pLAYERS nAME",WIDTH/2,500,24,d1) showText("wRITE 'comp' fOR cOMPUTER",WIDTH/2,450,24,d2) showText("yOU nEED mINIMUM tWO pLAYERS",WIDTH/2,400,24,d3) showText("gOOD lUCK :-)",WIDTH/2,350,24,d4) -- if timer>1 then showText("(tOUCH mE pLEASE aGAIN)",WIDTH/2,52,24,tx) end end function showplay() background(40, 40, 50) showText("oKTUM",WIDTH/2,HEIGHT-100,50,255 ) showText("aND hERE'S nOW tHE rESULT oF tHE pLAYERS",WIDTH/2,HEIGHT-150,30,155) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) countd(100,0) showText("pLAYER 1",WIDTH/2-300,HEIGHT-200,px/2,d1) showText(playername[1],WIDTH/2-300,HEIGHT-250,100-px/2,d1) if maxplayers>= 2 then showText("pLAYER 2",WIDTH/2-100,HEIGHT-250,px/2,d2) showText(playername[2],WIDTH/2-100,HEIGHT-300,100-px/2,d2) end if maxplayers>= 3 then showText("pLAYER 3",WIDTH/2+100,HEIGHT-200,px/2,d3) showText(playername[3],WIDTH/2+100,HEIGHT-250,100-px/2,d3) end if maxplayers>= 4 then showText("pLAYER 4",WIDTH/2+300,HEIGHT-250,px/2,d4) showText(playername[4],WIDTH/2+300,HEIGHT-300,100-px/2,d4) end if timer>1 then showText("(tOUCH mE pLEASE aGAIN)",WIDTH/2,52,24,tx) showText("(aND sORRY fOR tHAT mANY tOUCHING)",WIDTH/2,32,12,tx) end end function showwinner() background(40, 40, 50) showText("oKTUM",WIDTH/2,HEIGHT-100,50,255 ) showText("aND hERE'S nOW tHE rESULT oF tHE wINNER",WIDTH/2,HEIGHT-150,30,155) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) countd(100,0) for i=1 , maxplayers do ttx=30 if winner==i then ttx=px end if i==1 or i==3 then temp=200 end if i==2 or i==4 then temp=250 end showText("pLAYER "..i,100+(200*i),HEIGHT-temp,ttx/2,d1) showText(playername[i],100+(200*i),HEIGHT-temp-50,60-ttx/2,d1) showText(playersum[i],100+(200*i),HEIGHT-temp-100,ttx/2,d1) end if timer>2 then showText("(tOUCH hERE tO pLAY ",300,200,24,tx) showText("wHITH nEW pLAYERS)",400,150,24,tx) showText("(tOUCH hERE tO pLAY ",700,200,24,tx) showText("wHITH sAME pLAYERS)",800,150,24,tx) end end function splayer(aktplayer) background(40, 40, 50) showText("pLAYER ".. aktplayer,WIDTH/2,HEIGHT-100,px,255 ) tx=tx+dx if tx > 254 or tx<10 then dx=-dx end px=px+ppx if px>100 or px<40 then ppx=-ppx end countd(100,0) showText("we nEED mINIMUM tWO pLAYERS",WIDTH/2,550,24,d1) showText("pRESS rETURN tO eND",WIDTH/2,500,24,d2) showText("wRITE 'cOMP' fOR a cOMPUTER",WIDTH/2,450,24,d2) showText(playername[1],150,HEIGHT-50,px/2,255) showText(playername[2],150,HEIGHT-80,px/2,255) showText(playername[3],150,HEIGHT-110,px/2,255) showText(playername[4],150,HEIGHT-140,px/2,255) if d1==10 then showKeyboard() end if d1>10 then buffer = keyboardBuffer() key=keyboard(key) if buffer then showText( buffer, WIDTH/2,400,100,255 ) end end end function keyboard(key) -- Did the user press backspace? if key ~= nil then if string.byte(key) == 10 then -- if yourtext == "" then yourtext="cOMP" end if yourtext == "" then if aktplayer<3 then yourtext="cOMP" else yourtext="eND1" maxplayers=aktplayer-1 print(maxplayers) gamestate=8 end end l=string.len(yourtext) if l>6 then l=6 end yourtext=string.lower(string.sub(yourtext,1,1)) .. string.upper(string.sub(yourtext,2,l)) playername[aktplayer]=yourtext yourtext="" hideKeyboard() dl=0 --do something with "return" key elseif string.byte(key) == nil then --must be a backspace if string.len(yourtext) > 0 then yourtext = string.sub(yourtext, 1, string.len(yourtext) - 1) end else yourtext = yourtext..key end end end function showText(str , x , y , size, tx ) if size==0 then size=24 end l=string.find(str,"#",1,1) -- print (l) if l ~= nil then if rnd >5 then str=string.sub(str,1,l-1) else str=string.sub(str,l+1,99) end end pushStyle() fill(255, 255, 255, tx) font("Noteworthy-Bold") fontSize(size) text(str,x,y) popStyle() end function countd(xmax,mode) d1=d1 + 1 if d1>xmax then d2=d2+1 end if d2>xmax then d3=d3+1 end if d3>xmax then d4=d4+1 end if d4>xmax then d5=d5+1 end if d5>xmax then d6=d6+1 end if d6>xmax then d7=d7+1 end end function clearcountd() d1=0 d2=0 d3=0 d4=0 d5=0 d6=0 d7=0 d8=0 end function playsound(val) if val==1 then sound(DATA, "ZgBAJwBAVAAdPjZrx5MmPfnPgj1wZa4+XwBkWlNAPz4eSGx7") end if val==2 then sound(DATA, "ZgFABgA/ZH9WQHB63agAPHTA1z5QdEU+YgBiWkdAEUdiags4") end if val==3 then sound(DATA, "ZgFAQAAbPwxEQUweRJPnPrBRGj/AZWo/XwBaTUZCZQcZZT1e") end end function makedice() rnddice=math.random(15)+2 dicestate=1 end --# Main -- Oktum function setup() supportedOrientations(LANDSCAPE_ANY) aktround=1 dicestate=0 rnddice=5 maxplayers=4 temp=0 tx=254 dx=5 gamestate=0 px=-50 ppx=1 aktplayer=0 timer=0 yourtext="" playername={} playerpoints={} playerdp={} playersum={} dl=0 fl=0 dicenr=0 dicesum=0 winner=0 ttx=0 xm=0 for i=1,4 do playerpoints[i]={} playerdp[i]={} playername[i]="" for w=1,10 do playerpoints[i][w]=-1 playerdp[i][w]=-1 playersum[i]=0 end end gamestate=0 displayMode( FULLSCREEN ) hideKeyboard() math.randomseed(10) rnd=math.random(10) tx=250 backingMode(RETAINED) end function draw() timer=timer+DeltaTime if gamestate == 0 then splashscreen() rndt=math.random(10) if CurrentTouch.state==0 then if timer>1 then waittouch(1) else timer=0 showText("pLEASE tOUCH oNE tIME tO iNIT tOUCHSCREEN",500,300,30,255) end end elseif gamestate == 1 then infotmation() waittouch(2) elseif gamestate == 2 then rules1() waittouch(3) elseif gamestate == 3 then rules2() waittouch(4) elseif gamestate >= 4 and gamestate<8 then if dl==0 then if aktplayer<4 then aktplayer=aktplayer+1 end showKeyboard() end if isKeyboardShowing()==false then showKeyboard() end dl=1 splayer(aktplayer) if playername[aktplayer]~= "" then sound(DATA, "ZgBADgA/WBQHPVpM4bWfPQI9Pj/cb8++XwAeWg1APxpOGg0A") timer=0 dl=0 gamestate = gamestate+1 clearcountd() end if playername[aktplayer]== "eND1" then playername[aktplayer]= "" timer=0 dl=0 clearcountd() gamestate=8 end elseif gamestate == 8 then -- This sets a dark background color if dl==0 then hideKeyboard() dl=1 ppx=4 aktplayer=0 end showplay() waittouch(9) elseif gamestate ==9 then -- background(40, 40, 50) if dl<20 then if dl==0 then background(50, 50, 50) end drawboard(dl) dl=dl+1 elseif dl==20 then aktplayer=aktplayer+1 if aktplayer==maxplayers+1 then aktplayer=1 aktround=aktround+1 if aktround>10 then sound(DATA, "ZgJA6ABoQGk1VTdMMQkmv0aHmj7ct2w/VQAWWk1AH3QzamZD") gamestate=11 dl=0 timer=0 background(0, 0, 0, 255) end end if gamestate~=11 then showplayer(px) dl=21 gamestate=10 px=50 ppx=3 tx=200 dx=5 end end elseif gamestate ==10 then px=px+ppx if px>100 or px<40 then ppx=-ppx end tx=tx+dx if tx > 254 or tx<50 then dx=-dx end --background(40, 40, 50) fill(50) stroke(50) rect(25,400,450,340) rect(25,25,450,250) showplayer(px) if playername[aktplayer]~="cOMP" then showText("(tOUCH hERE tO rOLE)",250,430,35,tx ) if dicesum>0 then showText("(oR hERE fOR iKDIM)",250,75,35,255-tx ) end end dl=dl+1 -- if dl>3 then dl=0 end if playerdp[aktplayer][aktround]==-1 then playerdp[aktplayer][aktround]=0 end if timer>0.5 then if playername[aktplayer]=="cOMP" then rnd=math.random(10)+4 if winner~=aktplayer and winner~=0 then rnd=rnd+6 if aktround==9 then rnd=playerpoints[winner][9]+1 end if aktround==10 then rnd=playerpoints[winner][10] end end if playerdp[aktplayer][aktround] HEIGHT-350 then playsound(2) timer=0 dl=0 makedice() end if CurrentTouch.x <500 and CurrentTouch.y < HEIGHT-500 then if dicesum>0 then sound(DATA, "ZgFAQAAbPwxEQUweRJPnPrBRGj/AZWo/XwBaTUZCZQcZZT1e") timer=0 dl=0 -- nextplayer() dicestate=2 else sound(DATA, "ZgBAJQBAQCowaAswWeu9vVtYtD6E418/YQB9fjlUPzgrMw83") end end end end elseif gamestate == 11 then -- This sets a dark background color if dl==0 then background(50, 50, 50, 255) dl=1 ppx=4 aktplayer=0 end dl = dl + 1 background(50, 50, 50) showwinner() if CurrentTouch.state == BEGAN and timer>1 then if CurrentTouch.x < WIDTH/2 then sound(DATA, "ZgBAMQBCVk8MITluqBtxPjKqED9MTRs/cwAufEdADyEqRlUd") timer=0 dl=0 clearall(1) gamestate = 3 clearcountd() else sound(DATA, "ZgBAMQBCVk8MITluqBtxPjKqED9MTRs/cwAufEdADyEqRlUd") timer=0 dl=0 clearall(0) gamestate = 8 clearcountd() end end end -- Do your drawing here if dicestate==1 then dl = dl + 1 if dl>rnddice then dicestate=0 dice() end drawdice() end if dicestate==2 then fl = fl + 1 if fl> playerdp[aktplayer][aktround] then fl=0 dicestate=0 nextplayer() else drawppoints(fl) end end end function clearall(val) aktplayer=0 aktround=1 for i=1,4 do playersum[i]=0 if val==1 then playername[i]="" end for n=1,10 do playerpoints[i][n]=-1 playerdp[i][n]=-1 end end end function waittouch(val) if CurrentTouch.state == BEGAN and timer>1 then playsound(1) timer=0 gamestate = val clearcountd() dl=0 tx=240 ppx=1 px=50 end end