Darkwater

Untitled

Aug 26th, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. function love.load()
  2.     map = {} -- 64x48
  3.     for x=0, 63 do
  4.         map[x] = {}
  5.         for y=0, 47 do
  6.             map[x][y] = 0
  7.         end
  8.     end
  9.  
  10.     convert = 0
  11.  
  12.     love.graphics.setMode(1024, 768, false)
  13. end
  14.  
  15. function love.update()
  16.     if love.mouse.isDown("l") then
  17.         x = love.mouse.getX()
  18.         y = love.mouse.getY()
  19.         map[math.floor(x/16)][math.floor(y/16)] = convert
  20.     end
  21. end
  22.  
  23. function love.keypressed(key)
  24.     if key == "1" then convert = 0 end
  25.     if key == "2" then convert = 1 end
  26.     if key == "3" then convert = 2 end
  27.     if key == "4" then convert = 3 end
  28.     if key == "return" then
  29.         for x=0, 63 do
  30.             local str = ""
  31.             for y=0, 47 do
  32.                 str = str .. "0"..map[x][y].."0"..map[x][y].." "
  33.             end
  34.             print("fb     "..str)
  35.         end
  36.     end
  37. end
  38.  
  39. function love.draw()
  40.     for x=0, 63 do
  41.         for y=0, 47 do
  42.             if map[x][y] ~= 0 then
  43.                 if map[x][y] == 1 then
  44.                     love.graphics.setColor(255, 0, 0)
  45.                 end
  46.                 if map[x][y] == 2 then
  47.                     love.graphics.setColor(0, 0, 255)
  48.                 end
  49.                 if map[x][y] == 3 then
  50.                     love.graphics.setColor(0, 255, 0)
  51.                 end
  52.                 love.graphics.rectangle("fill", x*16, y*16, 16, 16)
  53.             end
  54.             love.graphics.setColor(127, 127, 127)
  55.             if math.floor(love.mouse.getX()/16) == x and math.floor(love.mouse.getY()/16) == y then
  56.                 if convert == 0 then
  57.                     love.graphics.setColor(0, 0, 0)
  58.                 end
  59.                 if convert == 1 then
  60.                     love.graphics.setColor(255, 0, 0)
  61.                 end
  62.                 if convert == 2 then
  63.                     love.graphics.setColor(0, 0, 255)
  64.                 end
  65.                 if convert == 3 then
  66.                     love.graphics.setColor(0, 255, 0)
  67.                 end
  68.             end
  69.             love.graphics.printf(map[x][y], x*16, y*16, 16, "right")
  70.         end
  71.     end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment