Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Code By SkullBlade(Skullblade213)
- --You are allowed to modify and redistribute
- --You are not allowed to modify this header
- function Draw()
- term.setBackgroundColor(counter)
- term.clear()
- term.setBackgroundColor(colors.white)
- term.setCursorPos(Ball[1], Ball[2])
- print(" ")
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(You[1], You[2])
- print(" ")
- term.setCursorPos(You[1], You[3])
- print(" ")
- term.setCursorPos(You[1], You[4])
- print(" ")
- term.setBackgroundColor(colors.red)
- term.setCursorPos(Op[1], Op[2])
- print(" ")
- term.setCursorPos(Op[1], Op[3])
- print(" ")
- term.setCursorPos(Op[1], Op[4])
- print(" ")
- end
- function Update()
- Ball={Ball[1]+Ball[3],Ball[2]+Ball[4],Ball[3],Ball[4]}
- if Ball[1]==3 or Ball[1]==49 then
- if Ball[1]==3 then
- Check="L"
- end
- if Ball[1]==49 then
- Check="R"
- end
- if (Ball[2]==You[2] and Check=="L") or (Ball[2]==Op[2] and Check=="R") then
- Ball[3]=Ball[3]*-1
- Ball[4]=-1
- rans=math.random(1,5)
- end
- if (Ball[2]==You[3] and Check=="L") or (Ball[2]==Op[3] and Check=="R") then
- Ball[3]=Ball[3]*-1
- Ball[4]=Ball[4]*-1
- end
- if (Ball[2]==You[4] and Check=="L") or (Ball[2]==Op[4] and Check=="R") then
- Ball[3]=Ball[3]*-1
- Ball[4]=1
- end
- end
- if Ball[2]==1 or Ball[2]==18 or Ball[2]==0 or Ball[2]==19 then
- Ball[4]=Ball[4]*-1
- end
- if Ball[1]==1 then
- score2=score2+1
- Start()
- end
- if Ball[1]==51 then
- score=score+1
- Start()
- end
- end
- function Move()
- if key==200 then
- You[2]=You[2]-1
- end
- if key==208 then
- You[2]=You[2]+1
- end
- end
- function AI()
- if Ball[2]+Ball[4]>Op[2]+2 then
- if Op[2]+3~=19 then
- Op={Op[1],Op[2]+1,Op[2]+2,Op[2]+3}
- end
- end
- if Ball[2]+Ball[4]<Op[2] then
- if Op[2]-1~=0 then
- Op={Op[1],Op[2]-1,Op[2],Op[2]+1}
- end
- end
- end
- function Start()
- You={2,9,10,11}
- Op={50,9,10,11}
- ran=math.random(-1,1)
- ran2=math.random(-1,1)
- while ran==0 do
- ran=math.random(-1,1)
- end
- while ran2==0 do
- ran2=math.random(-1,1)
- end
- Ball={25,10,ran,ran2}
- term.setCursorPos(20,10)
- print(score.." VS "..score2)
- if vars=="surv" and score2==1 then
- ends="true"
- end
- sleep(1)
- end
- function Single(v)
- vars=v
- ends="false"
- score=0
- score2=0
- if resume~="true" then
- Start()
- end
- counter=1
- breaks="false"
- while true do
- if vars=="surv" then
- counter=counter*2
- if counter==32 or counter==16384 then
- counter=counter*2
- end
- if counter==32768 then
- counter=2
- end
- term.setBackgroundColor(counter)
- end
- if vars~="surv" then
- counter=32768
- end
- Draw()
- os.startTimer(.1)
- while true do
- event, key = os.pullEvent()
- if event=="key" then
- if vars~="Local" then
- Move()
- end
- if key==59 and (vars=="surv" or vars=="norm" or vars=="Local") then
- Menu("Paused","Resume","Info/Help","Quit")
- breaks="true"
- break
- end
- if vars=="Local" then
- if key==17 then
- You[2]=You[2]-1
- end
- if key==31 then
- You[2]=You[2]+1
- end
- if key==200 then
- Op[2]=Op[2]-1
- end
- if key==208 then
- Op[2]=Op[2]+1
- end
- if You[2]==0 then
- You[2]=1
- end
- if You[2]==17 then
- You[2]=16
- end
- if Op[2]==0 then
- Op[2]=1
- end
- if Op[2]==17 then
- Op[2]=16
- end
- You={You[1],You[2],You[2]+1,You[2]+2}
- Op={Op[1],Op[2],Op[2]+1,Op[2]+2}
- end
- if You[2]==0 then
- You[2]=1
- end
- if You[2]==17 then
- You[2]=16
- end
- You={You[1],You[2],You[2]+1,You[2]+2}
- end
- if event=="timer" then
- break
- end
- end
- if breaks=="true" then
- break
- end
- if vars~="Local" then
- AI()
- end
- Update()
- if ends=="true" then
- ends="false"
- Menu("SinglePlayer","Normal","Survival","Back")
- break
- end
- end
- end
- function Set(x1,y1)
- x=x1
- y=y1
- term.setCursorPos(x1,y1)
- end
- function PrintCenter(text)
- textLen=string.len(text)
- x = ((51-textLen)/2)
- term.setCursorPos(x,y)
- print(text)
- y=y+1
- end
- function Menu(title,opt1,opt2,opt3)
- resume="false"
- term.setBackgroundColor(colors.black)
- select=1
- while true do
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.lime)
- print("SkullPong V1.10")
- Set(1,6)
- PrintCenter(title)
- PrintCenter("------------")
- term.setTextColor(colors.white)
- PrintCenter(opt1)
- PrintCenter(opt2)
- PrintCenter(opt3)
- if select==1 then
- Set(1,8)
- term.setTextColor(colors.blue)
- PrintCenter(opt1)
- term.setTextColor(colors.white)
- end
- if select==2 then
- Set(1,9)
- term.setTextColor(colors.blue)
- PrintCenter(opt2)
- term.setTextColor(colors.white)
- end
- if select==3 then
- Set(1,10)
- term.setTextColor(colors.blue)
- PrintCenter(opt3)
- term.setTextColor(colors.white)
- end
- event, param1, param2, param3 = os.pullEvent()
- if event=="mouse_click" then
- if param3==8 or param3==9 or param3==10 then
- sel=select
- if param3==8 then
- text=opt1
- select=1
- end
- if param3==9 then
- text=opt2
- select=2
- end
- if param3==10 then
- text=opt3
- select=3
- end
- strLen=string.len(text)
- start=(51-strLen)/2-1
- if param2>start and param2<start+strLen then
- if select==1 then
- if opt1=="SinglePlayer" then
- Menu("SinglePlayer","Normal","Survival","Back")
- break
- end
- if opt1=="Normal" then
- Single("norm")
- break
- end
- if opt1=="Resume" then
- resume="true"
- Single(vars)
- break
- end
- if opt1=="Local" then
- Single("Local")
- break
- end
- end
- if select==2 then
- if opt1=="SinglePlayer" then
- Menu("MultiPlayer","Local","Rednet","Back")
- break
- end
- if opt1=="Normal" then
- Single("surv")
- break
- end
- if opt1=="Resume" then
- if vars~="Local" then
- term.clear()
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- print("SkullPong V1.10")
- print("Help")
- print("---------------")
- term.setTextColor(colors.white)
- print("")
- print("Controls")
- print("UpArrow: Paddle Up")
- print("DownArrow: Paddle Down")
- print("Objective")
- print("Don't let the ball get pass the green paddle{You}")
- print("Get the ball pass the red paddle{AI}")
- print("")
- print("Press any key to continue")
- os.pullEvent("key")
- end
- if vars=="Local" then
- term.clear()
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- print("SkullPong V1.10")
- print("Help")
- print("---------------")
- term.setTextColor(colors.white)
- print("")
- print("Controls")
- print("UpArrow: Paddle Up-Red")
- print("DownArrow: Paddle Down-Red")
- print("W: Paddle Up-Green")
- print("A: Paddle Down-Green")
- print("Objective")
- print("Don't let the ball get pass the your paddle")
- print("Get the ball pass your opponent's paddle")
- print("")
- print("Press any key to continue")
- os.pullEvent("key")
- end
- end
- if opt1=="Local" then
- error("Not Implimented!")
- end
- end
- if select==3 then
- if opt1=="SinglePlayer" then
- term.clear()
- term.setCursorPos(1,1)
- break
- else
- Menu("Start","SinglePlayer","MultiPlayer","Quit")
- break
- end
- end
- else
- select=sel
- end
- end
- end
- if event=="key" then
- if param1==200 then
- select=select-1
- end
- if param1==208 then
- select=select+1
- end
- if param1==28 then
- if select==1 then
- if opt1=="SinglePlayer" then
- Menu("SinglePlayer","Normal","Survival","Back")
- break
- end
- if opt1=="Normal" then
- Single("norm")
- break
- end
- if opt1=="Resume" then
- resume="true"
- Single(vars)
- break
- end
- if opt1=="Local" then
- Single("Local")
- break
- end
- end
- if select==2 then
- if opt1=="SinglePlayer" then
- Menu("MultiPlayer","Local","Rednet","Back")
- break
- end
- if opt1=="Normal" then
- Single("surv")
- break
- end
- if opt1=="Resume" then
- if vars~="Local" then
- term.clear()
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- print("SkullPong V1.10")
- print("Help")
- print("---------------")
- term.setTextColor(colors.white)
- print("")
- print("Controls")
- print("UpArrow: Paddle Up")
- print("DownArrow: Paddle Down")
- print("Objective")
- print("Don't let the ball get pass the green paddle{You}")
- print("Get the ball pass the red paddle{AI}")
- print("")
- print("Press any key to continue")
- os.pullEvent("key")
- end
- if vars=="Local" then
- term.clear()
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- print("SkullPong V1.10")
- print("Help")
- print("---------------")
- term.setTextColor(colors.white)
- print("")
- print("Controls")
- print("UpArrow: Paddle Up-Red")
- print("DownArrow: Paddle Down-Red")
- print("W: Paddle Up-Green")
- print("A: Paddle Down-Green")
- print("Objective")
- print("Don't let the ball get pass the your paddle")
- print("Get the ball pass your opponent's paddle")
- print("")
- print("Press any key to continue")
- os.pullEvent("key")
- end
- end
- if opt1=="Local" then
- error("Not Implimented!")
- end
- end
- if select==3 then
- if opt1=="SinglePlayer" then
- term.clear()
- term.setCursorPos(1,1)
- break
- else
- Menu("Start","SinglePlayer","MultiPlayer","Quit")
- break
- end
- end
- end
- if select==0 then
- select=3
- end
- if select==4 then
- select=1
- end
- end
- end
- end
- Menu("Start","SinglePlayer","MultiPlayer","Quit")
Advertisement
Add Comment
Please, Sign In to add comment