Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Few questions about the game engine article.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Keyeszx   Members   -  Reputation: 155

Like
0Likes
Like

Posted 21 January 2014 - 07:50 PM

The article.

http://www.gamedev.net/page/resources/_/technical/game-programming/making-a-game-engine-core-design-principles-r3210

 

So I was wondering a few things about this. What's a singleton? I'm not sure I understand what the person means for scene. When they describe it makes sense but I kind of get loss looking at their code.

 

How does the scene know what game object to add to the scene?



Sponsor:

#2 dejaime   Crossbones+   -  Reputation: 4135

Like
1Likes
Like

Posted 21 January 2014 - 08:03 PM

You could ask that with a comment on the article, as most people here didn't read it and probably doesn't understand the scene->object relationship (as I didn't).

 

But answering to your first question, the one I can answer, a Singleton is a design pattern that forbids the instantiation of more than one object of a given "singleton class". In other words, if you have a Display class in your game, and want to make sure only one Display object is created at a time, you can make your Display class a singleton. So you'll avoid problems like creating two different game windows, in this example.

 

This is one way to do this:

public class Display {
public:
    static Display getInstance() { //This is what you use on your game.
        return SingleInstance;
    }

private:
    private Display(); //This is your constructor, private
                                    //It is private so no one can create new objects
                                    //  but the first one.

    static final Display SingleInstance = new Display(); // The only Display instance.
}

Edited by dejaime, 21 January 2014 - 08:03 PM.


#3 SeanMiddleditch   Crossbones+   -  Reputation: 11184

Like
0Likes
Like

Posted 21 January 2014 - 08:11 PM

The Scenes are likely a somewhat simpler version of what I call Spaces. Here's a talk I gave to game engineering students two years ago on Spaces and their utility:


https://github.com/EngineArchitectureClub/TalkSlides/tree/master/2012/12-Spaces-SeanMiddleditch

#4 jbadams   Senior Staff   -  Reputation: 23323

Like
0Likes
Like

Posted 21 January 2014 - 09:08 PM


a Singleton is a design pattern that forbids the instantiation of more than one object of a given "singleton class"

That's one of the two requirements for a singleton.  The other is that there must be a global point of access to the object.

 

Unless both requirements are met -- that is, it would be an error for more than one instance to be created, and you require global access -- a singleton is probably not the best choice. smile.png






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS