Black screen when I run the game.

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
BoopDeePoop
Prole
Posts: 39
Joined: Sun Dec 30, 2012 4:15 am

Black screen when I run the game.

Post by BoopDeePoop » Mon Dec 31, 2012 1:58 am

I'm having a strange problem that and I can't find anything wrong with my code. The problem is that when I tried to move my code for a "debug menu" at the top of the screen to a different file, the box would show but the text wouldn't. I then tried to move everything back to my main.lua where it was originally was and now I just get a black screen on startup. There is a high possibility that I missed something when switching it back over but I can't find what. Please help! My .love is attached at the bottom.
Attachments
SurvivalZSource.love
(6.28 MiB) Downloaded 93 times

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: Black screen when I run the game.

Post by Codex » Mon Dec 31, 2012 2:12 am

Your love.draw() should look like this:

Code: Select all

function love.draw()
	local x = love.mouse.getX()
	local y = love.mouse.getY()
	love.graphics.setColor(0, 0, 0, 255)
	love.graphics.line(x, 0, x,love.graphics.getHeight())
	love.graphics.line(0, y,love.graphics.getWidth(),y)
	if gamestate == "menu" then
		love.graphics.setColor(255,255,255,255)
	love.graphics.draw(menubackground,0,0)
	button_draw()
	elseif gamestate == "playing" then
		love.graphics.setColor(0, 0, 0, 255)
	love.graphics.rectangle("fill", 0, 0, 800, 100)
		love.graphics.setColor(255, 255, 255, 255)
		love.graphics.setFont(CentGoth)
	love.graphics.print("Debug Menu", 5, 3)
		love.graphics.setFont(MainFont)
	love.graphics.print("Press ESC to exit the game.", 5, 59)
	love.graphics.print("Press H to hide the cursor.", 5, 73)
	love.graphics.print("FPS: " .. love.timer.getFPS(), 5, 17)
	love.graphics.print("Delta Time: " .. love.timer.getDelta(), 5, 31)
	love.graphics.print("You've played for: " ..math.floor(time_passed).. " seconds.", 5, 45)
		love.graphics.setColor(255, 255, 255, 255)
	love.graphics.draw(playingbackground, 0, 0)
	player_draw()
	end
end
I think you should grasp how to use if, elseif, else loops. Take a look here because you might find it useful.

User avatar
BoopDeePoop
Prole
Posts: 39
Joined: Sun Dec 30, 2012 4:15 am

Re: Black screen when I run the game.

Post by BoopDeePoop » Mon Dec 31, 2012 2:21 am

Now it runs but when I click start it gives me an error that says I need to contact myself.

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: Black screen when I run the game.

Post by Codex » Mon Dec 31, 2012 2:39 am

You might have to jump into your love.mousepressed function and make it so that when you click on an option in the menu that it switches the gamestate.

ie. You click on new game, then gamestate == "playing"

Hope that helps! :ultraglee:

User avatar
BoopDeePoop
Prole
Posts: 39
Joined: Sun Dec 30, 2012 4:15 am

Re: Black screen when I run the game.

Post by BoopDeePoop » Mon Dec 31, 2012 2:51 am

Codex wrote:You might have to jump into your love.mousepressed function and make it so that when you click on an option in the menu that it switches the gamestate.

ie. You click on new game, then gamestate == "playing"

Hope that helps! :ultraglee:
I've already done that in menu.lua. In the function button_click it says:

Code: Select all

if v.id == "start" then gamestate = "playing"

Gravy
Citizen
Posts: 80
Joined: Sun Jan 22, 2012 10:15 pm
Location: CA, USA

Re: Black screen when I run the game.

Post by Gravy » Mon Dec 31, 2012 3:32 am

In your love.load, you only create time_passed if gamestate is "playing". Since the game starts in menu mode, and love.load only gets run once, it is never created. Once i took the if .. then .. end from around time_passed = 0, I was able to enter the game. The "end" was also in the wrong spot in love.load.

You should try to become unreasonably scrupulous about your indentations. It'll make your programming life much easier :)

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Black screen when I run the game.

Post by Robin » Mon Dec 31, 2012 11:17 am

BoopDeePoop wrote:Now it runs but when I click start it gives me an error that says I need to contact myself.
While developing, you need to change this line in conf.lua to

Code: Select all

    t.release = false
That will give you more helpful error screens. (It's the default, so you can just leave out that line as well.)
Help us help you: attach a .love.

User avatar
BoopDeePoop
Prole
Posts: 39
Joined: Sun Dec 30, 2012 4:15 am

Re: Black screen when I run the game.

Post by BoopDeePoop » Mon Dec 31, 2012 8:24 pm

Robin wrote:
BoopDeePoop wrote:Now it runs but when I click start it gives me an error that says I need to contact myself.
While developing, you need to change this line in conf.lua to

Code: Select all

    t.release = false
That will give you more helpful error screens. (It's the default, so you can just leave out that line as well.)
Thanks, I didn't really know what changing that to true did.

I got the game to work now and it's running fine.

Post Reply

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 89 guests