Crystal.cpp 650 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "Crystal.h"
  2. #include "Model.h"
  3. #include "Player.h"
  4. Crystal::Crystal(const std::string & filled, const std::string & empty, const Vec3f & position, Vec3f & rotation, const float & scale)
  5. {
  6. this->filled = filled;
  7. this->empty = empty;
  8. model = Model::load(this->filled);
  9. this->position = position;
  10. this->rotation = rotation;
  11. this->scale = scale;
  12. this->canCollide = true;
  13. isFilled = true;
  14. }
  15. Crystal::~Crystal()
  16. {
  17. if (model)
  18. Model::unload(model);
  19. }
  20. void Crystal::draw()
  21. {
  22. Entity::draw();
  23. }
  24. void Crystal::collide()
  25. {
  26. if (isFilled)
  27. {
  28. Player::getInstance()->crystals++;
  29. isFilled = false;
  30. model = Model::load(empty);
  31. }
  32. }