summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE21
-rw-r--r--README.md14
-rw-r--r--UML Diagram.pdfbin42670 -> 0 bytes
-rw-r--r--src/game.cpp45
-rw-r--r--src/game.h1
5 files changed, 35 insertions, 46 deletions
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index bc341d0..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020 Logan Hunt
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/README.md b/README.md
deleted file mode 100644
index 2dba81e..0000000
--- a/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Asteroids-CPP
-The game asteroids in c++ using the simplified drawing library provided by my school.
-
-## Requirements
-
-* libglut-dev
-* g++
-* make
-
-## Running
-
-All that is needed to run is a simple ```make```, and then run the game with ```./a.out```
-
-[![2020-06-30-20-24-32-1.gif](https://i.postimg.cc/k4ZNhdKw/2020-06-30-20-24-32-1.gif)](https://postimg.cc/zbCRV6dR)
diff --git a/UML Diagram.pdf b/UML Diagram.pdf
deleted file mode 100644
index 0396c36..0000000
--- a/UML Diagram.pdf
+++ /dev/null
Binary files differ
diff --git a/src/game.cpp b/src/game.cpp
index a2aa491..f7d4054 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -26,7 +26,7 @@ Game :: Game ( const Point &tl , const Point &br ) : topLeft ( tl ) , bottomRigh
vector<Rock *> Game :: createRocks()
{
vector<Rock *> initRocks;
- for ( int i = 0; i < random ( 5 , 8 ); i++ )
+ for ( int i = 0; i < random ( 5 + 2 * this->level , 8 + 2 * this->level ); i++ )
{
Point rockPoint = Point ( random( -190 , 190 ) , random ( -190 , 190 ) );
Velocity velocity;
@@ -136,14 +136,16 @@ void Game :: cleanUpZombies()
bullets.erase( bullets.begin() + i );
}
}
- for ( int i = 0; i < rocks.size(); i++ )
- {
- if ( !rocks[i]->isAlive() )
- {
- delete rocks[i];
- rocks[i] = NULL;
- rocks.erase( rocks.begin() + i );
- }
+ if (rocks.size() > 0) {
+ for ( int i = 0; i < rocks.size(); i++ )
+ {
+ if ( !rocks[i]->isAlive() )
+ {
+ delete rocks[i];
+ rocks[i] = NULL;
+ rocks.erase( rocks.begin() + i );
+ }
+ }
}
}
@@ -209,6 +211,14 @@ void Game :: draw ( const Interface &ui )
drawBullets();
drawNumber ( Point ( -170 , 170 ) , (int) ship->getFuel() );
drawText ( Point ( -170 , 180 ) , "FUEL:" );
+ drawNumber ( Point (-170, 130) , (int) level);
+ drawText ( Point(-170, 140), "LEVEL:");
+ if (!ship->isAlive()) {
+ drawText( Point ( -90 , 0 ) , "Play again? (space to continue)");
+ }
+ if (rocks.size() == 0 && ship->isAlive()) {
+ drawText( Point ( -90 , 0 ) , "Press space to continue to next level ");
+ }
}
// Draw rocks
@@ -241,7 +251,7 @@ void Game :: drawBullets()
// Handle in-game input
void Game::handleInput(const Interface & ui)
{
- if ( ship->isAlive() )
+ if ( ship->isAlive() && rocks.size() > 0 )
{
if ( ui.isUp() )
{
@@ -274,5 +284,18 @@ void Game::handleInput(const Interface & ui)
ship->setThrusting ( false );
}
}
-
+ else if ( !ship->isAlive() && rocks.size() > 0){
+ if ( ui.isSpace() ) {
+ rocks = createRocks();
+ ship = new Ship ( Point() );
+ level = 0;
+ }
+ }
+ else if ( ship->isAlive() && rocks.size() == 0) {
+ if ( ui.isSpace() ) {
+ rocks = createRocks();
+ ship = new Ship ( Point() );
+ level++;
+ }
+ }
}
diff --git a/src/game.h b/src/game.h
index d64efc6..943ed63 100644
--- a/src/game.h
+++ b/src/game.h
@@ -26,6 +26,7 @@ private:
vector<Rock *> rocks;
vector<Bullet *> bullets;
Ship* ship;
+ int level = 0;
float getClosestDistance( const FlyingObject &obj1 , const FlyingObject &obj2 ) const;