I cannot get anything to run. I followed a Youtube tutorial just to get the hang of things,
but when I tried to run it, the Love screen gives me errors. I searched all over for the
answer to no avail.
Answers to questions I assume you will ask:
--I downloaded both love and lua 64 versions.
--main.lua is at the root of my folder
--I zipped the folder and changed the extension to .love
--All the .lua files are just that (not .lua.text)
--I have tried double-clicking the .love file and tried dragging it to love.exe
I have the code down exactly as in the tutorial, it's just a blue square!
I'll just post it below.
Please let me know anything that might help.
Spanks!
MAIN.LUA
Code: Select all
require "player"
function love.load()
love.graphics.setBackgroundColor(255,255,255)
groundlevel = 400
--loading classes
player.load()
end
function love.update(dt)
UPDATE_PLAYER(dt)
end
function love.draw()
DRAW_PLAYER()
end
Code: Select all
function love.conf(t)
t.title = "Platform"
t.screen.width = 1200
t.screen.height = 750
end
Code: Select all
player = {}
function player.load()
player.x = 10
player.y = 10
player.xvel = 0
player.yvel = 0
player.friction = 6
player.speed = 2200
player.width = 50
player.height = 50
end
function player.draw()
love.graphics.setColor(0,0,255)
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.xvel = player.xvel * (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.boundary()
if player.x < 0 then
player.x = 0
player.xvel = 0
end
if player.y + player.height > groundlevel then
player.y = groundlevel - player.height
player.yvel = 0
end
end
function UPDATE_PLAYER(dt)
player.physics(dt)
player.move(dt)
player.boundary()
end
function DRAW_PLAYER()
player.draw()
end