-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBumper.cpp
More file actions
42 lines (37 loc) · 930 Bytes
/
Bumper.cpp
File metadata and controls
42 lines (37 loc) · 930 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Bumper.h"
#include <cmath>
Bumper::Bumper(double x, double y, double width)
{
this->x = x;
this->y = y;
this->width = width;
}
int Bumper::calculateCollision(double playerX, double playerY)
{
if (!bbox(playerX, playerY, x, y, width * 2, width * 2))
{
return BUMPER_NO_COLLISION;
}
else
{
if (abs(playerX - (x + width / 2)) < abs(playerY - (y + width / 2)))
return BUMPER_X_COLLISION;
else
return BUMPER_Y_COLLISION;
}
}
void Bumper::draw()
{
glPushMatrix();
glColor3f(1.0f, 0.75f, .8f);
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(x, y, 0.0f); // Top Left
glVertex3f(x + width, y, 0.0f); // Top Right
glVertex3f(x + width, y + width, 0.0f); // Bottom Right
glVertex3f(x,y + width, 0.0f); // Bottom Left
glEnd();
glPopMatrix();
}
Bumper::~Bumper()
{
}