Crash on open (Main)

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
McMixx
Prole
Posts: 3
Joined: Thu Jun 27, 2013 10:50 pm

Crash on open (Main)

Post by McMixx »

function love.load()
love.graphics.setBackgroundColor( 255, 255, 255 )
end

function love.draw() -- I think this is the problem too (go down)
local x = love.mouse.getX( )
local y = love.mouse.getY( )

love.graphics.setColor( 0, 0, 0, 255 )
love.graphics.rectangle( "fill", xCloud - 0.5, 450, 30, 30 )
end

function love.update(dt)
xCloud = Cloud + 32*dt
if xCloud >= (800 + 0.5) then
xCloud = 0
end
end -- This and up is a problem (Problem stops at my other note)

function love.focus(bool)
end

function love.keypressed( key, unicode )
end

function love.keyreleased( key, unicode )
end

function love.mousepressed( x, y, button )
end

function love.mousereleased( x, y, button )
end

function love.quit()
end
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Crash on open (Main)

Post by Ensayia »

You don't define xCloud until you use it in update, but you attempt to use it in draw which is called before update.

Defining xCloud and giving it a default value in load may help.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Crash on open (Main)

Post by Boolsheet »

Make sure you have read the Forum Rules. If you follow them, it will increase the chance that someone will or can help you.

When you use code in your post, use the [­code] tags to get a formatting that is cleaner and easier to read.

[­code]function love.load()
end[­/code]

Turns into this.

Code: Select all

function love.load()
end
If your game stops with a message on a blue background, we call that an error. A crash is when the whole application terminates in an abnormal way. I assume you got an error message that tells you what went wrong?

In the function love.update, you use the global variable 'Cloud', but you never set a value to it. Lua can't do arithmetic with nil values. I'm guessing that's a typo and you wanted to write xCloud. Set xCloud to 0 in love.load so it points to an actual number when love.update gets executed.

(love.update gets called before love.draw. See love.run)
Shallow indentations.
McMixx
Prole
Posts: 3
Joined: Thu Jun 27, 2013 10:50 pm

Re: Crash on open (Main)

Post by McMixx »

Thanks and it's a crash (crashes the whole thing), not a error.

Thanks (:
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Crash on open (Main)

Post by Boolsheet »

Well, that should not happen. Can you give us more information about your system?

With such simple code, we usually have to blame the graphics driver or other software that interferes with LÖVE.
Shallow indentations.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Crash on open (Main)

Post by raidho36 »

From my (short) experience with löve2d, I can tell that if it's crashes upon start then it fails to compile your Lua code. It actually quits gracefully rather than crashes it but doesn't leaves any kind of error message. One most frequent case is syntax error. You should check your file very carefully for missing (or extra) brackets, periods and mispelled keywords.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Crash on open (Main)

Post by micha »

In one line you need to replace this:

Code: Select all

xCloud = Cloud + 32*dt
by this:

Code: Select all

xCloud = xCloud + 32*dt
and in the love.load you need to add this line:

Code: Select all

xCloud = 0
However, not doing so should only result in an error (blue LÖVE-window with an error message), not a crash.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Crash on open (Main)

Post by Boolsheet »

raidho36 wrote:It actually quits gracefully rather than crashes it but doesn't leaves any kind of error message.
If the error happens before a window is created it won't bother making one just for the error message. However, it writes all error messages to stdout by default. That's easy to read on Linux and OS X, but because Microsoft did their own thing with the console, it's not very helpful if one doesn't know how to redirect it.
Shallow indentations.
McMixx
Prole
Posts: 3
Joined: Thu Jun 27, 2013 10:50 pm

Re: Crash on open (Main)

Post by McMixx »

Windows 7
HP
RAM: 4.00 (3.75 is usable)
System Type: 64-bit
Processor AMD Athlon(tm) II X2 260u Processor, 1800 Mhz, 2 Core(s), 2 Logical Processor(s)
ATI Radeon HD 4270
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot] and 6 guests