Can't make sti work with any kind of camera
Posted: Wed Sep 05, 2018 3:26 pm
Hi guys! I'm really at a loss here, it seems i can't get simple tiled implementation to work with any camera, i tried hump.camera, gamera and simply translating using love.graphics.translate;
P.s.
I use push.lua to manage resolution, i suspect it might be the culprit
P.p.s love version is 11.1
with both the versions above the map get drawn but not the player, also the map doesn't translate
P.s.
I use push.lua to manage resolution, i suspect it might be the culprit
P.p.s love version is 11.1
Code: Select all
-- in main
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
push:setupScreen(gWidth, gHeight, window_width, window_height,
{
vsync = true,
--canvas = false,
fullscreen = false,
resizable = true
})
Gamestate.switch(gStates.play)
end
function love.draw()
push:start()
Gamestate.draw()
push:finish()
end
Code: Select all
-- in play gamestate
local Camera = require "libs/camera"
function play:init()
-- stuff
self.camera = Camera(0,0)
end
function play:draw()
self.camera:attach()
self.map:draw()
self.player:draw()
self.camera:detach()
end
Code: Select all
-- in play gamestate
local gamera = require "libs/gamera"
function play:init()
self.camera = gamera.new(0, 0, gWidth*2, gHeight*2)
end
function play:draw()
self.camera:draw( function(l,t,w,h)
self.map:draw()
self.player:draw()
end)
end