View difference between Paste ID: 08pnYurc and XVXLWZc4
SHOW: | | - or go back to the newest paste.
1
local Cursor = require 'cursor'
2
3
local CELL_SIZE = 24
4
5
Editor = {
6
  x = 10,
7
  y = 10,
8
  interpreter = nil,
9
  cursor = nil
10
}
11
Editor.__index = Editor;
12
13
function Editor.new(interpreter)
14
  local editor = {}
15
  setmetatable(editor, Editor)
16
  editor.interpreter = interpreter
17
  editor.cursor = Cursor.new(0, 0, DIR_RIGHT)
18
  return editor
19
end
20
21
function Editor:drawGrid(w, h)
22
  -- Vertical lines
23
  for i = 0, w do
24
    local _x = self.x + i * CELL_SIZE
25
    local _h = h * CELL_SIZE
26
    love.graphics.line(_x, self.y, _x, self.y + _h)
27
  end
28
  -- Horizontal lines
29
  for i = 0, h do
30
    local _y = self.y + i * CELL_SIZE
31
    local _w = w * CELL_SIZE
32
    love.graphics.line(self.x, _y, self.x + _w, _y)
33
  end
34
end
35
36
function Editor:drawValues(w, h)
37
  for x = 0, w - 1 do
38
    for y = 0, h - 1 do
39
      local _x = self.x + x * CELL_SIZE
40
      local _y = self.y + y * CELL_SIZE
41
      love.graphics.print(self.interpreter.grid.cell[x][y], _x, _y) -- ERROR THIS!
42
    end
43
  end
44
end
45
46
function Editor:draw()
47
  local w = self.interpreter.grid.width
48
  local h = self.interpreter.grid.height
49
  
50-
  self:drawGrid(w, h)
50+
  Editor:drawGrid(w, h)
51-
  self:drawValues(w, h)
51+
  Editor:drawValues(w, h)
52
end
53
54
return Editor