A quick error I just cant find
Posted: Fri Sep 12, 2014 11:43 pm
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
and this is my love.lua and player.lua:
main.lua-
player.lua-
Code: Select all
Syntax error: player.lua:62: '<eof>' expected near end
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
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