examples/test: add basic asset tests
This commit is contained in:
parent
fa7b265618
commit
ae75fc46a0
6 changed files with 43 additions and 0 deletions
BIN
examples/test_scene2/assets/debris.png
Normal file
BIN
examples/test_scene2/assets/debris.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 B |
16
examples/test_scene2/assets/poof.lua
Normal file
16
examples/test_scene2/assets/poof.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
metadata = {
|
||||
height = 16,
|
||||
width = 16,
|
||||
defaultAnim = "anim"
|
||||
},
|
||||
animations = {
|
||||
["anim"] = {
|
||||
startAt = 1,
|
||||
endAt = 5,
|
||||
loop = 1,
|
||||
speed = 10,
|
||||
pauseAtEnd = false,
|
||||
}
|
||||
}
|
||||
}
|
BIN
examples/test_scene2/assets/poof.png
Normal file
BIN
examples/test_scene2/assets/poof.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 580 B |
6
examples/test_scene2/assets/weapon.lua
Normal file
6
examples/test_scene2/assets/weapon.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
metadata = {
|
||||
height = 16,
|
||||
width = 16
|
||||
}
|
||||
}
|
BIN
examples/test_scene2/assets/weapon.png
Normal file
BIN
examples/test_scene2/assets/weapon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -24,14 +24,25 @@
|
|||
local Scene = require "gamecore.modules.scenes"
|
||||
local TestScene = Scene:extend()
|
||||
|
||||
local folder = "examples/test_scene2/"
|
||||
|
||||
function TestScene:new()
|
||||
TestScene.super.new(self)
|
||||
|
||||
self.assets:addImage("debris", folder .. "assets/debris.png")
|
||||
self.assets:addSprite("poof", folder .. "assets/poof")
|
||||
self.assets:addTileset("weapon", folder .. "assets/weapon")
|
||||
|
||||
self.i = 0
|
||||
self.estImpair = false
|
||||
end
|
||||
|
||||
function TestScene:update(dt)
|
||||
self.i = self.i + dt
|
||||
|
||||
local i = math.floor(self.i)
|
||||
|
||||
self.estImpair = (math.floor(i / 2) ~= (i / 2))
|
||||
end
|
||||
|
||||
function TestScene:mousepressed(x, y)
|
||||
|
@ -45,6 +56,16 @@ function TestScene:draw()
|
|||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.print(math.floor(self.i) .. " ; " .. self.mouse.x .. ":" .. self.mouse.y, 16, 16)
|
||||
|
||||
if self.estImpair then
|
||||
self.assets.images["debris"]:draw(16, 32)
|
||||
self.assets.tileset["weapon"]:drawTile(1, 32, 32)
|
||||
self.assets.sprites["poof"]:drawAnimation(64, 32)
|
||||
else
|
||||
love.graphics.setColor(0, 1, 0, 1)
|
||||
self.assets.images["debris"]:drawMask(16, 32)
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
end
|
||||
|
||||
return TestScene
|
||||
|
|
Loading…
Reference in a new issue