Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- textutils.slowPrint("CCFS IS LOADING...")
- function Bar(procent,description,barPosX,barPosY,barColor)
- term.setCursorPos(barPosX,barPosY)
- term.setBackgroundColor(colors.gray)
- print(" ",description)
- term.setBackgroundColor(barColor)
- term.setCursorPos(barPosX,barPosY)
- print(string.rep(" ",procent*40))
- end
- Bar(0.2,"Loading...",1,2,colors.red)
- ScrnMX,ScrnMY = term.getSize()
- function CenterPrint(str,printY,slow)
- if printY == nil then
- printY = ScrnMY/2
- end
- term.setCursorPos(ScrnMX/2-(string.len(str)/2),printY)
- if slow == false then
- print(str)
- elseif slow == true then
- textutils.slowPrint(str)
- end
- end
- Bar(0.4,"Loading...",1,2,colors.red)
- CenterPrint("Wellcome to CCFS!",3,true)
- function Clear(clearColor)
- term.setBackgroundColor(clearColor)
- term.clear()
- term.setCursorPos(1,1)
- end
- Bar(0.6,"Loading...",1,2,colors.red)
- function Menu(title,options,bgColor,slow)
- local selOp = 1
- CenterPrint(title,1,slow)
- while true do
- Clear(bgColor)
- CenterPrint(title,1,false)
- for i=1,#options do
- if selOp == i then
- CenterPrint("[ "..options[i].." ]",i+2,false)
- else
- CenterPrint("["..options[i].."]",i+2,false)
- end
- end
- E,K = os.pullEvent("key")
- if K == keys.down then
- if selOp == #options then
- selOp = 1
- else
- selOp = selOp + 1
- end
- elseif K == keys.up then
- if selOp == 1 then
- selOp = #options
- else
- selOp = selOp - 1
- end
- elseif K == keys.enter then
- return selOp
- end
- end
- end
- Bar(0.8,"Loading...",1,2,colors.red)
- function MainMenu()
- Clear(colors.gray)
- local mmsel = Menu("Wellcome to CCFS",{"Fly!","About","Exit"},colors.lightBlue,true)
- if mmsel == 1 then
- Clear(colors.black)
- term.setTextColor(colors.white)
- CenterPrint("CCFS, SETUP",1,true)
- print("Enter MaxFuelConsumption recommended: 10")
- MaxFuelConsumption = tonumber(read())
- print("Enter acceletaion recommended: 5")
- local acceletaion = tonumber(read())
- print("Enter stallSpeed recommended: 5")
- local stallSpeed = tonumber(read())
- print("Enter terminalVelocity recommended: 560")
- local terminalVelocity = tonumber(read())
- Clear(colors.black)
- CenterPrint("MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity",1,false)
- print(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
- for i=1,5 do
- Bar(i/5,"",1,4,colors.white)
- CenterPrint(5-i,3,true)
- end
- Clear(colors.gray)
- Fly(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
- elseif mmsel == 2 then
- Clear(colors.black)
- term.setTextColor(colors.white)
- CenterPrint("CCFS is a flight simulator for computercraft!",1,true)
- CenterPrint("CCFS may not reflect real world situations",2,true)
- CenterPrint("No copyright infringement intended, please dont sue!",4,false)
- end
- end
- Clear(colors.lightBlue)
- Bar(1,"Done!",1,2,colors.red)
- Bar(0.2,"Loading game functions...",1,3,colors.red)
- CenterPrint("Wellcome to CCFS!",4,false)
- function Dashboard(fuelLevel,Altitude,Warnings,Throthel,PosX,PosY,GpsX,GpsY,speed)
- Clear(colors.gray)
- term.setTextColor(colors.red)
- CenterPrint(Warnings,1,false)
- term.setTextColor(colors.white)
- CenterPrint("ALT "..tostring(Altitude),2,false)
- local i,j = term.getSize()
- Bar(fuelLevel,"",(j/2-20),3,colors.orange)
- term.setBackgroundColor(colors.gray)
- CenterPrint("THRTL:"..tostring(Throthel),4,false)
- CenterPrint("YourY "..PosY.." GpsY "..GpsY,6,false)
- CenterPrint("YourX "..PosX.." GpsX "..GpsX,5,false)
- CenterPrint("SPD:"..tostring(speed),7,false)
- end
- Bar(0.4,"Loading game functions...",1,3,colors.red)
- function UpdatePos(speed,PosX,PosY,stearingX,stearingY,Pitch,Altitude,stallSpeed)
- PosX = stearingX*speed
- PosY = stearingY*speed
- if speed > stallSpeed then
- Altitude = Pitch*speed
- else
- Altitude = Altitude - 1
- end
- return PosX,PosY,Altitude
- end
- Bar(0.6,"Loading game functions...",1,3,colors.red)
- function UpdateFuelAndSpeed(fuelLevel,Throthel,MaxFuelConsumption,speed,acceletaion,stallSpeed,terminalVelocity)
- fuelLevel = fuelLevel - (Throthel)*MaxFuelConsumption
- if speed > stallSpeed then
- speed = speed + acceletaion*Throthel
- else
- speed = speed + acceletaion*Throthel + 2
- end
- if speed > terminalVelocity then
- speed = terminalVelocity
- end
- return fuelLevel, speed
- end
- Bar(0.8,"Loading game functions...",1,3,colors.red)
- function Fly(MaxFuelConsumption,acceletaion,stallSpeed,terminalVelocity)
- PosX = 0
- PosY = 0
- GpsX = math.random(1000,2000)
- GpsY = math.random(1000,2000)
- local fuelLevel=1
- Throthel = 0.75
- local speed = 100
- StearingX = 0
- StearingY = 1
- Pitch = 0
- Altitude = 500
- Dashboard(fuelLevel,Altitude,"Press any button to begin flying!",Throthel,PosX,PosY,GpsX,GpsY,speed)
- while true do
- E,K = os.pullEvent("key")
- if K == keys.w then
- Throthel = Throthel + 0.1
- elseif K == keys.s then
- Throthel = Throthel - 0.1
- elseif K == keys.up then
- Pitch = Pitch - 1
- elseif K == keys.down then
- Pitch = Pitch + 1
- elseif K == keys.right then
- StearingX = StearingX - 1
- if StearingX > 0 then
- StearingY = 1-StearingX
- else
- StearingY = 1+StearingX
- end
- elseif K == keys.left then
- StearingX = StearingX + 1
- if StearingX > 0 then
- StearingY = 1-StearingX
- else
- StearingY = 1+StearingX
- end
- elseif K == keys.q then
- break
- end
- if Throthel > 1 then
- Throthel = 1
- elseif Throthel < -1 then
- Throthel = -1
- end
- if speed < stallSpeed then
- Dashboard(fuelLevel,Altitude,"STALLING",Throthel,PosX,PosY,GpsX,GpsY,speed)
- elseif Altitude < 150 then
- Dashboard(fuelLevel,Altitude,"TERRAIN TERRAIN TERRAIN",Throthel,PosX,PosY,GpsX,GpsY,speed)
- else
- Dashboard(fuelLevel,Altitude,"",Throthel,PosX,PosY,GpsX,GpsY,speed)
- end
- fuelLevel,speed = UpdateFuelAndSpeed(fuelLevel,Throthel,MaxFuelConsumption,speed,acceletaion,stallSpeed,terminalVelocity)
- PosX,PosY,Altitude = UpdatePos(speed,PosX,PosY,StearingX,StearingY,Pitch,Altitude,stallSpeed)
- if fuelLevel < 0 then
- break
- end
- end
- Clear(colors.black)
- CenterPrint("Game over!",1,true)
- end
- Bar(1,"Done!",1,3,colors.red)
- MainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement