My command to end is being ignored.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

My command to end is being ignored.

Post by gravyferry »

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

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
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
Attachments
Archive.love
(5.25 KiB) Downloaded 143 times
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: My command to end is being ignored.

Post by zorg »

gravyferry wrote:

Code: Select all

	-- 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)
				end -- <-- you were probably missing this
			end -- <-- and this too
		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
9th & 10th line from the bottom.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

Re: My command to end is being ignored.

Post by gravyferry »

zorg wrote:
gravyferry wrote:

Code: Select all

	-- 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)
				end -- <-- you were probably missing this
			end -- <-- and this too
		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
9th & 10th line from the bottom.
thanks, that was the problem
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests