I honestly don't know what I did. Things were great until I decided to use HUMP's camera to adjust the camera for only one scene, not both of them. Here is the main.lua file. The player code only has the images of the player and its X and Y position, so it's unrelated.
Code: Select all
windowCenterX = love.graphics.getWidth() / 2
windowCenterY = love.graphics.getHeight() / 2
startButtonWidth = 228
startButtonHeight = 34
startButtonStartX = windowCenterX - (startButtonWidth / 2)
startButtonStartY = windowCenterY - (startButtonHeight / 2)
startButtonEndX = startButtonStartX + startButtonWidth
startButtonEndY = startButtonStartY + startButtonHeight
level = 0
function love.load()
require("Player")
sti = require("Simple-Tiled-Implementation-master/sti")
BrokenBridge = sti("maps/BrokenBridge.lua")
themeSound = love.audio.newSource("sounds/mad_scientist.mp3", "static")
themeSound:setLooping(true)
themeSound:play()
sprites = {}
sprites.background1 = love.graphics.newImage("sprites/Background1_pc.png")
sprites.startButton = love.graphics.newImage("sprites/button_Start_G.png")
sprites.pressedStartButton = love.graphics.newImage("sprites/button_Start_R.png")
cameraFile = require("hump-master/camera")
cam = cameraFile()
normalWorld = love.physics.newWorld(0, 100)
end
function love.update(dt)
if level > 0 then
BrokenBridge:update(dt)
cam:lookAt(Player.x, Player.y)
end
end
function love.draw()
cam:attach()
if level > 0 then
love.graphics.draw(Player, StartX, StartY, nil, 0.25, 0.25)
end
if level == 1 then
BrokenBridge:drawLayer(BrokenBridge.layers["Background"])
end
cam:detach()
love.graphics.draw(sprites.background1, 0, 0)
love.graphics.draw(sprites.startButton, startButtonStartX, startButtonStartY)
end
function isStartButtonClicked(mouseX, mouseY)
if (mouseX > startButtonStartX) and (mouseX < startButtonEndX) and (mouseY > startButtonStartY) and (mouseY < startButtonEndY) and level == 0 then
return true
end
return false
end
function love.mousepressed(mouseX, mouseY, button, istouch)
if isStartButtonClicked(mouseX, mouseY) then
level = 1
end
end
function startLevel()
for i,obj in pairs(BrokenBridge.layers["StartPosition"]) do
StartX = obj.x
StartY = obj.y
end
end