Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Few questions about the game engine article.

4: Adsense

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   

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?



#2 dejaime   Members   

4220
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   Members   

17493
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

Game Developer, C++ Geek, Dragon Slayer - http://seanmiddleditch.com

C++ SG14 "Games & Low Latency" - Co-chair - public forums

Wargaming Seattle - Lead Server Engineer - We're hiring!


#4 jbadams   Senior Staff   

25503
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


- Jason Astle-Adams





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.