Skip to content

Commit

Permalink
Add instruction view. Add View:setDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
TomK32 committed Dec 4, 2012
1 parent 0c97a04 commit c2c81ad
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions main.lua
Expand Up @@ -76,6 +76,12 @@ function love.keypressed(key, unicode)
end

function love.draw()
if game_state.paused then
-- TODO draw a background
gui_main.instructions_view:draw()
drawCopyright()
return
end
love.graphics.clear()
gui_main:draw()
love.graphics.setColor(255,255,255,255)
Expand Down
4 changes: 3 additions & 1 deletion views/gui_main.lua
Expand Up @@ -4,7 +4,7 @@ require('views/list_view')
require('views/map_view')
require('views/compass_view')
require('views/runners_view')

require('views/instructions_view')
GUIMain = class("GUIMain")
GUIMain:include({

Expand All @@ -27,6 +27,8 @@ GUIMain:include({
self.map_view.display.height = love.graphics.getHeight() - 10
self.map_view:drawCanvas()

self.instructions_view = InstructionsView()

self.focused_view = nil
end,

Expand Down
18 changes: 18 additions & 0 deletions views/instructions_view.lua
@@ -0,0 +1,18 @@

InstructionsView = class("InstructionsView", View)
function InstructionsView:initialize()
self:setDisplay({align = {x = 'center', y = 'center'}, width = 400, height = 100})
end

function InstructionsView:drawContent()
love.graphics.setColor(00,0,0,220)
love.graphics.rectangle('fill', 0, 0, self.display.width, self.display.height)
love.graphics.setColor(200,200,200,255)
love.graphics.rectangle('line', 0, 0, self.display.width, self.display.height)

love.graphics.print('Use your arrows keep to move around', 20, 10)
love.graphics.print('Hit space to pause the game', 20, 25)
love.graphics.print('Hit q to quit the game', 20, 40)
love.graphics.setColor(255,255,255,255)
love.graphics.print('Follow the waypoints to the finish', 20, 80)
end
12 changes: 12 additions & 0 deletions views/view.lua
Expand Up @@ -12,3 +12,15 @@ View:include({
end
})

function View:setDisplay(display)
self.display = display
if display.align then
if display.align.x == 'center' then
display.x = love.graphics.getWidth() / 2 - display.width / 2
end
if display.align.y == 'center' then
display.y = love.graphics.getHeight() / 2 - display.height / 2
end
end
end

0 comments on commit c2c81ad

Please sign in to comment.