Experimenting with multi-layer drawing
Getty Ritter
7 years ago
105 | 105 | self.sprite:drawPx(self.x, self.y) |
106 | 106 | end |
107 | 107 | |
108 | function Entity:gameCoords() | |
109 | return math.floor(self.x / consts.tileSize), math.floor(self.y / consts.tileSize) | |
110 | end | |
111 | ||
108 | 112 | return { |
109 | 113 | Entity = Entity |
110 | 114 | } |
27 | 27 | state.board:set(8, 4, tile.getTile('water')) |
28 | 28 | state.board:set(8, 5, tile.getTile('water')) |
29 | 29 | state.board:setEntity(9, 6, tile.getTile('sign')) |
30 | ||
31 | state.board:setEntity(10, 3, tile.getTile('tree_lower')) | |
32 | state.board:setEntity(10, 2, tile.getTile('tree_upper')) | |
30 | 33 | |
31 | 34 | state.canvas = love.graphics.newCanvas( |
32 | 35 | consts.boardWidth * consts.tileSize, |
83 | 86 | for y = 0, consts.boardHeight, 1 do |
84 | 87 | local e = state.board:lookupEntity(x, y) |
85 | 88 | if e then e:draw(x, y, state.t) end |
89 | local sX, sY = state.char:gameCoords() | |
90 | if sX == x and sY == y then | |
91 | state.char:draw() | |
92 | end | |
86 | 93 | end |
87 | 94 | end |
88 | ||
89 | state.char:draw() | |
90 | 95 | |
91 | 96 | if state.message then |
92 | 97 | local w = consts.boardWidth * consts.tileSize |
Binary diff not shown
Binary diff not shown