|
1 | 1 | #include "Asteroid.h" |
2 | 2 | #include "Constants.h" |
3 | 3 |
|
4 | | -glm::vec4 Asteroid::circlePoint = glm::vec4(0.0f); |
5 | | -glm::vec4 Asteroid::circleCenter = glm::vec4(0.0f); |
| 4 | +glm::vec4 Asteroid::circlePoint = { 1.0f, 0.0f, 0.f, 1.f }; |
| 5 | +glm::vec4 Asteroid::circleCenter = { 0.f, 0.0f, 0.f, 1.f }; |
6 | 6 |
|
7 | 7 | Asteroid::Asteroid(float radius = 40.0f, int nrOfVertices = 16, glm::vec4 coordinates = glm::vec4(0.0f,0.0f, 0.0f, 0.0f), |
8 | | - glm::vec4 colors = glm::vec4(0.0f, 0.0f,0.0f,0.0f)) : radius(radius), nrOfVertices(nrOfVertices), coordinates(coordinates), colors(colors), translatedDistance(0), currentZone(Constants::SAFE) { |
| 8 | + glm::vec4 colors = glm::vec4(0.0f, 0.0f,0.0f,0.0f)) : |
| 9 | + radius(radius), |
| 10 | + nrOfVertices(nrOfVertices), |
| 11 | + coordinates(coordinates), |
| 12 | + colors(colors), |
| 13 | + translatedDistance(0), |
| 14 | + currentZone(Constants::SAFE) { |
9 | 15 | textureIndex = rand() % Constants::nrOfTextures; |
10 | 16 | }; |
| 17 | + |
11 | 18 | bool Asteroid::isInViewport() { |
12 | 19 | return this->coordinates.y - this->translatedDistance < Constants::height && !this->belowViewport(); |
13 | 20 | } |
| 21 | + |
14 | 22 | bool Asteroid::belowViewport() { |
15 | 23 | return this->coordinates.y - this->translatedDistance < - this->radius; |
16 | 24 | } |
| 25 | + |
17 | 26 | bool Asteroid::inLowerHalf() { |
18 | 27 | return !this->belowViewport() && this->isInViewport() && this->getRealY() < Constants::height; |
19 | 28 | } |
| 29 | + |
20 | 30 | string Asteroid::getCurrentZone() { |
21 | 31 | return this->currentZone; |
22 | 32 | } |
| 33 | + |
23 | 34 | void Asteroid::setCurrentZone(string newZone) { |
24 | 35 | this->currentZone = newZone; |
25 | 36 | } |
| 37 | + |
26 | 38 | void Asteroid::updateState() { |
27 | 39 | if (Asteroid::inLowerHalf()) { |
28 | 40 | Asteroid::setCurrentZone(Constants::RED); |
29 | 41 | } |
30 | 42 | } |
| 43 | + |
| 44 | +float Asteroid::getX() { |
| 45 | + return this->coordinates.x; |
| 46 | +} |
| 47 | + |
| 48 | +float Asteroid::getRealY() { |
| 49 | + return this->coordinates.y - this->translatedDistance; |
| 50 | +} |
| 51 | + |
| 52 | +void Asteroid::setX(float newXOffset) { |
| 53 | + this->coordinates.x = newXOffset; |
| 54 | +} |
| 55 | + |
| 56 | +void Asteroid::setY(float newYOffset) { |
| 57 | + this->coordinates.y = newYOffset; |
| 58 | +} |
31 | 59 | int Asteroid::getTextureIndex() { |
32 | 60 | return this->textureIndex; |
33 | 61 | } |
34 | | -float Asteroid::getX() { return this->coordinates.x; } |
35 | | -float Asteroid::getRealY() { return this->coordinates.y - this->translatedDistance; } |
36 | | -void Asteroid::setX(float newXOffset) { this->coordinates.x = newXOffset; } |
37 | | -void Asteroid::setY(float newYOffset) { this->coordinates.y = newYOffset; } |
38 | 62 | float Asteroid::getTranslatedDistance() { return this->translatedDistance; } |
39 | 63 | void Asteroid::setTranslatedDistance(float distance) { this->translatedDistance = distance; } |
40 | 64 | float Asteroid::getRadius() { return this->radius; } |
|
0 commit comments