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

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
mallo
Prole
Posts: 3
Joined: Sat Nov 08, 2014 1:59 pm

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

Post 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.)
Attachments
space.love
(3.82 KiB) Downloaded 107 times
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

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

Post 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 :)
mallo
Prole
Posts: 3
Joined: Sat Nov 08, 2014 1:59 pm

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

Post 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. :/
mallo
Prole
Posts: 3
Joined: Sat Nov 08, 2014 1:59 pm

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

Post by mallo »

Unrelated question: Where is the "edit" button on the posts? I can't find it... :(
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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..?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

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

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests