Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started work on fixing some menus #6

Open
wants to merge 1 commit into
base: distortion
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions src/instructions.lua → src/controls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@ function state:init()

self.arrow = love.graphics.newImage("images/menu/arrow.png")
self.background = love.graphics.newImage("images/menu/pause.png")
self.instructions = {}

-- The X coordinates of the columns
self.left_column = 160
self.right_column = 300
-- The Y coordinate of the top key
self.top = 95
-- Vertical spacing between keys
self.spacing = 17

self.controls = {}
end

function state:enter(previous)
Expand All @@ -58,13 +49,22 @@ function state:enter(previous)
VerticalParticles.init()

camera:setPosition(0, 0)
self.instructions = controls:getActionmap()
self.controls = controls:getActionmap()
self.previous = previous
self.option = 0
self.statusText = ''
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
self.x = (self.width - window.width)/2
self.y = (self.height - window.height)/2
self.tx = (self.width - self.background:getWidth()) / 2
self.ty = (self.height - self.background:getHeight()) / 2
self.padx = 10
self.pady = 10 + self.arrow:getHeight()/2
self.padfont = (self.arrow:getHeight() - fonts:getHeight())/2
self.spacing = 17
self.middle = 100
end

function state:leave()
Expand All @@ -84,32 +84,28 @@ end
function state:draw()
VerticalParticles.draw()

love.graphics.draw(self.background,
(self.width - self.background:getWidth()) / 2,
(self.height - self.background:getHeight()) / 2)
love.graphics.draw(self.background, self.tx, self.ty)

local n = 1
local x = (self.width - window.width)/2
local y = (self.height - window.height)/2

love.graphics.setColor(255, 255, 255)
local back = controls:getKey("START") .. ": BACK TO MENU"
local howto = controls:getKey("ATTACK") .. " OR " .. controls:getKey("JUMP") .. ": REASSIGN CONTROL"

love.graphics.print(back, 25, 25)
love.graphics.print(howto, 25, 55)
love.graphics.print(self.statusText, x + self.left_column, y + 280)
love.graphics.print(self.statusText, self.x + self.tx, self.y + self.ty + self.background:getHeight())
love.graphics.setColor( 0, 0, 0, 255 )

for i, button in ipairs(menu.options) do
local z = y + self.top + self.spacing * (i - 1)
local z = self.y + self.ty + self.pady + self.spacing * (i - 1) + self.padfont/2
local key = controls:getKey(button)
love.graphics.print(descriptions[button], x + self.left_column, z, 0, 0.5)
love.graphics.print(key, x + self.right_column, z, 0, 0.5)
local basex = self.x + self.tx + self.padx*2 + self.arrow:getWidth()
love.graphics.print(descriptions[button], basex, z, 0, 0.5)
love.graphics.print(key, basex + self.middle, z, 0, 0.5)
end

love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw(self.arrow, x + 135, y + 87 + self.spacing * menu:selected())
love.graphics.draw(self.arrow, self.x + self.tx + self.padx, self.y + self.ty + self.pady + self.spacing * menu:selected())
end

function state:remapKey(key)
Expand Down
4 changes: 4 additions & 0 deletions src/fonts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function Fonts.set( x )
return love.graphics.getFont()
end

function Fonts.getHeight()
return love.graphics.getFont():getHeight()
end

function Fonts.reset()
Fonts._last = Fonts[Fonts._default]
love.graphics.setFont( Fonts[Fonts._default] )
Expand Down
17 changes: 14 additions & 3 deletions src/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ function state:enter(previous, target)
camera:setPosition(0, 0)
self.previous = previous
self.target = target

local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
self.x = (self.width - window.width)/2
self.y = (self.height - window.height)/2
self.tx = (self.width - self.background:getWidth()) / 2
self.ty = (self.height - self.background:getHeight()) / 2
self.padx = 10
self.pady = 10 + self.arrow:getHeight()/2
self.padfont = (self.arrow:getHeight() - fonts:getHeight())/2
self.spacing = 30

end

function state:leave()
Expand Down Expand Up @@ -336,9 +349,7 @@ function state:draw()

local y = 96

love.graphics.draw(self.background,
camera:getWidth() / 2 - self.background:getWidth() / 2,
camera:getHeight() / 2 - self.background:getHeight() / 2)
love.graphics.draw(self.background, self.tx, self.ty)

love.graphics.setColor( 0, 0, 0, 255 )

Expand Down
35 changes: 21 additions & 14 deletions src/pause.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ function state:enter(previous, player)
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
self.x = (self.width - window.width)/2
self.y = (self.height - window.height)/2
self.tx = (self.width - self.background:getWidth()) / 2
self.ty = (self.height - self.background:getHeight()) / 2
self.padx = 10
self.pady = 10 + self.arrow:getHeight()/2
self.padfont = (self.arrow:getHeight() - fonts:getHeight())/2
self.spacing = 30

