Skip to content

Commit

Permalink
options menu, vsync, fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashope committed Jan 30, 2017
1 parent 6808afc commit 52b3b5f
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require 'src.state'
require 'src.splash_screen_state'
require 'src.main_menu_state'
require 'src.pause_menu_state'
require 'src.options_menu_state'
require 'src.level_select_state'
require 'src.playing_state'
require 'src.physics'
Expand Down
27 changes: 27 additions & 0 deletions res/text/killed_by_lava.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
YOU ARE DEAD
You died
What a shame...
Looser
Loser
RIP
You have a nice corpse
Darkness engulfs you
Fade to red
Fade to lava
Fade to black
Sizzle sizzle
Toasty
Hot stuff
Lava, don't breathe this
It Burns! it Burns!
Too hot to handle
Lava, don't touch this
Red = danger
Ouch
Humans cause global warming
You look like steak
Game over
Critical fail
Epic fail
Keep practicing...
Nice one, dumbass
24 changes: 24 additions & 0 deletions res/text/killed_by_zombie.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
YOU ARE DEAD
You died
What a shame...
Looser
You have a nice corpse
Brainzzzzz
Braaaaainz
Darkness engulfs you
Fade to green
Fade to zombie
Fade to black
They can smell you
Nom nom
You are delicious
Lava kills faster
YOU ARE UNDEAD
Rawr
Eating your insides
One less human
I am not a cannibal!
Zombies have needs
Zombies are people too
You had a good run
Death comes for us all
3 changes: 3 additions & 0 deletions src/main_menu_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ main_menu_state['play'] = function( self, keycode, scancode, isrepeat )
end

main_menu_state['options'] = function( self, keycode, scancode, isrepeat )
if scancode == 'space' or scancode == 'return' then
Gamestate.switch(options_menu_state)
end
end

main_menu_state['credits'] = function( self, keycode, scancode, isrepeat )
Expand Down
63 changes: 63 additions & 0 deletions src/options_menu_state.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
options_menu_state = MenuState()

function options_menu_state:init()
self.items = {'fullscreen', 'vsync', 'back to main menu'}
self:get_window_mode()
end

function options_menu_state:enter()
self:get_window_mode()
end

function options_menu_state:draw()
love.graphics.setBackgroundColor(self.bg)
love.graphics.print("Options...", 20, 20)

love.graphics.setColor(255,255,255)
for i = 1, #self.items do
local string = self.items[i]

if string == 'fullscreen' then
if self.window_mode.fullscreen then string = string..': [ON] off' else string = string..': on [OFF]' end
elseif string == 'vsync' then
if self.window_mode.vsync then string = string..': [ON] off' else string = string..': on [OFF]' end
end

if i == self.index then string = "> "..string end

love.graphics.print(string, 20, 60 + 20 * i)
end
end

options_menu_state['fullscreen'] = function(self, keycode, scancode, isrepeat)
if scancode == 'space' or scancode == 'return' then
if not self.window_mode.fullscreen then
love.window.setMode( love.graphics.getWidth(), love.graphics.getHeight(), {fullscreen=true} )
else
love.window.setMode( 800, 600, {fullscreen=false} )
end
self:get_window_mode()
end
end

options_menu_state['vsync'] = function(self, keycode, scancode, isrepeat)
if scancode == 'space' or scancode == 'return' then
if not self.window_mode.vsync then
love.window.setMode( love.graphics.getWidth(), love.graphics.getHeight(), {vsync=true, fullscreen=self.window_mode.fullscreen} )
else
love.window.setMode( love.graphics.getWidth(), love.graphics.getHeight(), {vsync=false, fullscreen=self.window_mode.fullscreen} )
end
self:get_window_mode()
end
end

options_menu_state['back to main menu'] = function(self, keycode, scancode, isrepeat)
if scancode == 'space' or scancode == 'return' then
Gamestate.switch(main_menu_state)
end
end

function options_menu_state:get_window_mode()
local x, y = 0, 0
x, y, self.window_mode = love.window.getMode()
end

0 comments on commit 52b3b5f

Please sign in to comment.