Game.cpp 965 B

1234567891011121314151617181920212223242526272829303132
  1. #include "Game.h"
  2. #include "rendering/Renderer.h"
  3. #include "rendering/wrapper/GLFWWrapper.h"
  4. #include "utils/String.h"
  5. Game::Game(const Controller& c, const Clock& fps, const Clock& tps) : controller(c), fps(fps), tps(tps) {
  6. }
  7. float w = 0;
  8. void Game::tick() {
  9. w += 5;
  10. }
  11. void Game::render(float lag, Renderer& renderer) const {
  12. renderer.translateTo(0.0f, 0.0f).scale(2.0f).translate(100.0f, 240.0f).rotate(w + 5 * lag).translate(-100.0f, -240.0f).update();
  13. u64 time = GLFWWrapper::getTimeNanos();
  14. for(uint i = 0; i < 60; i++) {
  15. renderer.drawString(0, i * 10, "Das is&037t ein Test. Das is&077t ein Test. Das is&737t ein Test.");
  16. }
  17. time = GLFWWrapper::getTimeNanos() - time;
  18. renderer.translateTo(0.0f, 0.0f).scale(2.0f).update();
  19. String s;
  20. s.append((int) time).append(" ").append(fps.getUpdatesPerSecond());
  21. renderer.drawString(100, 10, s);
  22. (void) lag;
  23. }
  24. bool Game::isRunning() const {
  25. return true;
  26. }