From a5386c76824f9c5392c3018d3703bb24535aabb5 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 1 Oct 2012 10:47:42 +0200 Subject: [PATCH] Moved window creation to main(). --- source/Game.cpp | 7 +++---- source/Game.h | 4 ++-- source/main.cpp | 5 ++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/Game.cpp b/source/Game.cpp index a3a5e72..247193d 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -25,11 +25,10 @@ const float Game::TICKS_GOAL = 1000 / Game::FPS_GOAL; /** * Initializes game, including window and objects (sprites). */ -Game::Game(const Vector2i& resolution) : +Game::Game(sf::RenderWindow& window) : mWorld(b2Vec2(0, 0)), - mWindow(sf::VideoMode(resolution.x, resolution.y, 32), "Roguelike Shooter", - sf::Style::Close | sf::Style::Titlebar), - mView(Vector2f(0, 0), Vector2f(resolution)), + mWindow(window), + mView(Vector2f(0, 0), mWindow.getView().getSize()), //mFps("test"), mTileManager(mWorld), mPathfinder(mWorld), diff --git a/source/Game.h b/source/Game.h index 6c175d5..155e503 100644 --- a/source/Game.h +++ b/source/Game.h @@ -29,7 +29,7 @@ class Collection; class Game : private sf::NonCopyable, public b2ContactListener { // Public functions. public: - Game(const Vector2i& resolution); + Game(sf::RenderWindow& window); ~Game(); void loop(); @@ -56,7 +56,7 @@ private: b2World mWorld; - sf::RenderWindow mWindow; + sf::RenderWindow& mWindow; sf::Clock mClock; sf::View mView; //sf::Text mFps; diff --git a/source/main.cpp b/source/main.cpp index 0603dbd..5006214 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -15,7 +15,10 @@ int main(int argc, char* argv[]) { Loader::i().setFolder("resources/"); Loader::i().setSubFolder("textures/"); - Game game(Vector2i(800, 600)); + sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Dungeon Gunner", + sf::Style::Close | sf::Style::Titlebar); + + Game game(window); game.loop();