Advertisement
Agent_Silence

TopLeft to Cartesian

Jun 17th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. local coords = {{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},{math.random(-14,14),math.random(-9,9),2^math.random(1,14)},}
  2. local map = window.create(term.native(),1,1,29,19)
  3. local oldCursorPos = map.setCursorPos
  4. local oldGetCP = map.getCursorPos
  5. local maxX, maxY = map.getSize()
  6. map.getCursorPos = function() local x,y = oldGetCP() return x-(math.ceil(maxX/2)),-(y-(math.ceil(maxY/2))) end
  7. map.setCursorPos = function(x,y) oldCursorPos(x+(math.ceil(maxX/2)),-(y-(math.ceil(maxY/2)))) end
  8. map.setBackgroundColor(colors.white)
  9. map.clear()
  10. map.setTextColor(colors.black)
  11. local stage = 1
  12. while true do
  13. local event, key = os.pullEvent("key")
  14.     if key == keys.right then
  15.         stage = stage - 1
  16.         if stage < 1 then
  17.             stage = 4
  18.         end
  19.     elseif key == keys.left then
  20.         stage = stage + 1
  21.         if stage > 4 then
  22.             stage = 1
  23.         end
  24.     end
  25.     map.setBackgroundColor(colors.white)
  26.     map.clear()
  27.     map.setBackgroundColor(colors.yellow)
  28.     map.setCursorPos(0,0)
  29.     map.write("^")
  30.     for i,v in pairs(coords) do
  31.         map.setBackgroundColor(v[3])
  32.         if stage == 1 then
  33.             map.setCursorPos(v[1],v[2])
  34.             map.write("X")
  35.         elseif stage == 2 then
  36.             map.setCursorPos(v[2],-v[1])
  37.             map.write("X")
  38.         elseif stage == 3 then
  39.             map.setCursorPos(-v[1],-v[2])
  40.             map.write("X")
  41.         elseif stage == 4 then
  42.             map.setCursorPos(-v[2],v[1])
  43.             map.write("X")
  44.         end
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement