From d55e3fd138763d3dd3cf161e4bcecc1294f09cb5 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Wed, 3 May 2023 01:33:14 +0200 Subject: [PATCH] Added examples from older games --- src/game/game.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 801be24..764b4d0 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -41,6 +41,23 @@ void Game::run() } } } + +// sf::Clock clock; +// sf::Time TimeSinceLastUpdate = sf::seconds(0); +// +// while (Window.isOpen()) +// { +// processEvents(); +// TimeSinceLastUpdate += clock.restart(); +// while (TimeSinceLastUpdate >= FPS_TIME) +// { +// TimeSinceLastUpdate -= FPS_TIME; +// +// update(); +// processEvents(); +// } +// render(); +// } } void Game::exit() @@ -67,7 +84,79 @@ Game::~Game() } } -void Game::addGameObject(GameObject *gameObject) -{ - gameObjects.push_back(gameObject); -} + +//void Game::initWindow() +//{ +// sf::ContextSettings settings; +// settings.antialiasingLevel = 8; +// Window.create(sf::VideoMode(SCREEN_W, SCREEN_H), "Ping & Pong", sf::Style::Default, settings); +// +// Window.setFramerateLimit(FRAMERATE); +//} +// +//void Game::update() +//{ +// if (bGameRun && tMultiBallTime.asSeconds() == -1) +// { +// for (std::list::iterator i = lBalls.begin(); i != lBalls.end(); ++i) +// (*i)->update(); +// +// updateBars(); +// +// updatekBallGoal(); +// } +// updateScoreString(); +// +// updateMultiBall(); +//} +// +//void Game::processEvents() +//{ +// sf::Event event; +// while (Window.pollEvent(event)) +// { +// switch (event.type) +// { +// case sf::Event::KeyPressed: +// { +// //World.handleInput(event.key.code, true); +// }break; +// case sf::Event::KeyReleased: +// { +// if (event.key.code == sf::Keyboard::P) +// bGameRun = !bGameRun; +// //World.handleInput(event.key.code, false); +// }break; +// case sf::Event::Closed: +// Window.close(); +// break; +// } +// } +//} +// +//void Game::render() +//{ +// Window.clear(); +// +// //Bg +// Window.draw(Background); +// +// //Bar +// for (std::list::iterator i = lBars.begin(); i != lBars.end(); ++i) +// (*i)->draw(&Window); +// +// //Ball +// if ((int)(tMultiBallTime.asSeconds() * 10) % 10 < 5.f) +// for (std::list::iterator i = lBalls.begin(); i != lBalls.end(); ++i) +// (*i)->draw(&Window); +// +// //Score +// for (int i = 0; i < 2; i++) +// Window.draw(sScoreString[i]); +// +// //pausemenu +// if (!bGameRun) +// PauseMenu.draw(&Window); +// +// Window.display(); +//}