diff --git a/include/anim.hpp b/include/anim.hpp index a8fdd0f..6faf7c6 100644 --- a/include/anim.hpp +++ b/include/anim.hpp @@ -16,11 +16,11 @@ class Anim { unsigned int total; float pitch; bool scoreOnce; - Anim (RenderWindow*, unsigned int); + Anim (RenderWindow&, unsigned int); void explodeFood (bool&, Color, Vector2f, const float&); void scoreAnim (SoundManager&, Clock&, Color, unsigned int, Vector2f); private: - sf::RenderWindow* window; + sf::RenderWindow& window; sf::Color color; // explodeFood sf::RectangleShape shape1; diff --git a/include/intro.hpp b/include/intro.hpp index 138a706..c514b9d 100644 --- a/include/intro.hpp +++ b/include/intro.hpp @@ -6,26 +6,26 @@ class intro { public: - float addVal; - float alpha; - bool fadeIn; - bool fadeOut; - bool isSFML; - bool isCreator; - bool isRunning; - explicit intro (sf::RenderWindow*); - void init (); - void updates (); - void events (); - void renders (); - void loop (); + float addVal; + float alpha; + bool fadeIn; + bool fadeOut; + bool isSFML; + bool isCreator; + bool isRunning; + explicit intro (sf::RenderWindow&); + void init (); + void updates (); + void events (); + void renders (); + void loop (); private: - sf::Clock clock; - sf::RenderWindow* renderWin; - sf::Image sfmlLogo; - sf::Image creatorLogo; - sf::Texture texture; - sf::Sprite sprite; + sf::Clock clock; + sf::RenderWindow& renderWin; + sf::Image sfmlLogo; + sf::Image creatorLogo; + sf::Texture texture; + sf::Sprite sprite; }; #endif diff --git a/src/anim.cpp b/src/anim.cpp index bd47132..c5f8702 100644 --- a/src/anim.cpp +++ b/src/anim.cpp @@ -12,7 +12,7 @@ using sf::Vector2f; using sf::Color; using sf::Clock; -Anim::Anim (RenderWindow* window, unsigned int scale) +Anim::Anim (RenderWindow& window, unsigned int scale) : scale(scale), total(0), @@ -54,10 +54,10 @@ void Anim::explodeFood (bool& isActive, Color color, Vector2f foodPos, const flo { if (time >= 0.05f && time < 0.5f) { - window->draw(shape1); - window->draw(shape2); - window->draw(shape3); - window->draw(shape4); + window.draw(shape1); + window.draw(shape2); + window.draw(shape3); + window.draw(shape4); } if (time >= 0.5f && time < 1.0f) { @@ -65,10 +65,10 @@ void Anim::explodeFood (bool& isActive, Color color, Vector2f foodPos, const flo shape2.setPosition(Vector2f(shape2.getPosition().x - scale, shape2.getPosition().y)); shape3.setPosition(Vector2f(shape3.getPosition().x, shape3.getPosition().y + scale)); shape4.setPosition(Vector2f(shape4.getPosition().x, shape4.getPosition().y - scale)); - window->draw(shape1); - window->draw(shape2); - window->draw(shape3); - window->draw(shape4); + window.draw(shape1); + window.draw(shape2); + window.draw(shape3); + window.draw(shape4); } if (time >= 1.0f && time < 1.5f) { @@ -76,10 +76,10 @@ void Anim::explodeFood (bool& isActive, Color color, Vector2f foodPos, const flo shape2.setPosition(Vector2f(shape2.getPosition().x - 2 * scale, shape2.getPosition().y)); shape3.setPosition(Vector2f(shape3.getPosition().x, shape3.getPosition().y + 2 * scale)); shape4.setPosition(Vector2f(shape4.getPosition().x, shape4.getPosition().y - 2 * scale)); - window->draw(shape1); - window->draw(shape2); - window->draw(shape3); - window->draw(shape4); + window.draw(shape1); + window.draw(shape2); + window.draw(shape3); + window.draw(shape4); } if(time >= 1.5f) isActive = false; @@ -109,7 +109,7 @@ void Anim::scoreAnim (SoundManager& soundManager, Clock& clock, Color color, uns text.setFillColor(color); text.setString(intToStr(total)); text.setPosition(position); - window->draw(text); + window.draw(text); } } diff --git a/src/intro.cpp b/src/intro.cpp index 2acc5d3..310073c 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -7,7 +7,7 @@ using sf::Color; using sf::Event; using sf::Keyboard; -intro::intro (RenderWindow* renderWin) +intro::intro (RenderWindow& renderWin) : addVal(0.9f), alpha(0), fadeIn(true), @@ -17,7 +17,7 @@ intro::intro (RenderWindow* renderWin) isRunning(true), renderWin(renderWin) { - renderWin->setMouseCursorVisible(false); + renderWin.setMouseCursorVisible(false); } void intro::init () @@ -28,7 +28,7 @@ void intro::init () if (!creatorLogo.loadFromFile("gfx/Creator_Logo.png")) return; - renderWin->setFramerateLimit(250); + renderWin.setFramerateLimit(250); texture.loadFromImage(sfmlLogo); sprite.setTexture(texture); sprite.setColor(Color(255, 255, 255, alpha)); @@ -101,7 +101,7 @@ void intro::updates () void intro::events () { Event event; - while (renderWin->pollEvent(event)) + while (renderWin.pollEvent(event)) { if (event.type == Event::KeyPressed) { @@ -113,9 +113,9 @@ void intro::events () void intro::renders () { - renderWin->clear(); - renderWin->draw(sprite); - renderWin->display(); + renderWin.clear(); + renderWin.draw(sprite); + renderWin.display(); } void intro::loop () diff --git a/src/snakeGame.cpp b/src/snakeGame.cpp index 1386364..8ac0cdd 100644 --- a/src/snakeGame.cpp +++ b/src/snakeGame.cpp @@ -34,8 +34,8 @@ SnakeGame::SnakeGame (const unsigned int winX, winGrid (winX, winY), foodObj (Vector2f(winGrid.scale, winGrid.scale), winGrid.scale), window (VideoMode(winX, winY), windowTitle), - introduction (&window), - anim (&window, winGrid.scale), + introduction (window), + anim (window, winGrid.scale), interface (&window) { font.loadFromFile(FONT_FILENAME);