World.cpp 574 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "World.h"
  2. #include <GL/freeglut.h>
  3. #include "Entity.h"
  4. World::World() : player(Player::getInstance())
  5. {
  6. player.position.y = 1.7;
  7. //entities.push_back(new LevelObject("tree"));
  8. }
  9. World::~World()
  10. {
  11. }
  12. void World::draw()
  13. {
  14. player.setCamera();
  15. glColor3f(0.5f, 0.9f, 0.5f);
  16. glBegin(GL_QUADS);
  17. glVertex3f(-50, 0, -50);
  18. glVertex3f(-50, 0, 50);
  19. glVertex3f(50, 0, 50);
  20. glVertex3f(50, 0, -50);
  21. glEnd();
  22. for (auto e : entities)
  23. e->draw();
  24. glutSwapBuffers();
  25. }
  26. void World::update(float elapsedTime)
  27. {
  28. for (auto e : entities)
  29. e->update(elapsedTime);
  30. }