Start engines at full, implement main menu

This commit is contained in:
Mikko Ahlroth 2014-10-19 13:54:54 +03:00
parent d65357a578
commit 6cc4af0622
5 changed files with 34 additions and 13 deletions

View file

@ -113,8 +113,6 @@ function level_state:leave(bool)
end
function level_state:keypressed(key, unicode)
print('Somebody pressed ' .. key)
-- Ctrl + R restarts current level.
if key == "r"
and (love.keyboard.isDown("lctrl")
@ -137,9 +135,7 @@ end
function level_state:keyreleased(key, unicode)
print('Somebody released ' .. key)
for id, player in pairs(players) do
for id, player in pairs(players) do
player:release(key)
end
end

View file

@ -1,6 +1,5 @@
Gamestate = require 'hump.gamestate'
require 'menu_state'
require 'level_state'
require 'settings'
-- Initialize game global variables and switch to menu state
@ -14,7 +13,7 @@ function love.load()
love.physics.setMeter(PIXELS_PER_METER)
Gamestate.registerEvents()
Gamestate.switch(level_state)
Gamestate.switch(menu_state)
end
function love.quit()

View file

@ -1,8 +1,12 @@
Gamestate = require 'hump.gamestate'
require 'level_state'
require 'settings'
menu_state = {}
local font = love.graphics.newFont(18)
local titlefont = love.graphics.newFont(72)
local background = love.graphics.newImage('resources/graphics/sky.png')
function menu_state:enter()
love.graphics.setBackgroundColor(0, 0, 0, 0)
@ -10,10 +14,34 @@ end
function menu_state:draw()
love.graphics.setColor(128, 128, 128, 255)
love.graphics.draw(background)
love.graphics.setColor(255,255,255,255)
love.graphics.setFont(titlefont)
love.graphics.printf("FYSPLANE", 0, 100, love.window.getWidth(), "center")
love.graphics.setFont(font)
love.graphics.printf("WASD to move", 50, height-100, width, "left")
love.graphics.printf("Left mouse button to freeze, right mouse button to speed", width-250, height-100, 200, "right")
love.graphics.printf("PLAYER 1\
\
Turn CW: " .. KEYMAP[1]['cw'] .. "\
Turn CCW: " .. KEYMAP[1]['ccw'] .. "\
Shoot: " .. KEYMAP[1]['shoot'] .. "\
Engine power up: " .. KEYMAP[1]['accelerate'] .. "\
Engine power down: " .. KEYMAP[1]['decelerate'] .. "\
", 40, 400, 400, "left")
love.graphics.printf("PLAYER 2\
\
Turn CW: " .. KEYMAP[2]['cw'] .. "\
Turn CCW: " .. KEYMAP[2]['ccw'] .. "\
Shoot: " .. KEYMAP[2]['shoot'] .. "\
Engine power up: " .. KEYMAP[2]['accelerate'] .. "\
Engine power down: " .. KEYMAP[2]['decelerate'] .. "\
", love.window.getWidth() - 40 - 400, 400, 400, "left")
love.graphics.printf("PRESS ANY KEY TO BEGIN…", 0, 700, love.window.getWidth(), "center")
end
@ -28,7 +56,7 @@ end
function menu_state:keypressed(key, unicode)
Gamestate.switch(level_state)
end

View file

@ -48,7 +48,6 @@ Player = Class{
press = function(self, key)
for action, keycode in pairs(self.keys) do
if key == keycode then
print(self.name .. ' pressed ' .. action .. '!')
if self.actions[action] and self.plane then
self.actions[action](true)
end
@ -59,7 +58,6 @@ Player = Class{
release = function(self, key)
for action, keycode in pairs(self.keys) do
if key == keycode then
print(self.name .. ' released ' .. action .. '!')
if self.actions[action] and self.plane then
self.actions[action](false)
end

View file

@ -36,7 +36,7 @@ SCOREBOARD_MARGIN = 20
ENGINE_MAX = 500
INITIAL_PLANE_SPEED = 500
INITIAL_ENGINE_SPEED = 300
INITIAL_ENGINE_SPEED = ENGINE_MAX
HIT_SCORE = 1
KILL_SCORE = 10