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

Author Topic: Game engine object "owning" a window?  (Read 1484 times)

0 Members and 1 Guest are viewing this topic.

Pixel_Outlaw

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Game engine object "owning" a window?
« on: January 30, 2011, 11:01:35 pm »
I'm not sure what to make of these non copyable resources. I'd like my Engine object to own a window and be in charge of that window for the entire duration of the game. I could make the window a global value but this is frowned upon I'm told. Instead I wanted to make an game Engine class that manages resources.

The following code won't work apparently.

Code: [Select]


class Engine
{
    public:
        Engine();
        ~Engine();

        //SFML members
        sf::RenderWindow my_window;
        list<Player> player_list;


};


// methods
Engine::Engine()
{
        my_window = sf::RenderWindow(sf::VideoMode(640, 480, 32), "Assult Match"); // this cannot be assigned

        my_window.Clear(sf::Color(0,255,64));
        my_window.Display();
};

Engine::~Engine()
{

};

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Game engine object "owning" a window?
« Reply #1 on: January 30, 2011, 11:15:01 pm »
my_window.Create() method is the way

Pixel_Outlaw

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Game engine object "owning" a window?
« Reply #2 on: January 30, 2011, 11:58:48 pm »
Thanks very much. That seems to have solved the problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Game engine object "owning" a window?
« Reply #3 on: January 31, 2011, 07:33:02 am »
Or even better:
Code: [Select]
Engine::Engine() :
  my_window(sf::VideoMode(640, 480, 32), "Assult Match")
{
    ...
}
Laurent Gomila - SFML developer