examples/test: add basic asset tests

This commit is contained in:
Kazhnuz 2019-03-18 17:17:15 +01:00
parent fa7b265618
commit ae75fc46a0
6 changed files with 43 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

View 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,
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

View file

@ -0,0 +1,6 @@
return {
metadata = {
height = 16,
width = 16
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -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