Love:Mike: Added quit to title; Added quit from title; updated TODO; moved quit function into normal keypresses

This commit is contained in:
Logen Kain 2017-08-10 15:14:39 -07:00
parent c39c652d3b
commit 4d68180116
3 changed files with 20 additions and 4 deletions

View File

@ -19,3 +19,10 @@ Seperate out (or add debug mode) to the print_table function so saving is a sepe
make keys.lua more simple by turning more of the code into functions and stuff it in functions.lua make keys.lua more simple by turning more of the code into functions and stuff it in functions.lua
Add continue after pressing Q during gameplay. (timer should keep going)
Reset gamestate when player starts a new game.
move save and load to the title screen
make the title screen better looking
change the title screen to be a selection instead of just pressing keys
remove "q" from qutting the gameplay. Change it to "esc" and have it be a menu instead of insta-quit.

View File

@ -3,7 +3,7 @@ Gamestates = {}
-- Title screen -- Title screen
function Gamestates.title_draw() function Gamestates.title_draw()
love.graphics.setColor(255,0,0) love.graphics.setColor(255,0,0)
love.graphics.print(string.format("Press space to start!"), screen.width/2, screen.height/2) love.graphics.print(string.format("Press space to start!\n Or 'q' to exit."), screen.width/2, screen.height/2)
end end
function Gamestates.title_update() function Gamestates.title_update()
@ -11,6 +11,10 @@ function Gamestates.title_update()
gamestate.draw = Gamestates.main_draw gamestate.draw = Gamestates.main_draw
gamestate.update = Gamestates.main_update gamestate.update = Gamestates.main_update
end end
if love.keyboard.isDown(QUIT_KEY) then
love.event.quit()
end
end end
-- Main game loop -- Main game loop

View File

@ -9,11 +9,9 @@ MOVE_LEFT = "left"
SAVE_FILE = "testing.lua" SAVE_FILE = "testing.lua"
function love.keyreleased(key) function love.keyreleased(key)
if key == QUIT_KEY then
love.event.quit()
-- save -- save
elseif key == SAVE_KEY then if key == SAVE_KEY then
love.filesystem.write(SAVE_FILE, GameState.save(actors, "actors")) love.filesystem.write(SAVE_FILE, GameState.save(actors, "actors"))
-- Load -- Load
@ -43,6 +41,12 @@ function check_keys(object, screen, dt)
newObject.height = object.height newObject.height = object.height
newObject.speed = object.speed newObject.speed = object.speed
if love.keyboard.isDown(QUIT_KEY) then
love.timer.sleep( 1 )
gamestate.draw = Gamestates.title_draw
gamestate.update = Gamestates.title_update
end
if love.keyboard.isDown(MOVE_RIGHT) then if love.keyboard.isDown(MOVE_RIGHT) then
newObject.x = newObject.x + half_speed(newObject.speed * dt) newObject.x = newObject.x + half_speed(newObject.speed * dt)
end end
@ -54,4 +58,5 @@ function check_keys(object, screen, dt)
else else
return object return object
end end
end end