Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------FUNKTIONEN-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- StoneI=function(x,y,spin,s)
- if s==true then c="lightBlue" else c="black" end
- if spin==1 or spin==3 then
- paintutils.drawBox(x,y-1,x,y+2,colors[c])
- end
- if spin==2 or spin==4 then
- paintutils.drawBox(x-2,y,x+1,y,colors[c])
- end
- end
- StoneO=function(x,y,spin,s)
- if s==true then c="yellow" else c="black" end
- paintutils.drawBox(x,y,x+1,y+1,colors[c])
- end
- StoneT=function(x,y,spin,s)
- if s==true then c="purple" else c="black" end
- if spin==1 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x-1,y,colors[c])
- end
- if spin==2 then
- paintutils.drawBox(x-1,y,x+1,y,colors[c])
- paintutils.drawPixel(x,y-1,colors[c])
- end
- if spin==3 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x+1,y,colors[c])
- end
- if spin==4 then
- paintutils.drawBox(x-1,y,x+1,y,colors[c])
- paintutils.drawPixel(x,y+1,colors[c])
- end
- end
- StoneL=function(x,y,spin,s)
- if s==true then c="orange" else c="black" end
- if spin==1 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x+1,y+1,colors[c])
- end
- if spin==2 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x-1,y-1,colors[c])
- end
- if spin==3 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x-1,y-1,colors[c])
- end
- if spin==4 then
- paintutils.drawBox(x-1,y,x+1,y,colors[c])
- paintutils.drawPixel(x+1,y-1,colors[c])
- end
- end
- StoneJ=function(x,y,spin,s)
- if s==true then c="blue" else c="black" end
- if spin==1 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x-1,y+1,colors[c])
- end
- if spin==2 then
- paintutils.drawBox(x-1,y,x+1,y,colors[c])
- paintutils.drawPixel(x-1,y-1,colors[c])
- end
- if spin==3 then
- paintutils.drawBox(x,y-1,x,y+1,colors[c])
- paintutils.drawPixel(x+1,y-1,colors[c])
- end
- if spin==4 then
- paintutils.drawBox(x-1,y,x+1,y,colors[c])
- paintutils.drawPixel(x+1,y+1,colors[c])
- end
- end
- StoneZ=function(x,y,spin,s)
- if s==true then c="red" else c="black" end
- if spin==1 or spin==3 then
- paintutils.drawBox(x-1,y,x,y,colors[c])
- paintutils.drawBox(x,y+1,x+1,y+1,colors[c])
- end
- if spin==2 or spin==4 then
- paintutils.drawBox(x,y-1,x,y,colors[c])
- paitnutils.drawBox(x-1,y,x-1,y+1,colors[c])
- end
- end
- StoneS=function(x,y,spin,s)
- if s==true then c="lime" else c="black" end
- if spin==1 or spin==3 then
- paintutils.drawBox(x,y,x+1,y,colors[c])
- paintutils.drawBox(x-1,y+1,x,y+1,colors[c])
- end
- if spin==2 or spin==4 then
- paintutils.drawBox(x,y-1,x,y,colors[c])
- paintutils.drawBox(x+1,y,x+1,y+1,colors[c])
- end
- end
- SpawnNewBlock=function()
- x=math.random(1,7)
- spin=math.random(1,4)
- if x==1 then StoneI(43,5,spin,true) predictedBlock=StoneI end
- if x==2 then StoneO(43,5,spin,true) predictedBlock=StoneO end
- if x==3 then StoneT(43,5,spin,true) predictedBlock=StoneT end
- if x==4 then StoneL(43,5,spin,true) predictedBlock=StoneL end
- if x==5 then StoneJ(43,5,spin,true) predictedBlock=StoneJ end
- if x==6 then StoneZ(43,5,spin,true) predictedBlock=StoneZ end
- if x==7 then StoneS(43,5,spin,true) predictedBlock=StoneS end
- sleep(Diff)
- end
- waitForInput=function()
- e,a=os.pullEvent("key")
- if e=="key" and a==16 then error() end --Q
- if e=="key" and a==19 then error() end --R
- if e=="key" and a==42 then end --SHIFT
- if e=="key" and a==58 then end --CAPSLOCK
- if e=="key" and a==31 then if not(spin==4) then spin=spin+1 else spin=1 end end --Spin
- if e=="key" and a==203 then x=x-1 end --LINKS
- if e=="key" and a==205 then x=x+1 end --RECHTS
- if e=="key" and a==2 then Diff=1.5 DiffCol="green" end --Diff1
- if e=="key" and a==3 then Diff=1 DiffCol="orange" end --Diff2
- if e=="key" and a==4 then Diff=0.8 DiffCol="red" end
- end
- waitForNoInput=function()
- while true do
- sleep(diff)
- y=y+1
- end
- ---------------------------------------------------------FUNKTIONEN-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- ----------------------------------------------------------VARIABLE------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- DiffCol="orange"
- Diff=1
- FixedBlocks={} O={} I={} L={} J={} T={} Z={} S={}
- -----------------------------------------------------------DESIGN-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- paintutils.drawFilledBox(10,1,30,19,colors.black)
- paintutils.drawBox(10,1,30,19,colors.gray)
- paintutils.drawBox(11,1,29,19,colors.gray)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(33,15)
- write("Move: ARROWS")
- term.setCursorPos(33,17)
- write("Hold: CAPS LOCK")
- term.setCursorPos(33,18)
- write("Release: SHIFT")
- term.setCursorPos(33,16)
- write("Spin: S")
- term.setTextColor(colors.blue)
- term.setCursorPos(32,1)
- write("Tetris by Maxintosh")
- term.setTextColor(colors.black)
- term.setCursorPos(34,3)
- write("next: ")
- paintutils.drawFilledBox(40,3,46,8,colors.black)
- term.setCursorPos(33,11)
- term.setTextColor(colors[DiffCol])
- term.setBackgroundColor(colors.lightGray)
- write("Difficulty:")
- paintutils.drawBox(46,11,47,11,colors.green)
- paintutils.drawBox(48,11,49,11,colors.orange)
- paintutils.drawBox(50,11,51,11,colors.red)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(3,4)
- write("hold")
- paintutils.drawFilledBox(2,6,7,11,colors.black)
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(2,16)
- write("Quit:Q")
- term.setCursorPos(2,18)
- write("Redo:R")
- SpawnNewBlock()
- -----------------------------------------------------------DESIGN-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- while true do
- predictedBlock(19,2,spin,true)
- x=19
- y=2
- xOld=x
- yOld=y
- spinOld=spin
- ----------------------------------------------------------BLOCK FÄLLT---------------------------------------------------------------------
- while y<17 do
- term.setCursorPos(33,11)
- term.setTextColor(colors[DiffCol])
- term.setBackgroundColor(colors.lightGray)
- write("Difficulty:")
- predictedBlock(xOld,yOld,spinOld,false)
- xOld=x
- yOld=y
- spinOld=spin
- predictedBlock(x,y,spin,true)
- parallel.waitForAny(waitForInput,waitForNoInput)
- end
- paintutils.drawFilledBox(40,3,46,8,colors.black)
- SpawnNewBlock()
- end
Add Comment
Please, Sign In to add comment