generated from sage/tiny-ecs-love-template
28 lines
671 B
Lua
28 lines
671 B
Lua
local world = require("world")
|
|
local width, height = love.graphics.getWidth(), love.graphics.getHeight()
|
|
|
|
local dice = {
|
|
DiceOne,
|
|
DiceTwo,
|
|
DiceThree,
|
|
DiceFour,
|
|
DiceFive,
|
|
DiceSix,
|
|
}
|
|
|
|
world:filteredSystem("dice", { triggerDiceRoll = T.marker }, function(e, dt, system)
|
|
system.world:removeEntity(e)
|
|
local frames = {}
|
|
for _ = 1, 20 do
|
|
frames[#frames + 1] = dice[math.random(#dice)]
|
|
end
|
|
system.world:addEntity({
|
|
position = {
|
|
x = 20,
|
|
y = height - DiceOne:getHeight() - 20,
|
|
},
|
|
drawAsSprite = dice[math.random(#dice)],
|
|
animation = BuildAnimation(frames, 100)
|
|
})
|
|
end)
|