Lua show black screen when i run code

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.
MartinGarciaARG
Prole
Posts: 6
Joined: Thu Sep 08, 2022 4:44 pm

Lua show black screen when i run code

Post by MartinGarciaARG »

Hi, im new at this, i started following a tutorial about LOVE using ZeroBrane Studio for editing. I started with the classic "Hello World", then i continue the tutorial drawing a rectangle, after that, adding code to move it, until this moment all worked ok, but then something happens, now every time i try to run this code again, LOVE only open the black screen showing nothing. Any suggestion about what could happens? . Thanks in advance.
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Lua show black screen when i run code

Post by milon »

Can you post your .love file (or contents of main.lua)? What operating system are you running? What version of Love do you have installed?
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
knorke
Party member
Posts: 238
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Lua show black screen when i run code

Post by knorke »

MartinGarciaARG wrote: Thu Sep 08, 2022 4:56 pmthen i continue the tutorial drawing a rectangle, after that, adding code to move it, until this moment all worked ok,
Maybe you moved the rectangle off-screen?
The usual approach when things do not work is to un-do the last changes until it somewhat works again. Then carefully do more changes and experiment.
But do post your code, otherwise we can only guess. But it feels like the error is more likely in your code rather than Love or OS.
MartinGarciaARG
Prole
Posts: 6
Joined: Thu Sep 08, 2022 4:44 pm

Re: Lua show black screen when i run code

Post by MartinGarciaARG »

knorke wrote: Thu Sep 08, 2022 9:50 pm
MartinGarciaARG wrote: Thu Sep 08, 2022 4:56 pmthen i continue the tutorial drawing a rectangle, after that, adding code to move it, until this moment all worked ok,
Maybe you moved the rectangle off-screen?
The usual approach when things do not work is to un-do the last changes until it somewhat works again. Then carefully do more changes and experiment.
But do post your code, otherwise we can only guess. But it feels like the error is more likely in your code rather than Love or OS.
Hi, thanks for replying, yes , the idea of that tutorial is showing how you move that rectangle, and yes, it went off the screen the first time. But why if i re starting the code it seems appear off screen, it should start at the initial x,y position.
Attachments
main.lua
(164 Bytes) Downloaded 66 times
MartinGarciaARG
Prole
Posts: 6
Joined: Thu Sep 08, 2022 4:44 pm

Re: Lua show black screen when i run code

Post by MartinGarciaARG »

milon wrote: Thu Sep 08, 2022 7:59 pm Can you post your .love file (or contents of main.lua)? What operating system are you running? What version of Love do you have installed?
Yes, the code is very simple, after the first time when it showed the rectangle moving and dissapearing off the screen, it stoped to work and now every time i run the code it opens the LOVE screen but dont show nothing.
Thanks.
Attachments
main.lua
(164 Bytes) Downloaded 59 times
MartinGarciaARG
Prole
Posts: 6
Joined: Thu Sep 08, 2022 4:44 pm

Re: Lua show black screen when i run code

Post by MartinGarciaARG »

milon wrote: Thu Sep 08, 2022 7:59 pm Can you post your .love file (or contents of main.lua)? What operating system are you running? What version of Love do you have installed?
I have installed love-11.4-win64. And im running Windows10 Pro.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Lua show black screen when i run code

Post by ReFreezed »

There's nothing weird about the code. Restarting the game resets everything as expected.

Did you disable vsync by any chance? That would likely make the rectangle fly away very fast. To make the game frame rate independent use the delta time supplied to the update function:

Code: Select all

function love.update(dt)
  x = x + 50*dt -- Move 50 pixels per second.
end
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
MartinGarciaARG
Prole
Posts: 6
Joined: Thu Sep 08, 2022 4:44 pm

Re: Lua show black screen when i run code

Post by MartinGarciaARG »

ReFreezed wrote: Fri Sep 09, 2022 1:00 pm There's nothing weird about the code. Restarting the game resets everything as expected.

Did you disable vsync by any chance? That would likely make the rectangle fly away very fast. To make the game frame rate independent use the delta time supplied to the update function:

Code: Select all

function love.update(dt)
  x = x + 50*dt -- Move 50 pixels per second.
end
Yes, i tried that of delta time before but nothing seems to work, even if i put breakpoints in the code, when i run the programm in debug mode it never stop on thouse breakpoints.
User avatar
BrotSagtMist
Party member
Posts: 607
Joined: Fri Aug 06, 2021 10:30 pm

Re: Lua show black screen when i run code

Post by BrotSagtMist »

"draws nothing but the background"
Is this related to the other post: viewtopic.php?f=3&t=93747&sid=cc9e1b026 ... 135c5da433 ?
obey
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Lua show black screen when i run code

Post by milon »

1. Try making a new project. Can you print/draw to the screen?

2. Try this as its own project:

Code: Select all

function love.mousepressed()
	local r = love.math.random()
	local g = love.math.random()
	local b = love.math.random()
	print(r, g, b)
	love.graphics.setBackgroundColor(r, g, b)
end
Does the screen color change when you click in the window?
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 35 guests