Advertisement
Laine_prikol

2klavishy game

Feb 6th, 2017
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Игра "2 клавиши" by Laine_prikol
  2. local keyboard = require("keyboard")
  3. local os = require("os")
  4. local term = require("term")
  5. input = io.read
  6. scores = 0
  7. way = math.random(1, 2)
  8. term.clear()
  9. print("********2 клавиши игра*********")
  10. print("*   вы хотите начать играть?  *")
  11. print("*          y/n?               *")
  12. print("*******************************")
  13. input = io.read()
  14. if input == "y" then
  15. print("Цель: Нажимайте [Ctrl] или [Shift] и в зависимости от что вы нажмёте вы либо пройдёте дальше, либо проиграете!")
  16. -- Проверка shift
  17. while true do
  18. os.sleep(0.1)
  19. if keyboard.isShiftDown() == true then
  20.   os.sleep(0.1)
  21.     if way == 1 then
  22.     scores = scores + 1
  23.     term.clear()
  24.     print("Правильно, Очков: "..scores)
  25.     way = math.random(1, 2)
  26.     end
  27.       if way == 2 then
  28.       print("Вы проиграли! Ваш счёт: "..scores)
  29.       os.exit()
  30.       end
  31.     end
  32. os.sleep(0.1)
  33. -- Проверка ctrl
  34. os.sleep(0.1)
  35. if keyboard.isControlDown() == true then
  36.   os.sleep(0.1)
  37.     if way == 2 then
  38.     scores = scores + 1
  39.     term.clear()
  40.     print("Правильно, Очков: "..scores)
  41.     way = math.random(1, 2)
  42.     end
  43.       if way == 1 then
  44.       print("Вы проиграли! Ваш счёт: "..scores)
  45.       os.exit()
  46.       end
  47.     end
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement