gdritter repos animaltransiro / 8836666
Basic ambient animation Getty Ritter 6 years ago
7 changed file(s) with 36 addition(s) and 10 deletion(s). Collapse all Expand all
4040 end
4141
4242 function love.update()
43 state.t = state.t + 1
4344 state.char:move()
4445 end
4546
4647 function love.mousepressed(x, y)
47 local gx, gy = fromScreen(x, y)
48 local gx, gy = fromScreen(x / 2, y / 2)
4849 state.board:set(gx, gy, tile.getTile('stonepath'))
4950 end
5051
7475
7576 for x = 0, consts.boardWidth, 1 do
7677 for y = 0, consts.boardHeight, 1 do
77 state.board:lookup(x, y):draw(x, y)
78 state.board:lookup(x, y):draw(x, y, state.t)
7879 end
7980 end
8081
8182 for x = 0, consts.boardWidth, 1 do
8283 for y = 0, consts.boardHeight, 1 do
8384 local e = state.board:lookupEntity(x, y)
84 if e then e:draw(x, y) end
85 if e then e:draw(x, y, state.t) end
8586 end
8687 end
8788
1515 if f then
1616 t = loadstring('return' .. f:read('*all'))()
1717 f:close()
18 t.quad = love.graphics.newQuad(
19 t.spriteX * consts.tileSize,
20 t.spriteY * consts.tileSize,
21 consts.tileSize,
22 consts.tileSize,
23 spritesheet:getDimensions())
18 if t.animation then
19 t.totalFrames = table.getn(t.animation)
20 t.quads = {}
21 for i = 1, t.totalFrames do
22 t.quads[i] = love.graphics.newQuad(
23 t.animation[i][1] * consts.tileSize,
24 t.animation[i][2] * consts.tileSize,
25 consts.tileSize,
26 consts.tileSize,
27 spritesheet:getDimensions())
28 end
29 t.draw = tileAnimation
30 else
31 t.quad = love.graphics.newQuad(
32 t.spriteX * consts.tileSize,
33 t.spriteY * consts.tileSize,
34 consts.tileSize,
35 consts.tileSize,
36 spritesheet:getDimensions())
37 end
2438 else
2539 t = {
2640 name = name,
3549 end
3650
3751 function Tile:action()
52 end
53
54 function tileAnimation(self, x, y, t)
55 local tM = math.floor(t / 40) % self.totalFrames
56
57 love.graphics.draw(
58 spritesheet,
59 self.quads[tM + 1],
60 x * consts.tileSize,
61 y * consts.tileSize)
3862 end
3963
4064 function Tile:draw(x, y)
44 spriteX = 3,
55 spriteY = 0,
66 action = function(self, state) state.message = self.signText end,
7 signText = 'Bonvolu al Animaltransiron!'
7 signText = 'Bonvolu al Animaltransiron!\nKiel vi fartas, mia amiko?'
88 }
Binary diff not shown
Binary diff not shown
33 name = 'water',
44 spriteX = 5,
55 spriteY = 0,
6 animation = { {5, 0}, {6, 0}, {7, 0} },
67 }
tiles/water.png less more
Binary diff not shown