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