Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: If an object is not drawn does it exist?  (Read 3590 times)

0 Members and 1 Guest are viewing this topic.

AdrianHEY

  • Newbie
  • *
  • Posts: 14
    • View Profile
If an object is not drawn does it exist?
« 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.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: If an object is not drawn does it exist?
« Reply #1 on: April 07, 2021, 05:48:25 pm »
the sprite exists even if you're not drawing it. it has a size, position, etc
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: If an object is not drawn does it exist?
« Reply #2 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 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 ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: