summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-22 18:27:14 +0200
committerAki <nthirtyone@gmail.com>2016-08-22 18:27:14 +0200
commit213c783bdde0fe5bf9709e19168a8e5049c7b13a (patch)
treeb6cd11f16bef64c0a45da03f2a16c3ed814c9474
parent7d9d6a04c0bf916da50b5ab6dbafcee4a492398f (diff)
downloadroflnauts-213c783bdde0fe5bf9709e19168a8e5049c7b13a.zip
roflnauts-213c783bdde0fe5bf9709e19168a8e5049c7b13a.tar.gz
roflnauts-213c783bdde0fe5bf9709e19168a8e5049c7b13a.tar.bz2
game title
-rw-r--r--config/menumain.lua34
-rw-r--r--header.lua61
2 files changed, 75 insertions, 20 deletions
diff --git a/config/menumain.lua b/config/menumain.lua
index def1ab7..629284c 100644
--- a/config/menumain.lua
+++ b/config/menumain.lua
@@ -1,44 +1,38 @@
local menu = ...
local button = require "button"
+local header = require "header"
local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale()
local button_x = width/2-29
return {
button:new(menu)
- :setText("start")
- :setPosition(button_x,60)
+ :setText("Start")
+ :setPosition(button_x, 80)
:set("active", function (self)
self.parent:load("menustart")
end)
,
button:new(menu)
- :setText("join")
- :setPosition(button_x,76)
+ :setText("Join")
+ :setPosition(button_x, 96)
,
button:new(menu)
- :setText("settings")
- :setPosition(button_x,92)
+ :setText("Settings")
+ :setPosition(button_x, 112)
,
button:new(menu)
- :setText("credits")
- :setPosition(button_x,108)
+ :setText("Credits")
+ :setPosition(button_x, 128)
,
button:new(menu)
- :setText("exit")
- :setPosition(button_x,124)
+ :setText("Exit")
+ :setPosition(button_x, 144)
:set("active", love.event.quit)
,
- button:new(menu)
- :setText("NEVER")
- :setPosition(button_x,140)
- :set("focus", function (self, next)
- if next then
- self.parent:next()
- else
- self.parent:previous()
- end
- end)
+ header:new(menu)
+ :setText("Roflnauts")
+ :setPosition(width/2,40)
,
} \ No newline at end of file
diff --git a/header.lua b/header.lua
new file mode 100644
index 0000000..d538ab3
--- /dev/null
+++ b/header.lua
@@ -0,0 +1,61 @@
+-- `Header`
+-- It dances!
+
+Header = {
+ x = 0,
+ y = 0,
+ text = "",
+ parent,
+ bounce = 2,
+}
+function Header:new(parent)
+ local o = {}
+ setmetatable(o, self)
+ self.__index = self
+ o.parent = parent
+ return o
+end
+function Header:setText(text)
+ self.text = text or ""
+ return self
+end
+function Header:setPosition(x, y)
+ self.x = x or 0
+ self.y = y or 0
+ return self
+end
+function Header:getBounce(f)
+ local f = f or 1
+ return math.sin(self.bounce*f*math.pi)
+end
+function Header:getPosition() return self.x,self.y end -- gives x,y of Element
+function Header:focus(next)
+ if next and self.parent then
+ self.parent:next()
+ else
+ self.parent:previous()
+ end
+end
+function Header:blur() end -- Called when Element loses focus
+
+-- LÖVE2D callbacks
+function Header:draw(scale)
+ local angle = self:getBounce(2)
+ local dy = self:getBounce()*4
+ local x,y = self:getPosition()
+ love.graphics.setColor(255,255,255,255)
+ love.graphics.setFont(Bold)
+ love.graphics.printf(string.upper(self.text),x*scale,(y+dy)*scale,400,"center",(angle*5)*math.pi/180,scale,scale,200,12)
+end
+function Header:update(dt)
+ self.bounce = self.bounce + dt*0.7
+ if self.bounce > Header.bounce then -- Header.bounce is initial
+ self.bounce = self.bounce - Header.bounce
+ end
+end
+
+-- Controller callbacks
+function Header:controlpressed(set, action, key) end
+function Header:controlreleased(set, action, key) end
+
+return Header \ No newline at end of file