scenes/levels: first batch of transition to integrated asset manager

This commit is contained in:
Kazhnuz 2019-03-03 18:24:31 +01:00
parent 47e699d14a
commit cc24fc300b
23 changed files with 114 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

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

View File

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 733 B

View File

@ -0,0 +1,16 @@
return {
metadata = {
height = 16,
width = 16,
defaultAnim = "anim"
},
animations = {
["anim"] = {
startAt = 1,
endAt = 4,
loop = 1,
speed = 0.2,
pauseAtEnd = false,
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,16 @@
return {
metadata = {
height = 16,
width = 16,
defaultAnim = "anim"
},
animations = {
["anim"] = {
startAt = 1,
endAt = 4,
loop = 1,
speed = 0.2,
pauseAtEnd = false,
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,16 @@
return {
metadata = {
height = 16,
width = 16,
defaultAnim = "anim"
},
animations = {
["anim"] = {
startAt = 1,
endAt = 4,
loop = 1,
speed = 0.2,
pauseAtEnd = false,
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

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

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,16 @@
return {
metadata = {
height = 16,
width = 16,
defaultAnim = "anim"
},
animations = {
["anim"] = {
startAt = 1,
endAt = 5,
loop = 1,
speed = 0.08,
pauseAtEnd = false,
}
}
}

View File

@ -0,0 +1,16 @@
return {
metadata = {
height = 16,
width = 16,
defaultAnim = "anim"
},
animations = {
["anim"] = {
startAt = 1,
endAt = 5,
loop = 1,
speed = 0.08,
pauseAtEnd = false,
}
}
}

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -8,7 +8,7 @@ function Block:new(level, x , y, item)
end
function Block:draw(dt)
assets.sprites["block"]:draw(1, self.x, self.y)
self.level.assets.tileset["block"]:drawTile(1, self.x, self.y)
end
function Block:breakBlock()

View File

@ -4,8 +4,8 @@ local Coin = Loot:extend()
function Coin:new(level, x, y, anim, value)
self.value = value or 1
self.anim = anim or 1
Coin.super.new(self, level, x, y, "coin", self.anim)
local anim = anim or "coin"
Coin.super.new(self, level, x, y, anim)
end
function Coin:takeLoot()

View File

@ -3,7 +3,7 @@ local Coin = require "scenes.levels.entities.loot.coin"
local Coin5 = Coin:extend()
function Coin5:new(level, x, y)
Coin5.super.new(self, level, x, y, 3, 10)
Coin5.super.new(self, level, x, y, "coin10", 10)
end
return Coin5

View File

@ -3,7 +3,7 @@ local Coin = require "scenes.levels.entities.loot.coin"
local Coin5 = Coin:extend()
function Coin5:new(level, x, y)
Coin5.super.new(self, level, x, y, 2, 5)
Coin5.super.new(self, level, x, y, "coin5", 5)
end
return Coin5

View File

@ -2,11 +2,10 @@ local Entity = require "scenes.levels.entities.parent"
local Loot = Entity:extend()
function Loot:new(level, x, y, name, anim)
function Loot:new(level, x, y, name)
Loot.super.new(self, level, "loot", x, y, 16, 16)
self.collType = "loot"
self.sprite = name
self.anim = anim
end
function Loot:takeLoot()
@ -21,8 +20,7 @@ function Loot:update(dt)
end
function Loot:draw()
--local localx, localy = currentLevel.camera:cameraCoords(self.x, self.y)
assets.sprites[self.sprite]:draw(self.anim, self.x, self.y)
self.level.assets.sprites[self.sprite]:drawAnimation(self.x, self.y)
end
return Loot

View File

@ -54,8 +54,8 @@ end
function Weapon:draw(dt)
local rotation = math.floor(self.rotation/45)*45
drawx, drawy = self:getCenter()
assets.sprites["weapon"]:draw(self.weaponid, drawx, drawy, rotation,
self.direction, 1, 8, 8)
self.level.assets.tileset["weapon"]:drawTile(self.weaponid, drawx, drawy,
rotation, self.direction, 1, 8, 8)
end
return Weapon

View File

@ -77,14 +77,11 @@ end
function Level:loadSprites()
assets:clearSprites()
assets:addSprite("coin", 16, 16)
assets.sprites["coin"]:newAnimation('1-4', 1, 0.2)
assets.sprites["coin"]:newAnimation('1-4', 2, 0.2)
assets.sprites["coin"]:newAnimation('1-4', 3, 0.2)
self.assets:addSprite("coin", "assets/sprites/items/coin")
self.assets:addSprite("coin5", "assets/sprites/items/coin5")
self.assets:addSprite("coin10", "assets/sprites/items/coin10")
assets:addSprite("weapon", 16, 16)
assets.sprites["weapon"]:newAnimation(1, 2, 0.1)
assets.sprites["weapon"]:newAnimation(2, 2, 0.1)
self.assets:addTileset("weapon", "assets/sprites/weapon")
assets:addSprite("sparkle", 16, 16)
assets.sprites["sparkle"]:newAnimation('1-5', 1, 0.08, 'pauseAtEnd')
@ -92,12 +89,8 @@ function Level:loadSprites()
self:loadCochonSprites("cochon")
self:loadCochonSprites("bling-bling")
assets:addSprite("block", 16, 16)
assets.sprites["block"]:newAnimation(1, 1, 0.08)
assets.sprites["block"]:newAnimation(2, 1, 0.08)
assets.sprites["block"]:newAnimation(3, 1, 0.08)
assets.sprites["block"]:newAnimation(4, 1, 0.08)
assets.sprites["block"]:newAnimation(5, 1, 0.08)
self.assets:addTileset("weapon", "assets/sprites/weapon")
self.assets:addTileset("block", "assets/sprites/items/block")
assets:addSprite("debris", 8, 8)
assets.sprites["debris"]:newAnimation(1, 1, 0.08)

View File

@ -113,7 +113,7 @@ function PlayerManager:drawHUD(dt)
end
if (weapon ~= 0) and (weapon ~= nil) then
assets.sprites["weapon"]:drawIcon(weapon,28,28,0,1,1,8,8)
self.scene.assets.tileset["weapon"]:drawTile(weapon,28,28,0,1,1,8,8)
end
assets.progressbar["greenbar"]:draw("HP", 68, 14, 96, hp, "")
assets.progressbar["bluebar"]:draw("MP", 68, 30, 96, mp, "")