Advertisement
Good_Pudge

Game on OC [MC]

Jul 6th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.82 KB | None | 0 0
  1. --Подключение нужных модулей--
  2. local com = require("component")
  3. local gpu = com.gpu
  4. local term = require("term")
  5. local event = require("event")
  6. local colors = require("colors")
  7. local kb = require("keyboard")
  8.  
  9. --Главные граф. настройки и сохранение старых--
  10. OldB = gpu.getBackground()
  11. OldF = gpu.getForeground()
  12. OldW,OldH = gpu.getResolution()
  13. gpu.maxResolution()
  14. NewW,NewH = gpu.getResolution()
  15. gpu.setBackground(colors.green,true)
  16. gpu.setForeground(colors.black,true)
  17. term.clear()
  18.  
  19.  
  20. --ГРАФИКА КНОПОК--
  21.  
  22. --Заголовок--
  23. gpu.setBackground(colors.orange,true)
  24. term.setCursor(NewW/2-5,2)
  25. gpu.setForeground(colors.magenta,true)
  26. term.write("Jakes Bong")
  27.  
  28. --Продолжить--
  29. gpu.setBackground(colors.silver,true)
  30. term.setCursor(NewW/2-5,4)
  31. gpu.setForeground(0x942f57)
  32. term.write("Продолжить")
  33.  
  34. --Начать новую игру--
  35. gpu.setBackground(colors.silver,true)
  36. term.setCursor(NewW/2-8.5,6)
  37. gpu.setForeground(0x942f57)
  38. term.write("Начать новую игру")
  39.  
  40. --Настройки--
  41. gpu.setBackground(colors.silver,true)
  42. term.setCursor(NewW/2-4.5,8)
  43. gpu.setForeground(0x942f57)
  44. term.write("Настройки")
  45.  
  46. --Авторы--
  47. gpu.setBackground(colors.silver,true)
  48. term.setCursor(NewW/2-3,10)
  49. gpu.setForeground(0x942f57)
  50. term.write("Автор")
  51.  
  52. --Выход--
  53. gpu.setBackground(colors.silver,true)
  54. term.setCursor(NewW/2-2.5,12)
  55. gpu.setForeground(0x942f57)
  56. term.write("Выход")
  57.  
  58.  
  59.  
  60.  
  61. --Захват касаний в меню--
  62. Touch,ScreenA,ScreenX,ScreenY,T,nick = event.pull("touch")
  63. term.setCursor(1,14)
  64. print(ScreenX,ScreenY)
  65.  
  66. --ФУНКЦИОНАЛЬНОСТЬ КНОПОК--
  67.  
  68. --Кнопка "Начать новую игру"--
  69. if ScreenY==6 then
  70.     if ScreenX>=31 and ScreenX<=47 then
  71.         gpu.setBackground(colors.brown,true)
  72.         gpu.setForeground(colors.silver,true)
  73.         term.clear()
  74.     end
  75. end
  76.  
  77. --Кнопка "Настройки"--
  78. if ScreenY==8 then
  79.     if ScreenX>=35 and ScreenX<=43 then
  80.         gpu.setBackground(colors.green,true)
  81.         SSRX,SSRY = gpu.getResolution()
  82.        
  83.         if SSRX==80 and SSRY==25 then
  84.             SSIIX=60
  85.             SSIIY=25
  86.         end
  87.    
  88.        
  89.         gpu.setBackground(colors.gray,true)
  90.         gpu.fill(10,6,SSIIX,SSIIY," ")
  91.         gpu.setBackground(colors.orange,true)
  92.         gpu.setForeground(colors.magenta,true)
  93.         gpu.fill(10,4,60,3," ")
  94.  
  95.        
  96.         --САМИ НАСТРОЙКИ--
  97.        
  98.         --Управление--
  99.         --Заголовок--
  100.         term.setCursor(17,4)
  101.         term.write("Управление")
  102.        
  103.         --Графика--
  104.         --Заголовок--
  105.         term.setCursor(32,4)
  106.         term.write("Графика")
  107.     end
  108. end
  109.  
  110. --Стартовые координаты квадрата--
  111. SX=10
  112. SY=10
  113.  
  114. --Главный цикл--
  115. while true do
  116.  
  117.   OSX=SX
  118.   OSY=SY
  119.  
  120.   gpu.setBackground(colors.brown,true)
  121.  
  122.   Key,W,E,R,T,Y = event.pull("key_down")
  123.  
  124.   if Key and kb.isKeyDown(kb.keys.w) then
  125.     SY=SY-1
  126.   end
  127.  
  128.   if Key and kb.isKeyDown(kb.keys.s) then
  129.     SY=SY+1
  130.   end
  131.  
  132.   if Key and kb.isKeyDown(kb.keys.a) then
  133.     SX=SX-2
  134.   end
  135.  
  136.   if Key and kb.isKeyDown(kb.keys.d) then
  137.     SX=SX+2
  138.   end
  139.  
  140.   if Key and kb.isKeyDown(kb.keys.q) then
  141.     --Менюшка в прямо в игре--
  142.     gpu.setBackground(colors.gray,true)
  143.     gpu.setForeground(colors.magenta,true)
  144.     gpu.fill(30,4,10,10," ")
  145.     term.setCursor(4,10)
  146.     term.write("Продолжить")
  147.     --Не закончено--
  148.     break
  149.   end
  150.  
  151.   if Key and kb.isKeyDown(kb.keys.e) then
  152.     term.clear()
  153.   end
  154.  
  155.  
  156.   gpu.setBackground(colors.brown,true)
  157.   gpu.fill(OSX,OSY,2,1," ")
  158.  
  159.   gpu.setBackground(colors.orange,true)
  160.   gpu.fill(SX,SY,2,1," ")
  161. end
  162.  
  163. --Возвращение предыдущих настроек--
  164. gpu.setBackground(OldB)
  165. gpu.setForeground(OldF)
  166. gpu.setResolution(OldW,OldH)
  167. term.clear()
  168. os.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement