Interestingly enough, the code still doesn't do as expected when outside the conditional. I can easily verify that the conditional is being entered, because I can change the color of the first setColor() and see the changes work as expected.
As for the code, I can post love.draw() in main and Player:update() (the only place where gameOver is modified) in Player:
main.lua
Code: Select all
function love.draw()
if menu.run then
menu:draw()
elseif gameOver then
--orig_r, orig_g, orig_b, orig_a = love.graphics.getColor( )
love.graphics.setColor(255, 255, 255)
love.graphics.rectangle('fill', 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
love.graphics.setColorMode('modulate')
--ending = 'The End'
love.graphics.setColor(0, 0, 0)
love.graphics.print('The End', love.graphics.getWidth()/2, love.graphics.getHeight()*0.1)
--love.graphics.rectangle('fill', 0,0,love.graphics.getWidth(), love.graphics.getHeight())
else
--Diagnostic Info
love.graphics.print('Current Position {', 5, 35)
love.graphics.print(world.eventHandler.currentPos[1], 140, 35)
love.graphics.print(world.eventHandler.currentPos[2], 180, 35)
love.graphics.print(' }', 220, 35)
love.graphics.print('Player Health: ', 5, 5)
love.graphics.print(world.player.health, 100, 5)
love.graphics.print('Glow Health: ', 5, 20)
love.graphics.print(world.glow.health, 100, 20)
love.graphics.setColor(255,255,255,255)
love.graphics.line(0, 0, 0, 5000)
love.graphics.line(0, 0, 5000, 0)
love.graphics.line(0, 5000, 5000, 5000)
love.graphics.line(5000, 0, 5000, 5000)
fps = love.timer.getFPS()
love.graphics.print('FPS: ', 5, 50)
love.graphics.print(fps, 50, 50)
love.graphics.print('Pulse: ', 5, 85)
if world.player.isPulseActive == false then
love.graphics.print('false', 65, 85)
else
love.graphics.print('true', 65, 85)
end
love.graphics.print('Z1: ', 5, 100)
love.graphics.print(world.itemsInZones[1], 50, 100)
love.graphics.print('Z2: ', 5, 115)
love.graphics.print(world.itemsInZones[2], 50, 115)
love.graphics.print('Z3: ', 5, 130)
love.graphics.print(world.itemsInZones[3], 50, 130)
world:draw()
love.graphics.rectangle('fill', 0,0,love.graphics.getWidth(), love.graphics.getHeight())
end
end
Player.lua (you can probably ignore most of this)
Code: Select all
function Player:update(dt)
self.health = self.health - 100
if self.health < 1 then
--invoke loss condition
--love.graphics.setColor(0, 0, 0, 0)
love.graphics.setFont(font_end)
gameOver = true -- Here
end
--Calculate color
colorPerc = self.currentPulseCD/self.maxPulseCD
if self.currentPulseCD == 0 then
color = {1, 1, 1, 1}
else
color = {0 + colorPerc, 1, .5 + math.pow(colorPerc,2)/2, 1}
end
self.color = color
--Calculate Pulse CD
if self.currentPulseCD ~= 0 then
self.currentPulseCD = self.currentPulseCD - 1
end
--Calculate radius
if self.breathDirection == "in" then
if self.radius < self.minRadius then
self.breathDirection = "out"
end
self.radius = self.radius - 750*(1.0/self.health)
end
if self.breathDirection == "out" then
if self.radius > self.maxRadius then
self.breathDirection = "in"
end
self.radius = self.radius + 750*(1.0/self.health)
end
self.pixelEffect:send('position', {self.x, self.y})
self.pixelEffect:send('size', self.radius)
self.pixelEffect:send('col', self.color)
self.particleSys:update(dt, self.glowhp)
end
Thank you again for the continued support.
EDIT: So I commented out the entire (original) love.draw() call and replaced it with only the problematic code, and it printed "The End", like I wanted it to. So that definitely means something... Are the other conditional blocks somehow being entered? Or is it something to do with setColor()?