Start engines at full, implement main menu
This commit is contained in:
parent
d65357a578
commit
6cc4af0622
5 changed files with 34 additions and 13 deletions
|
@ -113,8 +113,6 @@ function level_state:leave(bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
function level_state:keypressed(key, unicode)
|
function level_state:keypressed(key, unicode)
|
||||||
print('Somebody pressed ' .. key)
|
|
||||||
|
|
||||||
-- Ctrl + R restarts current level.
|
-- Ctrl + R restarts current level.
|
||||||
if key == "r"
|
if key == "r"
|
||||||
and (love.keyboard.isDown("lctrl")
|
and (love.keyboard.isDown("lctrl")
|
||||||
|
@ -137,8 +135,6 @@ end
|
||||||
|
|
||||||
|
|
||||||
function level_state:keyreleased(key, unicode)
|
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)
|
player:release(key)
|
||||||
end
|
end
|
||||||
|
|
3
main.lua
3
main.lua
|
@ -1,6 +1,5 @@
|
||||||
Gamestate = require 'hump.gamestate'
|
Gamestate = require 'hump.gamestate'
|
||||||
require 'menu_state'
|
require 'menu_state'
|
||||||
require 'level_state'
|
|
||||||
require 'settings'
|
require 'settings'
|
||||||
|
|
||||||
-- Initialize game global variables and switch to menu state
|
-- Initialize game global variables and switch to menu state
|
||||||
|
@ -14,7 +13,7 @@ function love.load()
|
||||||
love.physics.setMeter(PIXELS_PER_METER)
|
love.physics.setMeter(PIXELS_PER_METER)
|
||||||
|
|
||||||
Gamestate.registerEvents()
|
Gamestate.registerEvents()
|
||||||
Gamestate.switch(level_state)
|
Gamestate.switch(menu_state)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.quit()
|
function love.quit()
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
Gamestate = require 'hump.gamestate'
|
Gamestate = require 'hump.gamestate'
|
||||||
|
require 'level_state'
|
||||||
|
require 'settings'
|
||||||
|
|
||||||
menu_state = {}
|
menu_state = {}
|
||||||
|
|
||||||
local font = love.graphics.newFont(18)
|
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()
|
function menu_state:enter()
|
||||||
love.graphics.setBackgroundColor(0, 0, 0, 0)
|
love.graphics.setBackgroundColor(0, 0, 0, 0)
|
||||||
|
@ -10,10 +14,34 @@ end
|
||||||
|
|
||||||
|
|
||||||
function menu_state:draw()
|
function menu_state:draw()
|
||||||
|
love.graphics.setColor(128, 128, 128, 255)
|
||||||
|
love.graphics.draw(background)
|
||||||
|
|
||||||
love.graphics.setColor(255,255,255,255)
|
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.setFont(font)
|
||||||
love.graphics.printf("WASD to move", 50, height-100, width, "left")
|
love.graphics.printf("PLAYER 1\
|
||||||
love.graphics.printf("Left mouse button to freeze, right mouse button to speed", width-250, height-100, 200, "right")
|
\
|
||||||
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +56,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function menu_state:keypressed(key, unicode)
|
function menu_state:keypressed(key, unicode)
|
||||||
|
Gamestate.switch(level_state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ Player = Class{
|
||||||
press = function(self, key)
|
press = function(self, key)
|
||||||
for action, keycode in pairs(self.keys) do
|
for action, keycode in pairs(self.keys) do
|
||||||
if key == keycode then
|
if key == keycode then
|
||||||
print(self.name .. ' pressed ' .. action .. '!')
|
|
||||||
if self.actions[action] and self.plane then
|
if self.actions[action] and self.plane then
|
||||||
self.actions[action](true)
|
self.actions[action](true)
|
||||||
end
|
end
|
||||||
|
@ -59,7 +58,6 @@ Player = Class{
|
||||||
release = function(self, key)
|
release = function(self, key)
|
||||||
for action, keycode in pairs(self.keys) do
|
for action, keycode in pairs(self.keys) do
|
||||||
if key == keycode then
|
if key == keycode then
|
||||||
print(self.name .. ' released ' .. action .. '!')
|
|
||||||
if self.actions[action] and self.plane then
|
if self.actions[action] and self.plane then
|
||||||
self.actions[action](false)
|
self.actions[action](false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ SCOREBOARD_MARGIN = 20
|
||||||
ENGINE_MAX = 500
|
ENGINE_MAX = 500
|
||||||
|
|
||||||
INITIAL_PLANE_SPEED = 500
|
INITIAL_PLANE_SPEED = 500
|
||||||
INITIAL_ENGINE_SPEED = 300
|
INITIAL_ENGINE_SPEED = ENGINE_MAX
|
||||||
|
|
||||||
HIT_SCORE = 1
|
HIT_SCORE = 1
|
||||||
KILL_SCORE = 10
|
KILL_SCORE = 10
|
||||||
|
|
Loading…
Reference in a new issue