nikolay04

Untitled

Oct 3rd, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local x = 20
  2. local y = 10
  3. local sX, sY = x, y + 0 + 1
  4. local monsterX = math.random(1,20)
  5. local monsterY = math.random(1,10)
  6. local points = 0
  7. local kM = false
  8.  
  9.  
  10. while true do
  11.   term.clear()
  12.   term.setCursorPos(x,y)
  13.   print"@"
  14.   term.setCursorPos(sX,sY)
  15.   print("-|--")
  16.   term.setCursorPos(50,1)
  17.   print(points)
  18.  
  19.  
  20.   if monsterX ~= sX and monsterY ~= sY then
  21.     term.setCursorPos(monsterX, monsterY)
  22.     print"!"
  23.     end
  24.    
  25.   local hendelse, tast = os.pullEvent("key")
  26.  
  27.  
  28.    
  29.    if monsterX == sX and monsterY == sY then
  30.      monsterX = math.random(1,70)
  31.      monsterY = math.random(1,50)
  32.      term.setCursorPos(monsterX, monsterY)
  33.      term.clear()
  34.      points = points + 1
  35.      local kM = true
  36.     end
  37.  
  38.   if tast == keys.q then
  39.     break
  40.   end
  41.  
  42.   if x == monsterX and y == monsterY then
  43.     term.setCursorPos(30,10)
  44.     print"You died"
  45.     sleep(.5)
  46.     break
  47.   end
  48.  
  49.  
  50.   if tast == keys.right then
  51.     x =  x + 1
  52.     sX = sX + 1
  53.   end
  54.  
  55.   if tast == keys.left then
  56.     x = x - 1
  57.     sX = sX - 1
  58.   end
  59.  
  60.   if tast == keys.up then
  61.     y = y - 1
  62.     sY = sY + -1
  63.   end
  64.  
  65.   if tast == keys.down then
  66.     y = y + 1
  67.     sY = sY + 1
  68.   end
  69. end
Add Comment
Please, Sign In to add comment