Advertisement
TIMAS_Bro

drivegame

Oct 17th, 2023 (edited)
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local file = fs.open("lgame/lgame","r")
  2. if file then
  3.     file.close()
  4. os.loadAPI('/lg/lg')
  5. lg.setup('term')
  6. os.loadAPI("uap")
  7. local lgamec = require("../lgame/lgame")
  8. lgamec.setup("term")
  9. lg.fillScreen(colors.black)
  10. local im1 = fs.open("/drivegame/car.nfp","r")
  11. if im1 then
  12.   im1.close()
  13. else
  14.   lg.drawText(1,6,colors.white,colors.black,"Downloading sprites...")
  15.   shell.run("pastebin","get","EnnsawZd","/drivegame/archive")
  16.   lg.drawText(1,6,colors.white,colors.black,"Downloading sprites... DONE")
  17.   lg.drawText(1,7,colors.white,colors.black,"Unpacking...")
  18.   local arch = fs.open("archive/archive","r")
  19.   if not arch then
  20.      lg.drawText(1,7,colors.red,colors.black,"DOWNLOAD ARCHIVE FROM UPDATER!")
  21.      os.sleep(4)
  22.      os.reboot()
  23.   end
  24.   shell.run("archive/archive unpack","/drivegame/archive","/drivegame/")
  25.   lg.drawText(1,7,colors.white,colors.black,"Unpacking... DONE")
  26.   os.sleep(2)
  27.   shell.run("delete","/drivegame/archive")
  28.   os.sleep(1)
  29.   lg.fillScreen(colors.black)
  30.  
  31. end
  32. if lg.getSize().x < 51 then
  33.   lg.drawText(1,7,colors.red,colors.black,"ONLY FOR COMPUTERS!")
  34.   lg.drawText(1,8,colors.red,colors.black,"pastebin run XLpDdvX4")
  35.      os.sleep(4)
  36.      os.reboot()
  37. end
  38. lgamec.fillScreen(colors.black)
  39. lgamec.lggSetDefBG(colors.black)
  40. scene = lgamec.createScene(1,1,lgamec.getSize().x,lgamec.getSize().y,false)
  41. scene:draw()
  42. scene:fillScreen(colors.white)
  43. scene:drawText(2,2,colors.black,colors.white," RACING GAME | TIMUZKAS")
  44. scene:drawBT("start",2,20,5,8,colors.white,colors.black," Start")
  45. while true do
  46.   local event, button, x, y = os.pullEvent( "mouse_click" )
  47.   if scene:isButton(x,y) == "start" then
  48.     scene:hide()
  49.     break
  50.   else
  51.   end
  52. end
  53. game  = lgamec.createScene(1,1,lgamec.getSize().x,lgamec.getSize().y)
  54. game:fillScreen(colors.brown)
  55. game:drawSprite("road",2,1,shell.dir().."/road.nfp")
  56. cary = lgamec.getSize().y-5
  57. game:drawSprite("car",12,cary,shell.dir().."/car.nfp")
  58. lanel = {12,25,38}
  59. lane  = 1
  60. function control()
  61. while true do
  62.   local event, key = os.pullEvent("key")
  63.   if key == keys.d then
  64.     if lane < 3 then
  65.       lane = lane + 1
  66.     end
  67.   elseif key == keys.a then  
  68.     if lane > 1 then
  69.         lane = lane - 1
  70.       end
  71.   end
  72. end
  73. end
  74. function loosef()
  75.     game:hide()
  76.     lgamec.fillScreen(colors.red)
  77.     lgamec.drawText(1,lgamec.getSize().y/2,colors.white,colors.red,"YOU DIED!")
  78.     os.sleep(1)
  79.     lgamec.clearScreen()
  80.     lgamec.setCursorPos(1,1)
  81.     end
  82. function winf()
  83.         game:hide()
  84.         lgamec.fillScreen(colors.green)
  85.         lgamec.drawText(1,lgamec.getSize().y/2,colors.white,colors.red,"YOU WON!")
  86.         os.sleep(1)
  87.         lgamec.clearScreen()
  88.         lgamec.setCursorPos(1,1)
  89. end
  90. lanes2 = {t1 = {16,16,15,15,14,14,13,13,12,12},
  91.     t2 = {26,26,26,26,26,26,26,26,26,26},
  92.     t3 = {34,35,35,36,36,37,37,38,38,39}}
  93. inlane = {16,30,41}
  94. function drawIndicator(linen,line,slt)
  95.     for i=1,5 do
  96.     game:moveSprite("in"..linen,inlane[line],2,false)
  97.     os.sleep(slt)    
  98.     end
  99. end
  100. game:drawSprite("car2",lanes2["t1"][1],5,"car2.nfp")
  101. local ii = 2
  102. sleept = 0.8
  103. score = 0
  104. local l2 = "t1"
  105. loose = false
  106. lvl = 1
  107. function gamef()
  108.   while true do
  109.   ii = ii + 1
  110.   game:moveSprite("car2",lanes2[l2][ii],2+ii,true)
  111.   game:moveSprite("car",lanel[lane],cary,true)
  112.   lgamec.fillScreen(colors.brown)
  113.   game:moveSprite("road",2,1)
  114.   game:moveSprite("car2",lanes2[l2][ii],2+ii)
  115.   game:moveSprite("car",lanel[lane],cary)
  116.   game:drawText(1,lgamec.getSize().y,colors.black,colors.white,"SCORE: "..score.." | LVL: "..lvl.." | "..sleept)
  117.   os.sleep(sleept)
  118.   if (ii == 9) then
  119.     if game:isColiding("car","car2") then
  120.         loose = true
  121.         break
  122.     else
  123.       ii = 2
  124.       nl2 = math.random(1,3)
  125.       l2 = "t"..tostring(nl2)
  126.       if (sleept < 0.2) then
  127.          sleept = 0  
  128.       else
  129.       sleept = sleept - 0.2
  130.       end
  131.       score = score + 1
  132.       if (sleept == 0 ) then
  133.         break  
  134.       end
  135.     end
  136.   end
  137.   end
  138. end
  139. parallel.waitForAny(gamef,control)
  140. game:drawSprite("car3",lanes2["t3"][1],5,"drivegame/car2.nfp")
  141. function gamef2()
  142.     local ii = 2
  143.     sleept = 0.8
  144.     local l2 = "t1"
  145.     local l22 = "t3"
  146.     loose = false
  147.     while true do
  148.     ii = ii + 1
  149.     game:moveSprite("car2",lanes2[l2][ii],2+ii,true)
  150.     game:moveSprite("car3",lanes2[l22][ii],2+ii,true)
  151.     game:moveSprite("car",lanel[lane],cary,true)
  152.     lgamec.fillScreen(colors.brown)
  153.     game:moveSprite("road",2,1)
  154.     game:moveSprite("car2",lanes2[l2][ii],2+ii)
  155.     game:moveSprite("car2",lanes2[l22][ii],2+ii)
  156.     game:moveSprite("car",lanel[lane],cary)
  157.     game:drawText(1,lgamec.getSize().y,colors.black,colors.white,"SCORE: "..score.." | LVL: "..lvl)
  158.     os.sleep(sleept)
  159.     if (ii == 9) then
  160.       if game:isColiding("car","car2") or game:isColiding("car","car3") then
  161.           loose = true
  162.           break
  163.       else
  164.         ii = 2
  165.         nl2 = math.random(1,3)
  166.         l2 = "t"..tostring(nl2)
  167.         repeat
  168.             nl22 = math.random(1,3)
  169.             l22 = "t"..tostring(nl22)
  170.         until l22 ~= l2
  171.         if (sleept < 0.21) then
  172.             sleept = 0  
  173.         else
  174.           sleept = sleept - 0.2
  175.         end
  176.         score = score + 1
  177.         if (sleept == 0 ) then
  178.           break  
  179.         end
  180.       end
  181.     end
  182.     end
  183.   end
  184. if loose then
  185.     loosef()
  186. else
  187.     lvl = 2
  188.     parallel.waitForAny(gamef2,control)
  189.     if (loose) then
  190.         loosef()
  191.     else
  192.         winf()
  193.     end
  194. end
  195. lgamec.exit()
  196. else
  197.     term.clear()
  198.     term.setCursorPos(1,2)
  199.     term.write("Install lgame from updater!")
  200.     uap.upd()
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement