settings: introduced WIDTH and HEIGHT, use them instead of window size

This commit is contained in:
Erkki Seppälä 2014-10-22 22:06:25 +03:00
parent 2ddead6962
commit 8ce2fb94f0
4 changed files with 12 additions and 8 deletions

View file

@ -1,9 +1,10 @@
-- LÖVE configuration values -- LÖVE configuration values
require 'settings'
function love.conf(t) function love.conf(t)
t.window.title = "Fysplane" t.window.title = "Fysplane"
t.window.width = 1280 t.window.width = WIDTH
t.window.height = 768 t.window.height = HEIGHT
t.window.resizable = false t.window.resizable = false
t.window.vsync = true t.window.vsync = true

View file

@ -31,7 +31,7 @@ Level = Class{
self) self)
end, end,
[2] = function() [2] = function()
return Plane(love.window.getWidth() - 100 - 100, 300, -INITIAL_PLANE_SPEED, 0, return Plane(WIDTH - 100 - 100, 300, -INITIAL_PLANE_SPEED, 0,
0, 255, 0, -- green 0, 255, 0, -- green
self) self)
end } end }
@ -80,11 +80,11 @@ Level = Class{
if entity:isinstance(PhysicsEntity) then if entity:isinstance(PhysicsEntity) then
local jump_window = 70 local jump_window = 70
local jump_amount = 50 local jump_amount = 50
while entity.body:getX() > love.window.getWidth() + jump_window do while entity.body:getX() > WIDTH + jump_window do
entity.body:setX(entity.body:getX() - love.window.getWidth() - jump_window - jump_amount) entity.body:setX(entity.body:getX() - WIDTH - jump_window - jump_amount)
end end
while entity.body:getX() < -jump_window do while entity.body:getX() < -jump_window do
entity.body:setX(entity.body:getX() + love.window.getWidth() + jump_window + jump_amount) entity.body:setX(entity.body:getX() + WIDTH + jump_window + jump_amount)
end end
end end
entity:update(dt) entity:update(dt)

View file

@ -129,8 +129,8 @@ function level_state:update(dt)
local r = love.math.random() local r = love.math.random()
if r <= POWERUP_POSSIBILITY * dt then if r <= POWERUP_POSSIBILITY * dt then
local x = love.math.random(love.window.getWidth()) local x = love.math.random(WIDTH)
local y = love.math.random(love.window.getHeight()) local y = love.math.random(HEIGHT)
POWERUPS[love.math.random(1, #POWERUPS)](x, y, current_level) POWERUPS[love.math.random(1, #POWERUPS)](x, y, current_level)
end end

View file

@ -6,6 +6,9 @@ PIXELS_PER_METER = 8
GRAVITY_X = 0 GRAVITY_X = 0
GRAVITY_Y = 9.82599 * PIXELS_PER_METER GRAVITY_Y = 9.82599 * PIXELS_PER_METER
WIDTH = 1280
HEIGHT = 768
KEYMAP = { KEYMAP = {
[1] = { [1] = {
ccw = 'k', ccw = 'k',