Page 1 of 1

love.graphics.point makes it unable to draw anything.

Posted: Sat Nov 08, 2014 2:22 pm
by mallo
Hi! I'm making an asteroids-like game. I wanted to make it have a funky starry sky but I've enountered a big problem.

When I don't have any points, everything's perfectly fine. But when I make the game draw points, But only they appear on screen. Nothing else gets drawn anymore. :/

Here's code:

Code: Select all

function love.draw()
	love.graphics.clear()
	love.graphics.setColor(255,255,255)
	love.graphics.setPointSize(2)
	for i=0, StarCount, 1 do
		love.graphics.point(0.5+StarPos[i][1],0.5+StarPos[i][2])
	end
	Ship:Draw()
end

Code: Select all

function Ship:Draw()
	love.graphics.setColor(255,255,255)
	love.graphics.print(Ship.Angle,200,200)
	love.graphics.translate(Ship.X,Ship.Y)
	love.graphics.rotate(math.rad(Ship.Angle))
	love.graphics.line(-15, 15, 0, -25)
	love.graphics.line(0, -25, 15, 15)
	love.graphics.line(-15, 15, 0, 0)
	love.graphics.line(0, 0, 15, 15)
end
I included a .love file of my game. The star-drawing code is in main.lua. (By the way, the number is the ship's angle. I left it because part of it is seen through, but most of it is not.)

Re: love.graphics.point makes it unable to draw anything.

Posted: Sat Nov 08, 2014 5:02 pm
by ArchAngel075
Im not exactly sure but are you making sure to pop ad push the scaling and translating done by Ship:Draw() ?
If you dont anything else drawn afterwards would be affected by the translation and scaling.

Also the love.graphics.clear() is automatically called before love.draw()
[[
Pulled from wiki of love.graphics.clear() [http://love2d.org/wiki/love.graphics.clear]
"This function is called automatically before love.draw in the default love.run function"
]]

Here is a edited .love of the game :

[
space-modified.love
modified version.
(2.02 KiB) Downloaded 115 times
]

Note that i commented in certain words to help.
"#ADDED" is a line of code added,
"#REMOVED" is a lone of code commented out, effectively being removed.
"#DEBUG" is a line of code that can be commented out or removed, its only purpose is to lend to showing the changes made.

The three lines for debug make a small 300x300 red, transparent rectangle. If you do not add the pop and push calls in ship.lua the rectangle will be affected by the translation and scaling and rotation.

Also the .love you posted had a folder "space" which was effectively a copy of the game folder? Probably a messup when compiling into the .love :)

Re: love.graphics.point makes it unable to draw anything.

Posted: Sun Nov 09, 2014 9:05 pm
by mallo
Thanks for the reply! I did add push and pop after I posted the thread, but it didn't help, so I didn't bothered with updating. And sorry, but your code doesn't work. I guess I'll have to live without stars in the sky. :/

Re: love.graphics.point makes it unable to draw anything.

Posted: Sun Nov 09, 2014 9:07 pm
by mallo
Unrelated question: Where is the "edit" button on the posts? I can't find it... :(

Re: love.graphics.point makes it unable to draw anything.

Posted: Sun Nov 09, 2014 10:02 pm
by s-ol
mallo wrote:Unrelated question: Where is the "edit" button on the posts? I can't find it... :(
top right, next to quote and report.

mallo wrote:Thanks for the reply! I did add push and pop after I posted the thread, but it didn't help, so I didn't bothered with updating. And sorry, but your code doesn't work. I guess I'll have to live without stars in the sky. :/
I see stars in your and in the space-modified version..?

Re: love.graphics.point makes it unable to draw anything.

Posted: Mon Nov 10, 2014 4:07 am
by ArchAngel075
This is strange, just as above, in your version i saw stars and space ship etc. I added the changes regardless to prevent future issues.

It seems your pc is not drawing correctly?