SFML community forums

Help => General => Topic started by: AdrianHEY on April 07, 2021, 05:28:50 pm

Title: If an object is not drawn does it exist?
Post by: AdrianHEY on April 07, 2021, 05:28:50 pm
If an object is not drawn with the .draw() function is it still in the window?
I am making a kind of shooting game and I have a bullet object. I also have a thing that draws the object whenever you press E.
The question is does the object still "exist"? I mean if it somehow hits an enemy while not drawn will it kill the enemy or do I have to press E so i dray it?
Sry for the bad english.
Title: Re: If an object is not drawn does it exist?
Post by: Stauricus on April 07, 2021, 05:48:25 pm
the sprite exists even if you're not drawing it. it has a size, position, etc
Title: Re: If an object is not drawn does it exist?
Post by: Nexus on April 09, 2021, 01:10:48 pm
Quote
If an object is not drawn does it exist?
Quite a philosophical question!

See my answer in the other thread (https://en.sfml-dev.org/forums/index.php?topic=27974.msg175753#msg175753) for an explanation. Collision with other objects will happen exactly when you program it, otherwise not. There is no "implicit" collision in SFML or anything like that.

Maybe also consider reading a good C++ book that explains the concept of objects and their lifetimes ;)