Require won't work :s
Posted: Mon Apr 09, 2012 8:55 pm
Hey Guys i have a Problem with Love 0.8.0 I Programmed a New Game(N00b Like xD) and i made a player.lua .. i'll post the complete code..
main.lua
player.lua
Everytime i Started this i became this warning from Love
Error
main.lua:23: stack overflowed
Traceback
main.lua:23: in function 'draw'
main.lua
Code: Select all
require 'player'
function love.load()
mediumFont = love.graphics.newFont(20)
bg_color()
end
function love.update(dt)
if love.keyboard.isDown("right") then
player_x = player_x + (speed * dt)
elseif love.keyboard.isDown("left") then
player_x = player_x - (speed * dt)
end
if love.keyboard.isDown("up") then
player_y = player_y - (speed * dt)
elseif love.keyboard.isDown("down") then
player_y = player_y + (speed * dt)
end
end
function love.draw()
love.draw(player_mob, player_x, player_y)
love.graphics.setFont(mediumFont)
setColor("black")
love.graphics.print("Start Game", 5, 5)
resetColor()
end
function bg_color()
love.graphics.setBackgroundColor(187, 255, 129)
end
function setColor(color)
if color == "black" then
love.graphics.setColor(0, 0, 0)
end
end
function resetColor()
love.graphics.setColor(255, 255, 255)
end
player.lua
Code: Select all
function player()
player_mob = love.graphics.newImage("Data/mob/player.png")
player_x = 200
player_y = 200
speed = 400
end
Error
main.lua:23: stack overflowed
Traceback
main.lua:23: in function 'draw'