Skip to content

Commit 5a16812

Browse files
authored
Add files via upload
1 parent 78973ad commit 5a16812

40 files changed

+4517
-20
lines changed

CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(M4OEP-mphughes-tkitazat-lbourami)
3+
4+
if (WIN32)
5+
set(FREEGLUT_INCLUDE_DIRS "C:/Program\ Files/Common\ Files/freeglut/include")
6+
set(FREEGLUT_LIBRARY_DIRS "C:/Program\ Files/Common\ Files/freeglut/lib/x64")
7+
endif (WIN32)
8+
9+
set(CMAKE_CXX_STANDARD 14)
10+
11+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
12+
13+
find_package (OpenGL REQUIRED)
14+
15+
if (APPLE)
16+
find_package(GLUT REQUIRED)
17+
endif (APPLE)
18+
19+
if (WIN32)
20+
include_directories(${OPENGL_INCLUDE_DIR} ${FREEGLUT_INCLUDE_DIRS})
21+
link_directories(${FREEGLUT_LIBRARY_DIRS})
22+
elseif (APPLE)
23+
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS})
24+
endif ()
25+
26+
file(GLOB SOURCE_FILES
27+
*.cpp
28+
*.h
29+
)
30+
31+
add_executable(graphics ${SOURCE_FILES})
32+
33+
if (WIN32)
34+
target_link_libraries (graphics ${OPENGL_LIBRARIES} freeglut)
35+
elseif (APPLE)
36+
target_link_libraries (graphics ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
37+
endif ()

README.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
# 🎯 Bird Hunter Game: Test Your Aiming Skills! 🐦
1+
Utilizing OpenGL to render the graphics, this project generates a fun game to test your aiming skills!
22

3-
## 📚 Overview
4-
This exciting and visually engaging game was developed as part of Lisa Dion's Advanced Programming class in collaboration with fellow students Maxwell Hughes and Tai Kitazato. Using OpenGL for rendering graphics, the Bird Hunter game tests your aiming skills as you strive to protect the skies from pesky birds.
3+
In this game, you play as a hunter whose job is to get as many of the birds flying above you with your gun.
54

6-
## 🎮 Gameplay
7-
In Bird Hunter, you play as a skilled hunter with a mission to shoot as many birds as possible while they fly across the screen. But be careful! If a bird reaches the left end of the screen before you can shoot it down, it's game over.
5+
If a bird reaches the end of the screen on the left before it is shot, you lose!
86

9-
The game utilizes keyboard input for controlling the action:
7+
The game utilizes keyboard input to start/end the game and to move the angle at which the gun shoots at.
108

11-
- Up and Down arrow keys: Aim the gun
12-
- Spacebar: Shoot bullets at the birds
9+
The up and down keys are used to aim the gun and the space bar is to shoot bullets at the birds.
1310

14-
## 🦜 Dynamic Birds and Clouds ☁️
15-
Birds and clouds are drawn using OpenGL, each with a timer that determines how long they remain on the screen and when they should update. The birds have different speeds, and as the game progresses, they become faster, increasing the difficulty and keeping you on your toes!
11+
The birds + clouds are drawn with OpenGL and each have a timer as to how long it will stay on screen and how to update.
1612

17-
## 🎨 Graphics Classes
18-
The game employs four graphics classes to create objects of various types, such as `Rect`, `Circle`, `FreeShape`, and `Shape`. These classes are used to generate the game's visuals, including:
13+
The birds each have their own speed and all progressively speed up as the game goes on to increase the difficulty!
1914

20-
- Background
21-
- Birds
22-
- Gun
23-
- Bullets
24-
- Bird falling animation
25-
- User prompt screens
15+
There are 4 graphic classes used to create objects of type: Rect, Circle, FreeShape, and Shape to draw the game.
2616

27-
## 🏆 Set Your High Score!
28-
Ready to put your aiming skills to the test? Dive into the Bird Hunter game and become the ultimate bird conservationist! Set your own high score and challenge your friends to see who can claim the title of the best bird hunter!
17+
These classes are used to produce the background, birds, gun, bullets, bird falling animation, and user prompt screens.
18+
19+
Go ahead and set your own high score and be the best bird conservationist!

circle.cpp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#include "circle.h"
2+
#include "graphics.h"
3+
4+
Circle::Circle() : Shape(), radius(0) {
5+
}
6+
7+
Circle::Circle(double radius) : Shape() {
8+
setRadius(radius);
9+
}
10+
11+
Circle::Circle(color fill) : Shape(fill), radius(0) {
12+
}
13+
14+
Circle::Circle(point2D center) : Shape(center), radius(0) {
15+
}
16+
17+
Circle::Circle(color fill, point2D center) : Shape(fill, center), radius(0) {
18+
}
19+
20+
Circle::Circle(double red, double green, double blue, double alpha) : Shape(red, green, blue, alpha), radius(0) {
21+
}
22+
23+
Circle::Circle(double x, double y) : Shape(x, y), radius(0) {
24+
}
25+
26+
Circle::Circle(double red, double green, double blue, double alpha, double x, double y) : Shape(red, green, blue, alpha, x, y), radius(0) {
27+
}
28+
29+
Circle::Circle(color fill, double x, double y) : Shape(fill, x, y), radius(0) {
30+
}
31+
32+
Circle::Circle(double red, double green, double blue, double alpha, point2D center) : Shape(red, green, blue, alpha, center), radius(0) {
33+
}
34+
35+
Circle::Circle(color fill, double radius) : Shape(fill) {
36+
setRadius(radius);
37+
}
38+
39+
Circle::Circle(point2D center, double radius) : Shape(center) {
40+
setRadius(radius);
41+
}
42+
43+
Circle::Circle(color fill, point2D center, double radius) : Shape(fill, center) {
44+
setRadius(radius);
45+
}
46+
47+
Circle::Circle(double red, double green, double blue, double alpha, double radius) : Shape(red, green, blue, alpha) {
48+
setRadius(radius);
49+
}
50+
51+
Circle::Circle(double x, double y, double radius) : Shape(x, y) {
52+
setRadius(radius);
53+
}
54+
55+
Circle::Circle(double red, double green, double blue, double alpha, double x, double y, double radius) : Shape(red, green, blue, alpha, x, y) {
56+
setRadius(radius);
57+
}
58+
59+
Circle::Circle(color fill, double x, double y, double radius) : Shape(fill, x, y) {
60+
setRadius(radius);
61+
}
62+
63+
Circle::Circle(double red, double green, double blue, double alpha, point2D center, double radius) : Shape(red, green, blue, alpha, center) {
64+
setRadius(radius);
65+
}
66+
67+
double Circle::getRadius() const {
68+
return radius;
69+
}
70+
71+
double Circle::getLeftX() const {
72+
return center.x - radius;
73+
}
74+
75+
double Circle::getRightX() const {
76+
return center.x + radius;
77+
}
78+
79+
double Circle::getTopY() const {
80+
return center.y - radius;
81+
}
82+
83+
double Circle::getBottomY() const {
84+
return center.y + radius;
85+
}
86+
87+
void Circle::setRadius(double r) {
88+
if (r < 0) {
89+
r = 0;
90+
}
91+
radius = r;
92+
}
93+
94+
void Circle::changeRadius(double delta) {
95+
setRadius(radius + delta);
96+
}
97+
98+
void Circle::draw() const {
99+
// Set drawing color to fill color
100+
glColor4f(fill.red, fill.green, fill.blue, fill.alpha);
101+
// Draw circle as Triangle Fan
102+
glBegin(GL_TRIANGLE_FAN);
103+
// Draw center point
104+
glVertex2i(center.x, center.y);
105+
// Draw points on edge of circle
106+
for (double i = 0; i < 2.0*PI+0.05; i += (2.0*PI)/360.0) {
107+
glVertex2i(center.x + (radius * cos(i)),
108+
center.y + (radius * sin(i)));
109+
}
110+
// End Triangle Fan
111+
glEnd();
112+
}

circle.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef GRAPHICSEXAMPLES_CIRCLE_H
2+
#define GRAPHICSEXAMPLES_CIRCLE_H
3+
4+
#include "shape.h"
5+
6+
class Circle : public Shape {
7+
private:
8+
double radius;
9+
public:
10+
/* Constructors */
11+
Circle();
12+
explicit Circle(double radius);
13+
explicit Circle(color fill);
14+
explicit Circle(point2D center);
15+
Circle(color fill, point2D center);
16+
Circle(double red, double green, double blue, double alpha);
17+
Circle(double x, double y);
18+
Circle(double red, double green, double blue, double alpha, double x, double y);
19+
Circle(color fill, double x, double y);
20+
Circle(double red, double green, double blue, double alpha, point2D center);
21+
Circle(color fill, double radius);
22+
Circle(point2D center, double radius);
23+
Circle(color fill, point2D center, double radius);
24+
Circle(double red, double green, double blue, double alpha, double radius);
25+
Circle(double x, double y, double radius);
26+
Circle(double red, double green, double blue, double alpha, double x, double y, double radius);
27+
Circle(color fill, double x, double y, double radius);
28+
Circle(double red, double green, double blue, double alpha, point2D center, double radius);
29+
30+
/* Destructor */
31+
virtual ~Circle() = default;
32+
33+
/* Getters */
34+
double getRadius() const;
35+
double getLeftX() const override;
36+
double getRightX() const override;
37+
double getTopY() const override;
38+
double getBottomY() const override;
39+
40+
/* Setter */
41+
void setRadius(double r);
42+
void changeRadius(double delta);
43+
44+
/* Draw */
45+
void draw() const override;
46+
47+
};
48+
49+
#endif //GRAPHICSEXAMPLES_CIRCLE_H

0 commit comments

Comments
 (0)