Game.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <sstream>
  2. #include "client/Game.h"
  3. Game::Game() : texture("resources/textures.png")
  4. {
  5. m.add({0, 0, 0.9, 0, 0, 1, 0, 0});
  6. m.add({0, 1, 0.9, 0, 1, 1, 0, 0});
  7. m.add({1, 0, 0.9, 1, 0, 1, 0, 0});
  8. m.build();
  9. }
  10. void Game::tick(const Keys& keys, const MouseButtons& mButtons, Camera& cam)
  11. {
  12. (void) mButtons;
  13. if(keys.down.isDown())
  14. {
  15. pos.addMul(cam.getFlatBack(), 0.1f);
  16. }
  17. if(keys.up.isDown())
  18. {
  19. pos.addMul(cam.getFlatFront(), 0.1f);
  20. }
  21. if(keys.left.isDown())
  22. {
  23. pos.addMul(cam.getFlatLeft(), 0.1f);
  24. }
  25. if(keys.right.isDown())
  26. {
  27. pos.addMul(cam.getFlatRight(), 0.1f);
  28. }
  29. if(keys.jump.isDown())
  30. {
  31. pos.addMul(cam.getFlatUp(), 0.1f);
  32. }
  33. if(keys.sneak.isDown())
  34. {
  35. pos.addMul(cam.getFlatDown(), 0.1f);
  36. }
  37. cam.storePosition();
  38. cam.setPosition(pos, 0, 0);
  39. }
  40. void Game::renderWorld(float lag, MatrixStack& stack, Shader& sh)
  41. {
  42. (void) lag;
  43. (void) stack;
  44. (void) sh;
  45. texture.bind(0);
  46. m.draw();
  47. }
  48. void Game::renderTextOverlay(float lag, MatrixStack& stack, Shader& sh, FontRenderer& fr)
  49. {
  50. (void) lag;
  51. stack.get().scale(2.0f, 2.0f, 2.0f);
  52. sh.setMatrix("model", stack.get().getValues());
  53. fr.drawString(0, 0, "Das ist ein Test");
  54. }