-
Notifications
You must be signed in to change notification settings - Fork 2
/
Apple.hpp
25 lines (21 loc) · 814 Bytes
/
Apple.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once
#include "Random.hpp"
#include "Quad.hpp"
class Apple {
public:
static Quad apple;
static GLfloat horizontalPosition;
static GLfloat verticalPosition;
public:
static void create() {
horizontalPosition = Random::getReal(-1.0f, 0.9f);
verticalPosition = Random::getReal(-1.0f, 0.9f);
apple.make(horizontalPosition, verticalPosition, 183, 28, 28);
}
static bool checkCollision(const Quad& quad) {
auto[quadHorizontalPosition, quadVerticalPosition] = quad.getPosition();
return
((quadHorizontalPosition >= horizontalPosition - 0.09f) && (quadHorizontalPosition <= horizontalPosition + 0.09f))
&& ((quadVerticalPosition >= verticalPosition - 0.09f) && (quadVerticalPosition <= verticalPosition + 0.09f));
}
};