My command to end is being ignored.
Posted: Mon Jun 01, 2015 3:35 am
I barely know how to describe this, it basically is just ignoring a bit of my code.
https://imgur.com/QwYpmqI this is the error message
As you can see I have an end to the If function. I honestly have no idea what happened either, I didn't edit any code after I tested it before going away for a minute, then when I went to retest it, I got this error.
edit: forgot to mention, line 114 is at the end, and line 99 is the line that right below where it says enemy AI
https://imgur.com/QwYpmqI this is the error message
Code: Select all
debug = true
player = { x = 10, y = 560, xSpeed = 450, ySpeed = 700, img = nil}
player2 = { x = 1210, y = 560, xSpeed = 450, ySpeed = 700, img = nil}
bullet = { x = 616, y = 336, xSpeed = 450, ySpeed = 400, img = nil}
background = {x = 0, y = 0, img = nil}
score = {player = 0, AI = 0}
function love.draw(dt)
love.graphics.draw(background.Img, background.x, background.y)
love.graphics.draw(player.Img, player.x, player.y)
love.graphics.draw(player2.Img, player2.x, player2.y)
love.graphics.draw(bullet.Img, bullet.x, bullet.y)
end
function love.load(arg)
background.Img = love.graphics.newImage('assets/background.png')
player.Img = love.graphics.newImage('assets/player 1.png')
player2.Img = love.graphics.newImage('assets/player 2.png')
bullet.Img = love.graphics.newImage('assets/bullet.png')
-- asset ready to be used
end
function love.update(dt)
-- basic menu stuff
if love.keyboard.isDown('escape') then
love.event.push('quit')
end
-- player 1
if love.keyboard.isDown('w') then
if player.y > 0 then
player.y = player.y - (player.ySpeed*dt)
end
elseif love.keyboard.isDown('s') then
if player.y < (love.graphics.getHeight() - player.Img:getHeight()) then
player.y = player.y + (player.ySpeed*dt)
end
end
---------------------------------------------------------------------------------------------------------------------------------------
-- Bullet AI
if bullet.x <= 616 then
if player.y >= bullet.y then
bullet.y = bullet.y + (bullet.ySpeed*dt)
elseif player.y < bullet.y then
bullet.y = bullet.y - (bullet.ySpeed*dt)
end
if bullet.x < (love.graphics.getHeight() - bullet.Img:getHeight()) then
bullet.x = bullet.x - (bullet.xSpeed*dt)
end
end
if bullet.x > 616 then
if player2.y > bullet.y then
bullet.y = bullet.y + (bullet.ySpeed*dt)
elseif player2.y < bullet.y then
bullet.y = bullet.y - (bullet.ySpeed*dt)
end
if bullet.x > 0 then
bullet.x = bullet.x + (bullet.xSpeed*dt)
end
end
if bullet.x <= 0 then
bullet.x = 617
bullet.y = 336
end
if bullet.x >= 1280 then
bullet.x = 616
bullet.y = 336
end
---------------------------------------------------------------------------------------------------------------------------------------
-- Score
if bullet.x <= 0 then
score.player = score.player + (1)
end
if bullet.x >= 1280 then
score.AI = score.AI + (1)
end
---------------------------------------------------------------------------------------------------------------------------------------
-- Enemy AI
if bullet.x > 640 then
if bullet.y ~= player2.y then
if player2.y ~= 1 then
if player2.y < (love.graphics.getHeight - player2.Img:getHeight()) then
player2.y = player2.y + (player2.ySpeed*dt)
end
elseif player2.y ~= 580 then
if player2.y < (love.graphics.getHeight - player2.Img:getHeight()) then
player2.y = player2.y + (player2.ySpeed*dt)
elseif bullet.y > player2.y then
player2.y = player2.y + (player2.ySpeed*dt)
elseif bullet.y < player2.y then
player2.y = player2.y - (player2.ySpeed*dt)
end
end
end
edit: forgot to mention, line 114 is at the end, and line 99 is the line that right below where it says enemy AI