camera:setPosition(0, 0)
self.option = 0

if previous ~= Gamestate.get('options') and previous ~= Gamestate.get('instructions') and previous ~= Gamestate.get('overworld') then
if previous ~= Gamestate.get('options') and previous ~= Gamestate.get('controls') and previous ~= Gamestate.get('overworld') then
self.previous = previous
self.player = player
end
Expand Down Expand Up @@ -76,7 +84,7 @@ function state:keypressed( button )
if button == "ATTACK" or button == "JUMP" then
sound.playSfx( 'confirm' )
if self.option == 0 then
Gamestate.switch('instructions')
Gamestate.switch('controls')
elseif self.option == 1 then
Gamestate.switch('options', self.previous)
elseif self.option == 2 then
Expand All @@ -92,25 +100,24 @@ function state:keypressed( button )
end

function state:draw()

VerticalParticles.draw()

love.graphics.draw(self.background,
(self.width - self.background:getWidth()) / 2,
(self.height - self.background:getHeight()) / 2)

local x = (self.width - window.width)/2
local y = (self.height - window.height)/2
love.graphics.draw(self.background, self.tx, self.ty)

local controls = self.player.controls

local sidex = self.x + self.tx + self.padx
local sidey = self.y + self.ty + self.pady

love.graphics.setColor( 0, 0, 0, 255 )
love.graphics.print('Controls', x + 198, y + 101)
love.graphics.print('Options', x + 198, y + 131)
love.graphics.print('Quit to Map', x + 198, y + 161)
love.graphics.print('Quit to Menu', x + 198, y + 191)
love.graphics.print('Quit to Desktop', x + 198, y + 221)
love.graphics.print('Controls', sidex + self.padx + self.arrow:getWidth(), sidey + self.padfont + self.spacing*0)
love.graphics.print('Options', sidex + self.padx + self.arrow:getWidth(), sidey + self.padfont + self.spacing*1)
love.graphics.print('Quit to Map', sidex + self.padx + self.arrow:getWidth(), sidey + self.padfont + self.spacing*2)
love.graphics.print('Quit to Menu', sidex + self.padx + self.arrow:getWidth(), sidey + self.padfont + self.spacing*3)
love.graphics.print('Quit to Desktop', sidex + self.padx + self.arrow:getWidth(), sidey + self.padfont + self.spacing*4)
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw(self.arrow, x + 156, y + 96 + 30 * self.option)
love.graphics.draw(self.arrow, sidex, sidey + self.spacing * self.option)
local back = controls:getKey("START") .. ": BACK TO GAME"
local howto = controls:getKey("ATTACK") .. " OR " .. controls:getKey("JUMP") .. ": SELECT ITEM"
love.graphics.print(back, 25, 25)
Expand Down
21 changes: 12 additions & 9 deletions src/splash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ function splash:init()
self.name = 'splash'
VerticalParticles.init()

camera.x = 528
self.camera_x = {y = camera.x}
local splash_h = 1056
local splash_w = 1008

camera.x = splash_w - window.width + 48
self.camera_x = {x = camera.x}
self.camera_y = {y = camera.y}

self.cityscape = love.graphics.newImage("images/menu/cityscape.png")
Expand All @@ -27,13 +30,13 @@ function splash:init()
local g1 = anim8.newGrid(99, 99, self.beams:getWidth(), self.beams:getHeight())
self.beamsanimate = anim8.newAnimation('once', g1('1-5,1','1-5,2'), 0.03, {[1]=2,[5]=2})

self.logo_position = {y=-self.logo:getHeight()}
self.logo_position = {y=-self.logo:getHeight()-40}
self.logo_position_final = self.logo:getHeight() / 2 + 40

-- panning of camera & logo appears
tween(2, self.camera_y, {y = window.height*2})
tween(2, self.camera_y, {y = splash_h - window.height - 48})
timer.add(2, function()
tween(2, self.camera_x, {y = 0})
tween(2, self.camera_x, {x = 0})
timer.add(2, function() tween(4, self.logo_position, { y=self.logo_position_final}) end)
end)

Expand Down Expand Up @@ -62,7 +65,7 @@ end

function splash:update(dt)

camera.x = self.camera_x.y
camera.x = self.camera_x.x
camera.y = self.camera_y.y

if self.double_speed then
Expand Down Expand Up @@ -102,14 +105,14 @@ end
function splash:draw()

VerticalParticles.draw()

local xlogo = window.width / 2 - self.logo:getWidth()/2
print(camera.y)
local xlogo = (window.width - self.logo:getWidth())/2
local ylogo = window.height / 2 - self.logo_position.y

