A quick error I just cant find

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
User avatar
BEANSFTW
Prole
Posts: 28
Joined: Sun Apr 15, 2012 2:58 pm

A quick error I just cant find

Post by BEANSFTW »

This should have been a direct copy and paste from one of my templates, but I'm getting an error anyways. seems like a simple problem but I just can't find where it is. The error is

Code: Select all

Syntax error: player.lua:62: '<eof>' expected near end
and this is my love.lua and player.lua:

main.lua-

Code: Select all

require "player"


function love.load()

	
	love.graphics.getBackgroundColor(0,0,0)

	player.load()
	
	glev = 550
	
	gravity = 900
	
end

function love.update(dt)

	UPDATE_PLAYER(dt)


end

function love.draw()

	DRAW_PLAYER()

end
player.lua-

Code: Select all

player = {}
	
function player.load()
	
	player.x = 5
	player.y = 5
	player.xvel = 0
	player.yvel = 0
	player.friction = 7
	player.speed = 2250
	player.width = 50
	player.height = 50
	
end

function player.draw()

	love.graphics.setColor(255,0,0)
	love.graphics.rectangle("fill",player.x,player.y,player.width, player.height)

end

function player.physics(dt)

	player.x = player.x + player.xvel * dt
	player.y = player.y + player.yvel * dt
	player.vel = player.yvel + gravity * dt
	player.xvel = player.xvel * (1 - math.min(dt * player.friction, 1))
	player.yvel = player.yvel * (1 - math.min(dt * player.friction, 1))

end

function player.move(dt)

	if love.keyboard.isDown('right') and
	player.xvel < player.speed then
		player.xvel = player.xvel + player.speed * dt 
	end
	
	if love.keyboard.isDown('left') and
	player.xvel > -player.speed then
		player.xvel = player.xvel - player.speed * dt 
	end

end

function player.collision()

	if player.x < 0 then
		player.x = 0
		player.xvel = 0
	end	
	
	if player.y + player.height > glev then
		player.y = glev - player.height
		player.yvel = 0
	end	

end

function UPDATE_PLAYER(dt)

	player.physics(dt)
	player.move(dt)
	player.collision()
	
end

function DRAW_PLAYER()
	player.draw()
end
Snackrilege
Prole
Posts: 19
Joined: Sat Sep 06, 2014 8:50 pm

Re: A quick error I just cant find

Post by Snackrilege »

There is almost certainly no end of file error in that player code... you're certain you posted all of it ( even comments, etc) ?
User avatar
BEANSFTW
Prole
Posts: 28
Joined: Sun Apr 15, 2012 2:58 pm

Re: A quick error I just cant find

Post by BEANSFTW »

Did you try running the game and seeing if it got an error? from a first glance, it really doesn't look like it has an error. maybe it's the version of love, but still.
Snackrilege
Prole
Posts: 19
Joined: Sat Sep 06, 2014 8:50 pm

Re: A quick error I just cant find

Post by Snackrilege »

Whoops, sorry to leave you hanging!

I just ran the code and was not stopped by the compiler. It displayed a red rectangle in the top right corner of a black screen.

Keep up the good fight, my friend, I know how painful it is to have to debug your debugger. Probably the worst experience in coding.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: A quick error I just cant find

Post by undef »

Maybe you didn't save the changes in all files? Player.lua in this example.
(Maybe you're actually editing a backup at a different location?)

It's always easiest if you just create and upload a .love file, and check if the file works on your computer. If not - upload it.
It's much more convenient for those willing to help as well.
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
BEANSFTW
Prole
Posts: 28
Joined: Sun Apr 15, 2012 2:58 pm

Re: A quick error I just cant find

Post by BEANSFTW »

thx guy for the support, i got the thing working by putting the variables in the player.lua.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 0 guests