feat: initial version of the character screen

This commit is contained in:
Kazhnuz 2020-08-26 18:38:40 +02:00
parent ab0c325956
commit 717d7c57c0
11 changed files with 132 additions and 8 deletions

View file

@ -0,0 +1,4 @@
return {
x = 120,
y = -16
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View file

@ -0,0 +1,4 @@
return {
x = 120,
y = -32
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View file

@ -0,0 +1,4 @@
return {
x = 128,
y = -40
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View file

@ -39,6 +39,7 @@ function MovePlayer:new()
self.assets:batchImport("scenes.overworld.assets")
self.tweens = TweenManager(self)
self.screens = screens
World(self, "test", "map")
self.world:setPlayerNumber(1)
@ -123,6 +124,10 @@ function MovePlayer:draw()
love.graphics.rectangle("fill", 0, 0, 424, 240)
utils.graphics.resetColor()
if (self.currentScreen ~= nil) then
self.currentScreen:drawBackground()
end
love.graphics.draw(self.borders, 0, self.borderPosition, 0, 1, -1)
love.graphics.draw(self.borders, 424, 240 - self.borderPosition, 0, -1, 1)

View file

@ -0,0 +1,83 @@
local ParentScreen = require "scenes.overworld.screens.parent"
local CharacterScreen = ParentScreen:extend()
local menu = require "game.modules.menus.fancy"
local gui = require "game.modules.gui"
local ReturnWidget = menu.BaseWidget:extend()
function CharacterScreen:new(scene, character)
self.character = game.characters.list[character]
self.charName = character
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", 176, 48+8)
self.nameBox = gui.newTextBox("assets/gui/dialogbox.png", 176, 40)
self.artwork = love.graphics.newImage("datas/gamedata/characters/" .. character .. "/artwork.png")
self.artworkOrigin = require("datas.gamedata.characters." .. character .. ".artwork")
CharacterScreen.super.new(self, scene)
end
function CharacterScreen:setMenu()
menu.FancyMenu(self.scene, "menu", 272, 140+(17*3), 128, 1, false)
--menu.BaseWidget(self.scene, "equip", "Change talent", ">")
--menu.BaseWidget(self.scene, "equip", "Battle skills", ">")
--menu.BaseWidget(self.scene, "equip", "Equipement", ">")
ReturnWidget(self.scene, self.charName)
self.scene.menusystem:switchMenu("menu")
self.scene.menusystem.menus["menu"]:getFocus()
self.scene.menusystem.menus["menu"]:setCancelWidget()
end
function CharacterScreen:draw()
self.scene.assets.fonts["SA2font"]:print(self.character.name, 158, 16)
love.graphics.draw(self.nameBox, 24 - 4, 40)
love.graphics.draw(self.statBox, 24 - 4, 100)
love.graphics.draw(self.statBox, 24 - 4, 160)
local identityString = self.character.fullname .. "\n"
identityString = identityString .. "Class: " .. self.character.data.class
self.scene.assets.fonts["small"]:draw(identityString, 24, 40 + 3, -1, "left")
local levelString = "Level: " .. self.character.level .. "\n"
local levelString = levelString .. "Current exp: " .. self.character.exp .. "\n"
local levelString = levelString .. "Next level: " .. self.character.exp_next
self.scene.assets.fonts["small"]:draw(levelString, 24, 100 + 3, -1, "left")
local statString = "ATK " .. self.character.stats.attack .. "0" .. "\n"
statString = statString .. "DEF " .. self.character.stats.defense .. "0" .. "\n"
statString = statString .. "SPD " .. self.character.stats.speed .. "0" .. "\n"
statString2 = "POW " .. self.character.stats.power .. "0" .. "\n"
statString2 = statString2 .. "MND " .. self.character.stats.mind .. "0" .. "\n"
statString2 = statString2 .. "TEK " .. self.character.stats.technic .. "0"
local separatorString = ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">"
self.scene.assets.fonts["small"]:draw(statString, 24, 163, -1, "left")
self.scene.assets.fonts["small"]:draw(statString2, 24+ (176/2), 163, -1, "left")
--self.scene.assets.fonts["small"]:draw(separatorString, 88, 120, -1, "left")
--self.scene.assets.fonts["small"]:draw("Weak to: Earth, Lightning \nResist To: Fire", 24+76, 181, -1, "left")
end
function CharacterScreen:drawBackground()
love.graphics.draw(self.artwork, self.artworkOrigin.x, self.artworkOrigin.y)
end
-- Widgets
function ReturnWidget:new(scene, charName)
self.charName = charName
ReturnWidget.super.new(self, scene, "menu", "Back", "")
end
function ReturnWidget:action()
for i, name in ipairs(game.characters.team) do
if (name == self.charName) then
self.widgetSelected = i
end
end
self.scene.screens.mainmenu["pause"](self.scene, "character", self.widgetSelected)
end
return CharacterScreen

View file

@ -1,3 +1,4 @@
return {
pause = require "scenes.overworld.screens.mainmenu.pause"
pause = require "scenes.overworld.screens.mainmenu.pause",
character = require "scenes.overworld.screens.mainmenu.character"
}

View file

@ -14,9 +14,12 @@ local CharacterMenu = baseMenu:extend()
local CharacterWidget = baseWidget:extend()
local TeamWidget = menu.BaseWidget:extend()
--local PauseMenu =
local ViewWidget = menu.BaseWidget:extend()
function PauseScreen:new(scene)
function PauseScreen:new(scene, menu, widget)
self.menuSelected = menu or "main"
self.widgetSelected = widget
self.widget = widget
PauseScreen.super.new(self, scene)
end
@ -32,12 +35,14 @@ function PauseScreen:setMenu()
menu.BaseWidget(self.scene, "main", "Resume", ">")
CharacterMenu(self.scene)
CharacterWidget(self.scene, "sonic")
CharacterWidget(self.scene, "tails")
CharacterWidget(self.scene, "amy")
CharacterWidget(self.scene, "sonic")
for i, name in ipairs(game.characters.team) do
CharacterWidget(self.scene, name)
end
self.scene.menusystem.menus["main"]:getFocus()
self.scene.menusystem.menus[self.menuSelected]:getFocus()
if (self.widgetSelected ~= nil) then
self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected
end
end
function PauseScreen:draw()
@ -85,6 +90,10 @@ function CharacterWidget:draw(x, y)
end
end
function CharacterWidget:action()
self.scene.screens.mainmenu.character(self.scene, self.charName)
end
-- Team Widget
--
@ -96,4 +105,14 @@ function TeamWidget:action()
self.scene.menusystem.menus["character"]:getFocus()
end
-- View Widget
function ViewWidget:new(scene, name, view)
TeamWidget.super.new(self, scene, "main", name, ">")
self.nextView = view
end
function ViewWidget:action()
self.scene.screens.mainmenu[self.nextView](self.scene)
end
return PauseScreen

View file

@ -29,4 +29,8 @@ function MenuScreenParent:draw()
end
function MenuScreenParent:drawBackground()
end
return MenuScreenParent