I'm using the gamestates module from noooway's arkanoid tutorial:
Code: Select all
local gamestates = {}
local current_state = nil
local loaded = {} -- doesn't require automatically check for this?
function gamestates.state_event(function_name, ...)
if current_state and type(current_state[function_name]) == "function" then
current_state[function_name](...)
end
end
function gamestates.set_state(state_name, ...)
gamestates.state_event("exit")
local old_state_name = get_key_for_value(loaded, current_state) -- get_key_for_value(table, value) return key
current_state = loaded[ state_name ] -- check if it's already loaded
if not current_state then -- if not i load it
current_state = require( "gamestates/" .. state_name )
loaded[ state_name ] = current_state
gamestates.state_event("load", old_state_name, ... )
end
gamestates.state_event("enter", old_state_name, ... )
end
function get_key_for_value(table, value)
for k,v in ipairs(table) do
if v == value then
return k
end
end
end
return gamestates
Anyway i don't believe the problem is related to the gamestates module, probably is the camera:
the game window is 480x672
Code: Select all
function love.conf(t)
t.title = "Scrolling Shooter Tutorial" -- The title of the window the game is in (string)
t.version = "0.9.1" -- The LÖVE version this game was made for (string)
t.window.width = 480 -- we want our game to be long and thin.
t.window.height = 672
-- For Windows debugging
t.console = true
end
as i wanted to use 24x24 sprites i configured the main as such:
Code: Select all
require "strict"
gamestates = require "gamestates.gamestates"
camera = require "tools.camera"
G_width = 120 --love.graphics.getWidth() <-- HERE: set globals for screen dimension
G_height = 168 --love.graphics.getHeight()
G_debug = true
G_fps = 0
G_time = 0
G_tileSize = 24
score = 0
function love.load(arg)
camera.scale.x = 0.25 -- <-- upscaled 4x
camera.scale.y = 0.25
gamestates.set_state("splash")
end
function love.update(dt)
G_time = G_time + dt
gamestates.state_event("update", dt)
end
function love.draw()
camera:set()
gamestates.state_event("draw")
camera:unset()
end
function love.keyreleased(key)
gamestates.state_event("keyreleased", key)
end