Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Cursor = require 'cursor'
- local CELL_SIZE = 24
- Editor = {
- x = 10,
- y = 10,
- interpreter = nil,
- cursor = nil
- }
- Editor.__index = Editor;
- function Editor.new(interpreter)
- local editor = {}
- setmetatable(editor, Editor)
- editor.interpreter = interpreter
- editor.cursor = Cursor.new(0, 0, DIR_RIGHT)
- return editor
- end
- function Editor:drawGrid(w, h)
- -- Vertical lines
- for i = 0, w do
- local _x = self.x + i * CELL_SIZE
- local _h = h * CELL_SIZE
- love.graphics.line(_x, self.y, _x, self.y + _h)
- end
- -- Horizontal lines
- for i = 0, h do
- local _y = self.y + i * CELL_SIZE
- local _w = w * CELL_SIZE
- love.graphics.line(self.x, _y, self.x + _w, _y)
- end
- end
- function Editor:drawValues(w, h)
- for x = 0, w - 1 do
- for y = 0, h - 1 do
- local _x = self.x + x * CELL_SIZE
- local _y = self.y + y * CELL_SIZE
- love.graphics.print(self.interpreter.grid.cell[x][y], _x, _y) -- ERROR THIS!
- end
- end
- end
- function Editor:draw()
- local w = self.interpreter.grid.width
- local h = self.interpreter.grid.height
- Editor:drawGrid(w, h)
- Editor:drawValues(w, h)
- end
- return Editor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement