added main menu art
This commit is contained in:
BIN
assets/images/main-menu.aseprite
Normal file
BIN
assets/images/main-menu.aseprite
Normal file
Binary file not shown.
BIN
assets/images/main-menu.png
Normal file
BIN
assets/images/main-menu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
@@ -8,7 +8,7 @@ MainMenu.__index = MainMenu
|
||||
|
||||
function MainMenu.new(core, input)
|
||||
setmetatable(MainMenu, { __index = Menu })
|
||||
local self = setmetatable(Menu.new(core, input), MainMenu)
|
||||
local self = setmetatable(Menu.new(core, input, 'assets/images/main-menu.png'), MainMenu)
|
||||
|
||||
self:_initializeScreens()
|
||||
self:_pushScreen(self.screens.main)
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
local component = require 'packages.badr'
|
||||
|
||||
-- https://github.com/s-walrus/hex2color/blob/master/hex2color.lua
|
||||
local function Hex(hex, value)
|
||||
return {
|
||||
tonumber(string.sub(hex, 2, 3), 16) / 256,
|
||||
tonumber(string.sub(hex, 4, 5), 16) / 256,
|
||||
tonumber(string.sub(hex, 6, 7), 16) / 256,
|
||||
value or 1 }
|
||||
end
|
||||
local hex = require 'src.utils.hex'
|
||||
|
||||
return function(props)
|
||||
local font = props.font or love.graphics.getFont()
|
||||
@@ -29,9 +21,9 @@ return function(props)
|
||||
font = font,
|
||||
-- styles
|
||||
opacity = props.opacity or 1,
|
||||
backgroundColor = props.backgroundColor or Hex '#DBE2EF',
|
||||
hoverColor = props.hoverColor or Hex '#3F72AF',
|
||||
textColor = props.textColor or Hex '#112D4E',
|
||||
backgroundColor = props.backgroundColor or hex '#f4c47f',
|
||||
hoverColor = props.hoverColor or hex '#ebab65',
|
||||
textColor = props.textColor or hex '#ecd5bf',
|
||||
cornerRadius = props.cornerRadius or 4,
|
||||
leftPadding = props.leftPadding or 12,
|
||||
rightPadding = props.rightPadding or 12,
|
||||
@@ -58,7 +50,7 @@ return function(props)
|
||||
love.graphics.push()
|
||||
love.graphics.rotate(self.angle)
|
||||
love.graphics.scale(self.scale, self.scale)
|
||||
love.graphics.setFont(font)
|
||||
-- love.graphics.setFont(font)
|
||||
-- border
|
||||
if self.border then
|
||||
love.graphics.setColor(self.borderColor)
|
||||
|
||||
@@ -15,7 +15,7 @@ local function label(options)
|
||||
font = _font,
|
||||
draw = function(self)
|
||||
if not self.visible then return end
|
||||
love.graphics.setFont(self.font)
|
||||
-- love.graphics.setFont(self.font)
|
||||
love.graphics.setColor {
|
||||
color[1], color[2], color[3], options.opacity
|
||||
}
|
||||
|
||||
10
src/utils/hex.lua
Normal file
10
src/utils/hex.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- https://github.com/s-walrus/hex2color/blob/master/hex2color.lua
|
||||
local function hex(hexString, value)
|
||||
return {
|
||||
tonumber(string.sub(hexString, 2, 3), 16) / 256,
|
||||
tonumber(string.sub(hexString, 4, 5), 16) / 256,
|
||||
tonumber(string.sub(hexString, 6, 7), 16) / 256,
|
||||
value or 1 }
|
||||
end
|
||||
|
||||
return hex
|
||||
@@ -3,12 +3,15 @@ local LoveNode = require 'src.utils.love_node'
|
||||
local Menu = {}
|
||||
Menu.__index = Menu
|
||||
|
||||
function Menu.new(core, input)
|
||||
function Menu.new(core, input, bgPath)
|
||||
setmetatable(Menu, { __index = LoveNode })
|
||||
local self = setmetatable(LoveNode.new(), Menu)
|
||||
|
||||
self.core = core
|
||||
self.input = input
|
||||
if bgPath then
|
||||
self.bgPath = love.graphics.newImage(bgPath)
|
||||
end
|
||||
|
||||
-- Initialize screens and stack navigation
|
||||
self.screens = {}
|
||||
@@ -25,6 +28,9 @@ function Menu:update(dt)
|
||||
end
|
||||
|
||||
function Menu:draw()
|
||||
if self.bgPath then
|
||||
love.graphics.draw(self.bgPath, 0, 0, 0, 1, 1, 0, 0, 0, 0)
|
||||
end
|
||||
local screen = self:getActiveScreen()
|
||||
if screen then
|
||||
screen:draw()
|
||||
|
||||
Reference in New Issue
Block a user