Unexpected <eof> near End

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

Unexpected <eof> near End

Post by gravyferry »

I'm trying to make a basic tracking AI that follows the player's y axis and approaches them, then I came across this error, I don't know what's caused it. The code for the AI is below, as well as the code other entities incase they're screwing with it somehow. (This is my first game, so be ready for poorly written code.) This is the entire main.lua . Here's a picture of the error. https://i.imgur.com/uK16U5x.png

Code: Select all

debug = true

player = { x = 10, y = 560, xSpeed = 450, ySpeed = 700, img = nil, Img2 = nil }

player2 = { x = 1270, y = 560, xSpeed = 450, ySpeed = 700, img = nil, Img2 = nil }

bullet = { x = 640, y = 360, xSpeed = 300, ySpeed = 450, img = nil, Img2 = nil }

function love.draw(dt)
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)
	player.Img = love.graphics.newImage('assets/player 1.png')
	player.Img2 = love.graphics.newImage('assets/player 1 flip.png')
	player2.Img = love.graphics.newImage('assets/player 2.png')
	player2.Img2 = love.graphics.newImage('assets/player 2 flip.png')
	bullet.Img = love.graphics.newImage('assets/bullet.png')
	bullet.Img2 = love.graphics.newImage('assets/bullet flip.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
---------------------------------------------------------------------------------------------------------------------------------------

	-- AI

---------------------------------------------------------------------------------------------------------------------------------------

	-- Bullet AI
	if love.keyboard.isDown(' ') then
	 	if player.y >= 360 then
	 		bullet.y = player.y - (bullet.ySpeed*dt)
	 			elseif player.y < 360 then
	 				bullet.y = player.y + (bullet.ySpeed*dt)
	 			end
	 		end
	 	end
	end
---------------------------------------------------------------------------------------------------------------------------------------
end
edit: forgot to mention, I'm going to go to sleep, so I'll look at this when I wake up.
Attachments
Testing.love
(5.88 KiB) Downloaded 170 times
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Unexpected <eof> near End

Post by MadByte »

the problem is this code:

Code: Select all

   -- Bullet AI
   if love.keyboard.isDown(' ') then
       if player.y >= 360 then
          bullet.y = player.y - (bullet.ySpeed*dt)
             elseif player.y < 360 then
                bullet.y = player.y + (bullet.ySpeed*dt)
             end
          end
       end
   end
if you format it right, you can see, that there are two "end" unused, you need to remove them.

Code: Select all

   -- Bullet AI
   if love.keyboard.isDown(' ') then
       if player.y >= 360 then
          bullet.y = player.y - (bullet.ySpeed*dt)
       elseif player.y < 360 then
          bullet.y = player.y + (bullet.ySpeed*dt)
       end
   end
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

Re: Unexpected <eof> near End

Post by gravyferry »

Thanks for the help.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests