improvement: use gamecore integrated asset system as much as possible
8
sonic-radiance.love/assets/backgrounds/borders.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
metadata = {
|
||||
width = 80,
|
||||
height = 10,
|
||||
ox = 0,
|
||||
oy = 0,
|
||||
}
|
||||
}
|
8
sonic-radiance.love/assets/backgrounds/normaltile.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
metadata = {
|
||||
width = 40,
|
||||
height = 24,
|
||||
ox = 0,
|
||||
oy = 4,
|
||||
}
|
||||
}
|
8
sonic-radiance.love/assets/backgrounds/specialtile.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
metadata = {
|
||||
width = 40,
|
||||
height = 26,
|
||||
ox = 0,
|
||||
oy = 6,
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
16
sonic-radiance.love/assets/gui/cursor/ground.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
metadata = {
|
||||
width = 28,
|
||||
height = 11,
|
||||
defaultAnim = "default"
|
||||
},
|
||||
animations = {
|
||||
["default"] = {
|
||||
startAt = 1,
|
||||
endAt = 3,
|
||||
loop = 1,
|
||||
speed = 3,
|
||||
pauseAtEnd = false,
|
||||
},
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 457 B |
4
sonic-radiance.love/assets/gui/fonts/hudnumbers.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
glyphs = " 0123456789:/",
|
||||
extraspacing = 1
|
||||
}
|
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
4
sonic-radiance.love/assets/gui/fonts/hudsmallnumbers.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
glyphs = " 0123456789",
|
||||
extraspacing = 0,
|
||||
}
|
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 521 B |
25
sonic-radiance.love/scenes/battlesystem/assets.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
return {
|
||||
["tilesets"] = {
|
||||
{"charicons", "assets/sprites/characters/charicons"},
|
||||
{"normaltiles", "assets/backgrounds/normaltile"},
|
||||
{"sptiles", "assets/backgrounds/specialtile"},
|
||||
{"borders", "assets/backgrounds/borders"},
|
||||
},
|
||||
["sprites"] = {
|
||||
{"cursorground", "assets/gui/cursor/ground"}
|
||||
},
|
||||
["textures"] = {
|
||||
{"menucursor", "assets/gui/cursor-menulist.png"},
|
||||
{"statusbar", "assets/gui/status_bar.png"},
|
||||
{"cursorpeak", "assets/gui/cursor/peak.png"},
|
||||
{"actorsShadow", "assets/sprites/shadow.png"},
|
||||
{"emptytile", "assets/backgrounds/tilemask.png"}
|
||||
},
|
||||
["fonts"] = {
|
||||
{"small", "assets/gui/fonts/PixelOperator.ttf", 16},
|
||||
},
|
||||
["imagefonts"] = {
|
||||
{"hudnbrs", "assets/gui/fonts/hudnumbers"},
|
||||
{"hudnbrs_small", "assets/gui/fonts/hudsmallnumbers"},
|
||||
}
|
||||
}
|
|
@ -20,17 +20,12 @@ function ActorManager:new(controller)
|
|||
|
||||
self.cursor = self.turns.current
|
||||
|
||||
self.controller.assets:addTileset("charicons", "assets/sprites/characters/charicons")
|
||||
for i, v in ipairs(game.characters.team) do
|
||||
self:addCharacter(POSITIONS[i].x, POSITIONS[i].y, v)
|
||||
end
|
||||
|
||||
self:addEnnemy(10, 3, "motobug")
|
||||
self:addEnnemy(10, 5, "motobug")
|
||||
|
||||
--print("entities")
|
||||
self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png")
|
||||
|
||||
end
|
||||
|
||||
function ActorManager:generateActionList()
|
||||
|
@ -135,8 +130,7 @@ function ActorManager:draw()
|
|||
for i,v in ipairs(self.actionlist) do
|
||||
v.actor:drawIcon(4 + (i-1)*(20), 6)
|
||||
end
|
||||
|
||||
love.graphics.draw(self.cursorTexture, self.cursor * 20 - 6, 26, math.rad(-90), 1, 1, 4, 8)
|
||||
self.controller.assets.images["menucursor"]:draw(self.cursor * 20 - 6, 26, math.rad(-90), 1, 1, 4, 8)
|
||||
end
|
||||
|
||||
return ActorManager
|
||||
|
|
|
@ -16,6 +16,8 @@ _GROUND_Y = 90
|
|||
|
||||
function BattleArena:new(controller)
|
||||
self.controller = controller
|
||||
self.assets = self.controller.assets
|
||||
|
||||
self:initArena()
|
||||
|
||||
self.entities = {}
|
||||
|
@ -34,41 +36,10 @@ function BattleArena:initArena(battlefile)
|
|||
self.datas.borders = 1
|
||||
self.datas.terrains = EmptyArena
|
||||
|
||||
self:loadRessources()
|
||||
end
|
||||
|
||||
function BattleArena:loadRessources()
|
||||
local backname = self.datas.background or "city"
|
||||
local tileline = self.datas.tiles or 1
|
||||
local borderline = self.datas.borders or 1
|
||||
|
||||
self.textures = {}
|
||||
self.textures.tiles = love.graphics.newImage("assets/backgrounds/normaltile.png")
|
||||
self.textures.sptiles = love.graphics.newImage("assets/backgrounds/specialtile.png")
|
||||
self.textures.back1 = love.graphics.newImage("assets/backgrounds/parallax/" .. backname .. "-back.png")
|
||||
self.textures.back2 = love.graphics.newImage("assets/backgrounds/parallax/" .. backname .. "-fore.png")
|
||||
self.textures.cliff = love.graphics.newImage("assets/backgrounds/parallax/" .. backname .. "-cliff.png")
|
||||
self.textures.borders = love.graphics.newImage("assets/backgrounds/borders.png")
|
||||
self.textures.shadow = love.graphics.newImage("assets/sprites/shadow.png")
|
||||
|
||||
self.emptytile = love.graphics.newImage("assets/gui/tilemask.png")
|
||||
|
||||
self.quads = {}
|
||||
self.quads.tiles = {}
|
||||
self.quads.sptiles = {}
|
||||
|
||||
local w, h = self.textures.tiles:getDimensions()
|
||||
self.quads.tiles[1] = love.graphics.newQuad( 0, tileline*24, 40, 24, w, h)
|
||||
self.quads.tiles[2] = love.graphics.newQuad(40, tileline*24, 40, 24, w, h)
|
||||
|
||||
local w, h = self.textures.sptiles:getDimensions()
|
||||
local h2 = math.floor(h / 26)
|
||||
for i=1, h2 do
|
||||
self.quads.sptiles[i] = love.graphics.newQuad(0, (i-1)*26, 40, 26, w, h)
|
||||
end
|
||||
|
||||
local w, h = self.textures.borders:getDimensions()
|
||||
self.quads.borders = love.graphics.newQuad(0, borderline*10, 80, 10, w, h)
|
||||
local backpath = "assets/backgrounds/parallax/" .. self.datas.background
|
||||
self.assets:addImage("back1", backpath .. "-back.png")
|
||||
self.assets:addImage("back2", backpath .. "-fore.png")
|
||||
self.assets:addImage("cliff", backpath .. "-cliff.png")
|
||||
end
|
||||
|
||||
function BattleArena:gridToPixel(x, y, center)
|
||||
|
@ -155,23 +126,24 @@ end
|
|||
function BattleArena:drawBackgrounds()
|
||||
local w, _ = core.screen:getDimensions()
|
||||
|
||||
local w2, h2 = self.textures.back1:getDimensions()
|
||||
local w2, h2 = self.assets.images["back1"]:getDimensions()
|
||||
local imax = math.ceil(w / w2) + 1
|
||||
for i=1, imax do
|
||||
love.graphics.draw(self.textures.back1, (i-1)*w2, 0, 0, 1, 1)
|
||||
self.assets.images["back1"]:draw((i-1)*w2, 0, 0, 1, 1)
|
||||
end
|
||||
|
||||
local w2, h2 = self.textures.back2:getDimensions()
|
||||
local w2, h2 = self.assets.images["back2"]:getDimensions()
|
||||
local imax = math.ceil(w / w2) + 1
|
||||
for i=1, imax do
|
||||
love.graphics.draw(self.textures.back2, (i-1)*w2, _GROUND_Y-h2, 0, 1, 1)
|
||||
self.assets.images["back2"]:draw((i-1)*w2, _GROUND_Y-h2, 0, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleArena:drawBorder()
|
||||
local border = self.datas.borders + 1
|
||||
for i=1, 7 do
|
||||
love.graphics.draw(self.textures.borders, self.quads.borders, (i-1)*80, _GROUND_Y-10, 0, 1, 1)
|
||||
love.graphics.draw(self.textures.borders, self.quads.borders, (i-1)*80, _GROUND_Y+20*7, 0, 1, 1)
|
||||
self.assets.tileset["borders"]:drawTile(border, (i-1)*80, _GROUND_Y-10 , 0, 1, 1)
|
||||
self.assets.tileset["borders"]:drawTile(border, (i-1)*80, _GROUND_Y+20*7, 0, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -194,10 +166,10 @@ function BattleArena:drawTerrains()
|
|||
else
|
||||
love.graphics.setColor(vhd, vhd, vhd, 1)
|
||||
end
|
||||
self:drawTile(x, y - 4, terrain, k)
|
||||
self:drawTile(x, y, terrain, k)
|
||||
else
|
||||
love.graphics.setColor(vd, vd, vd, 1)
|
||||
self:drawTile(x, y - 4, 0, k)
|
||||
self:drawTile(x, y, 0, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -207,9 +179,10 @@ end
|
|||
|
||||
function BattleArena:drawTile(x, y, type, variant)
|
||||
if type == 0 then
|
||||
love.graphics.draw(self.textures.tiles, self.quads.tiles[variant], x, y)
|
||||
local tiles = self.datas.tiles*2 + variant
|
||||
self.assets.tileset["normaltiles"]:drawTile(tiles, x, y)
|
||||
else
|
||||
love.graphics.draw(self.textures.sptiles, self.quads.sptiles[type], x, y-2)
|
||||
self.assets.tileset["sptiles"]:drawTile(type, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -218,7 +191,7 @@ function BattleArena:showMask(ox, oy, shape, size, direction)
|
|||
for j=1,7 do
|
||||
if self:isInMask(i, j, ox, oy, shape, size, direction) then
|
||||
local x, y = self:gridToPixel(i, j)
|
||||
love.graphics.draw(self.emptytile, x, y)
|
||||
self.assets.images["emptytile"]:draw(x, y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,26 +16,10 @@ function Cursor:new(controller)
|
|||
self.x = 1
|
||||
self.y = 1
|
||||
self.isActive = false
|
||||
self.frame = 1
|
||||
self.tx = 1
|
||||
self.ty = 1
|
||||
|
||||
self.grid = EmptyGrid
|
||||
|
||||
self:loadRessources()
|
||||
end
|
||||
|
||||
function Cursor:loadRessources()
|
||||
|
||||
self.texture = love.graphics.newImage("assets/gui/cursor.png")
|
||||
self.texture2 = love.graphics.newImage("assets/gui/cursor2.png")
|
||||
|
||||
local w, h = self.texture:getDimensions()
|
||||
self.sprite = {}
|
||||
self.sprite[1] = love.graphics.newQuad(0, 0, 28, 11, w, h)
|
||||
self.sprite[2] = love.graphics.newQuad(28, 0, 28, 11, w, h)
|
||||
self.sprite[3] = love.graphics.newQuad(56, 0, 28, 11, w, h)
|
||||
self.sprite[4] = love.graphics.newQuad(28, 0, 28, 11, w, h)
|
||||
end
|
||||
|
||||
function Cursor:set(x, y)
|
||||
|
@ -97,10 +81,6 @@ end
|
|||
|
||||
function Cursor:update(dt)
|
||||
if (self.isActive) then
|
||||
self.frame = self.frame + dt*4
|
||||
if (self.frame >= 4) then
|
||||
self.frame = 1
|
||||
end
|
||||
local keys = self.controller.sources[1].keys
|
||||
|
||||
if (keys["up"].isPressed) then
|
||||
|
@ -144,9 +124,8 @@ function Cursor:drawBottom()
|
|||
if (self.isActive) then
|
||||
local x, y, frame
|
||||
x, y = self.controller.battlearena:gridToPixel(self.tx, self.ty, true)
|
||||
frame = math.floor(self.frame)
|
||||
|
||||
love.graphics.draw(self.texture, self.sprite[frame], x, y, 0, 1, 1, 14, 6)
|
||||
self.controller.assets.sprites["cursorground"]:drawAnimation(x, y, 0, 1, 1, 14, 6)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -157,7 +136,7 @@ function Cursor:drawTop()
|
|||
local x, y
|
||||
x, y = self.controller.battlearena:gridToPixel(self.tx, self.ty, true)
|
||||
|
||||
love.graphics.draw(self.texture2, x, y - 24, 0, 1, 1, 7, 26)
|
||||
self.controller.assets.images["cursorpeak"]:draw(x, y - 24, 0, 1, 1, 7, 26)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,20 +9,11 @@ function BattleHUD:new(controller)
|
|||
end
|
||||
|
||||
function BattleHUD:loadAssets()
|
||||
self.hud1 = gui.newBorder(424, 30, 8)
|
||||
|
||||
self.hud7 = love.graphics.newImage("assets/gui/status_bar.png")
|
||||
|
||||
self.ring = love.graphics.newImage("assets/gui/ring.png")
|
||||
|
||||
self.font = love.graphics.newImageFont("assets/gui/hudnumbers.png", " 0123456789:/", 1)
|
||||
self.font2 = love.graphics.newImageFont("assets/gui/hudsmallnumbers.png", " 0123456789", 0)
|
||||
|
||||
self.controller.assets:addTileset("lifeicon", "assets/sprites/characters/charicons")
|
||||
self.frame = gui.newBorder(424, 30, 8)
|
||||
end
|
||||
|
||||
function BattleHUD:destroy( )
|
||||
self.hud1:release( )
|
||||
self.frame:release( )
|
||||
end
|
||||
|
||||
function BattleHUD:update(dt)
|
||||
|
@ -30,17 +21,16 @@ function BattleHUD:update(dt)
|
|||
end
|
||||
|
||||
function BattleHUD:draw()
|
||||
love.graphics.setFont( self.font )
|
||||
self.controller.assets.fonts["hudnbrs"]:set()
|
||||
self:drawFrame()
|
||||
--self.controller:resetFont( )
|
||||
end
|
||||
|
||||
function BattleHUD:drawFrame()
|
||||
love.graphics.draw(self.hud1, 424, 20, 0, -1, -1)
|
||||
love.graphics.draw(self.hud7, -8, 215)
|
||||
love.graphics.draw(self.hud7, -8 + 128 + 24, 215)
|
||||
love.graphics.draw(self.hud7, -8 + 256 + 48, 215)
|
||||
--love.graphics.draw(self.hud2, 0, 200)
|
||||
love.graphics.draw(self.frame, 424, 20, 0, -1, -1)
|
||||
self.controller.assets.images["statusbar"]:draw(-8, 215)
|
||||
self.controller.assets.images["statusbar"]:draw(-8 + 128 + 24, 215)
|
||||
self.controller.assets.images["statusbar"]:draw(-8 + 256 + 48, 215)
|
||||
end
|
||||
|
||||
return BattleHUD
|
||||
|
|
|
@ -14,7 +14,6 @@ local MENU_ITEM_NUMBER = 6
|
|||
|
||||
function MenuConstructor:new( controller )
|
||||
self.controller = controller
|
||||
self.controller.assets:addFont("small", "assets/gui/fonts/PixelOperator.ttf", 16)
|
||||
end
|
||||
|
||||
function MenuConstructor:reconstruct(character)
|
||||
|
|
|
@ -55,7 +55,7 @@ end
|
|||
|
||||
function BaseEntity:drawShadow()
|
||||
local x, y = self.controller.battlearena:gridToPixel(self.x, self.y, true)
|
||||
love.graphics.draw(self.controller.battlearena.textures.shadow, x, y, 0, 1, 1, 12, 5)
|
||||
self.controller.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
|
||||
end
|
||||
|
||||
return BaseEntity
|
||||
|
|
|
@ -11,6 +11,8 @@ local MenuSystem = require "scenes.battlesystem.controller.menu"
|
|||
|
||||
function BattleSystem:new()
|
||||
BattleSystem.super.new(self)
|
||||
self.assets:batchImport("scenes.battlesystem.assets")
|
||||
|
||||
self:initManagers()
|
||||
|
||||
self:register()
|
||||
|
|