love.graphics.draw(self.cityscape)
love.graphics.draw(self.logo, xlogo, ylogo + camera.y )

self.beamsanimate:draw(self.beams, window.width*0.291 + camera.x, window.height*0.089 + camera.y)
self.beamsanimate:draw(self.beams, 153.648 + camera.x, 29.904 + camera.y)

if camera.x == 0 then
for _,_sp in pairs(self.sparkles) do
Expand Down
41 changes: 22 additions & 19 deletions src/start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ function state:enter( previous )
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
self.x = (self.width - window.width)/2
self.y = (self.height - window.height)/2
self.tx = (self.width - self.background:getWidth()) / 2
self.ty = (self.height - self.background:getHeight()) / 2
self.padx = 10
self.pady = 10 + self.arrow:getHeight()/2
self.padfont = (self.arrow:getHeight() - fonts:getHeight())/2
self.savespacing = 20
self.spacing = 30
end

function state:leave()
Expand Down Expand Up @@ -162,14 +171,14 @@ end
function state:draw()
VerticalParticles.draw()

local sidex = self.x + self.tx + self.padx
local sidey = self.y + self.ty + self.pady

love.graphics.setColor(255, 255, 255)
love.graphics.draw(self.background,
(self.width - self.background:getWidth()) / 2,
(self.height - self.background:getHeight()) / 2)

local x = (self.width - window.width)/2
local y = 90 + (self.height - window.height)/2

if self.window == 'main' then
love.graphics.setColor(255, 255, 255)
local howto = controls:getKey("ATTACK") .. " OR " .. controls:getKey("JUMP") .. ": SELECT SLOT"
Expand All @@ -183,35 +192,29 @@ function state:draw()
for n, opt in pairs(self.options) do
if tonumber( n ) ~= nil then
if opt.name and opt.slot then
love.graphics.print( opt.name , x + 175, y, 0 )
y = y + yFactor
love.graphics.print( self.get_slot_level( opt.slot ), x + 190, y, 0 )
y = y + yFactor
love.graphics.print( opt.name, sidex + self.arrow:getWidth() + self.padx, sidey + self.padfont + (n-1)*2*self.savespacing, 0 )
love.graphics.print( self.get_slot_level( opt.slot ), sidex + self.arrow:getWidth() + self.padx + 15, sidey + self.padfont + ((n-1)*2+1)*self.savespacing, 0 )
elseif opt.name then
y = y + yFactor
love.graphics.print( opt.name, x + 175, y, 0 )
love.graphics.print( opt.name, sidex + self.arrow:getWidth() + self.padx, sidey + self.padfont + (n-1)*2*self.savespacing, 0 )
end
end
end
love.graphics.setColor( 255, 255, 255, 255 )
-- Determine how far the arrow should move for the last menu item
local arrowYFactor = 2
if self.selection > 2 then
arrowYFactor = 2.5
end
love.graphics.draw( self.arrow, x + 135, y - 80 + ( (yFactor * arrowYFactor) * ( self.selection - 1 ) ) )

love.graphics.draw( self.arrow, sidex, sidey + self.savespacing * self.selection * 2 )
elseif self.window == 'deleteSlot' then
love.graphics.setColor(255, 255, 255)
local howto = controls:getKey("UP") .. " OR " .. controls:getKey("DOWN") .. ": CHANGE OPTION"
local delete = controls:getKey("JUMP") .. ": SELECT OPTION"
love.graphics.print(howto, 25, 25)
love.graphics.print(delete, 25, 55)
love.graphics.setColor( 0, 0, 0, 255 )
love.graphics.printf('Are you sure you want to delete this slot?', x + 155, y + 20, self.background:getWidth() - 30, 'left')
love.graphics.print('Yes', x + 175, y + 85, 0)
love.graphics.print('No', x + 175, y + 115, 0)
love.graphics.printf('Are you sure you want to delete this slot?', sidex, sidey, self.background:getWidth() - self.padx*2, 'left')
local space_offset = 50
love.graphics.print('Yes', sidex + self.arrow:getWidth() + self.padx, sidey + self.padfont + space_offset + self.spacing*0, 0)
love.graphics.print('No', sidex + self.arrow:getWidth() + self.padx, sidey + self.padfont + space_offset + self.spacing*1, 0)
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw( self.arrow, x + 140, y + 80 + 30 * self.selectionDelete )
love.graphics.draw( self.arrow, sidex, sidey + space_offset + self.spacing * self.selectionDelete )
end
end

Expand Down
2 changes: 0 additions & 2 deletions src/welcome.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function state:init()
self.menu:onSelect(function(option)
if option == 'exit' then
love.event.push("quit")
elseif option == 'controls' then
Gamestate.switch('instructions')
else
Gamestate.switch(option)
end
Expand Down