$50

Blobs Attack! C++

0 ratings
Pay

Blobs Attack! C++

$50
0 ratings

MAIN FILE
#include "Game.hpp"

#include <cstdlib>

#include <ctime>

#include <iomanip>

#include <iostream>

 

using namespace std;

 

/*******************************************************************************

 * Description:

 * Starting point of the program. Seed the RNG using the current system time.

 * Starts the game.

 *

 * Input:

 * N/A

 *

 * Output:

 * An integer that signals the exit code to the operating system (OS)

*******************************************************************************/

 

int main() {

    // seed the RNG

    srand(time(nullptr));

 

    // play the game

    Game blobbyGame;

    cout << "\n\n\n";

    cout << setfill('+') << setw(50) << "\n";

    cout << "Let the battle commence!!!\n";

    cout << setfill('+') << setw(50) << "\n";

    cout << "\n\n\n";

    blobbyGame.play();

 

    // terminate

    return 0;

}

 

 

HPP FILE

#ifndef GAME_HPP

#define GAME_HPP

 

#include "Blob.hpp"

 

class Game {

    private:

        // how many blobs are there per team

        unsigned teamSize;

 

        // a team is a dynamic array of dynamic blobs (hence, double pointer)

        Blob** teamOne;

        Blob** teamTwo;

 

        // helper methods for the game

        void createTeam(bool);

        void outcome(Blob*, Blob*);

 

    public:

        // constructor

        Game();

 

        // destructor

        ~Game();

 

        // lets play Blobs Attack!

        void play();

};

 

#endif

 

CPP FILE

#include "AttackBlob.hpp"

#include "DefenseBlob.hpp"

#include "Game.hpp"

#include "SpeedBlob.hpp"

#include <iomanip>

#include <iostream>

 

using namespace std;

 

Game::Game() {

    // TODO

}

 

Game::~Game() {

    // TODO

}

 

void Game::createTeam(bool teamFlag) {

    // TODO

}

 

void Game::outcome(Blob* currentBlob, Blob* otherBlob) {

    // TODO

}

 

void Game::play() {

    // variables

    bool gameOverFlag = false;

    unsigned currentPlayerIndex = 0, otherPlayerIndex = 0, tmp = 0;

    Blob currentPlayer = nullptr, otherPlayer = nullptr;

    string pause;

 

    // randomly decide which team is going first

    if (rand() % 2 == 0) {

        currentPlayer = teamOne;

        otherPlayer   = teamTwo;

    }

    else {

        currentPlayer = teamTwo;

        otherPlayer   = teamOne;

    }

 

    // game loop

    while (!gameOverFlag) {

        // let the two blobs battle each other

        outcome(currentPlayer[currentPlayerIndex], otherPlayer[otherPlayerIndex]);

 

        // display team reports

        cout << "Team One Status:\n";

        for (unsigned i = 0; i < teamSize; i++) {

            cout << '\t' << *teamOne[i];

        }

        cout << "\nTeam Two Status:\n";

        for (unsigned i = 0; i < teamSize; i++) {

            cout << '\t' << *teamTwo[i];

        }

 

        // TODO: is the game over?

 

        // TODO: update the current team members

 

        // alternate the players

        currentPlayer = (currentPlayer == teamOne) ? teamTwo : teamOne;

        otherPlayer   = (otherPlayer   == teamOne) ? teamTwo : teamOne;

 

        // pause

        cout << "\nHit enter to start the next round";

        getline(cin, pause);

        cout << endl << endl;

    }

 

    // count how many blobs fainted for each team

    currentPlayerIndex = otherPlayerIndex = 0;

    for (unsigned i = 0; i < teamSize; i++) {

        if (teamOne[i]->getHp() == 0) {

            currentPlayerIndex++;

        }

        if (teamTwo[i]->getHp() == 0) {

            otherPlayerIndex++;

        }

    }

 

    // determine the winner

    cout << "\n\n\n";

    cout << setfill('+') << setw(50) << "\n";

    if (currentPlayerIndex < otherPlayerIndex) {

        cout << "Player 1 has won this match!\n";

    }

    else {

        cout << "Player 2 has won this match!\n";

    }

    cout << setfill('+') << setw(50) << "\n";

}

OUTPUT

Welcome player 1! You are about to choose your team members.

Choosing team member #1
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 2
Enter the name for this team member: Shuckle

Choosing team member #2
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 3
Enter the name for this team member: Flygon

Choosing team member #3
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 1
Enter the name for this team member: Kleavor


Welcome player 2! You are about to choose your team members.

Choosing team member #1
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 1
Enter the name for this team member: Keldeo

Choosing team member #2
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 1
Enter the name for this team member: Garchomp

Choosing team member #3
Enter 1 for AttackBlob, 2 for DefenseBlob, or 3 for SpeedBlob: 2
Enter the name for this team member: Stonjourner

 

+++++++++++++++++++++++++++++++++++++++++++++++++
Let the battle commence!!!
+++++++++++++++++++++++++++++++++++++++++++++++++

 

Keldeo used Blobby Hands and hits Shuckle for 1 points!
Team One Status:
Shuckle has 26 HP
Flygon has 16 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 14 HP
Stonjourner has 32 HP

Hit enter to start the next round


Flygon used Blobby Hands and hits Garchomp for 3 points!
Team One Status:
Shuckle has 26 HP
Flygon has 16 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 32 HP

Hit enter to start the next round


Kleavor is a ninja and was able to dodge Stonjourner completely.
Team One Status:
Shuckle has 26 HP
Flygon has 16 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 32 HP

Hit enter to start the next round


Keldeo is a ninja and was able to dodge Shuckle completely.
Team One Status:
Shuckle has 26 HP
Flygon has 16 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 32 HP

Hit enter to start the next round


Garchomp used Blobby Hands and hits Flygon for 9 points!
Team One Status:
Shuckle has 26 HP
Flygon has 7 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 32 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Stonjourner for 8 points!
Team One Status:
Shuckle has 26 HP
Flygon has 7 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 24 HP

Hit enter to start the next round


Keldeo used Blobby Hands and hits Shuckle for 2 points!
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 11 HP
Stonjourner has 24 HP

Hit enter to start the next round


Flygon used Blobby Hands and hits Garchomp for 3 points!
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 14 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 24 HP

Hit enter to start the next round


Stonjourner was unable to pierce Kleavor fully :(
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 24 HP

Hit enter to start the next round


Keldeo is a ninja and was able to dodge Shuckle completely.
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 24 HP

Hit enter to start the next round


Flygon is a ninja and was able to dodge Garchomp completely.
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 24 HP

Hit enter to start the next round


Kleavor was unable to pierce Stonjourner fully :(
Team One Status:
Shuckle has 24 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 23 HP

Hit enter to start the next round


Keldeo used Blobby Hands and hits Shuckle for 2 points!
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 8 HP
Stonjourner has 23 HP

Hit enter to start the next round


Flygon used Blobby Hands and hits Garchomp for 1 points!
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 13 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 7 HP
Stonjourner has 23 HP

Hit enter to start the next round


Stonjourner was unable to pierce Kleavor fully :(
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 13 HP
Garchomp has 7 HP
Stonjourner has 23 HP

Hit enter to start the next round


Shuckle used Blobby Hands and hits Keldeo for 1 points!
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 7 HP
Stonjourner has 23 HP

Hit enter to start the next round


Flygon is a ninja and was able to dodge Garchomp completely.
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 7 HP
Stonjourner has 23 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Stonjourner for 6 points!
Team One Status:
Shuckle has 22 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 7 HP
Stonjourner has 17 HP

Hit enter to start the next round


Keldeo used Blobby Hands and hits Shuckle for 4 points!
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 7 HP
Stonjourner has 17 HP

Hit enter to start the next round


Flygon used Blobby Hands and hits Garchomp for 5 points!
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Kleavor is a ninja and was able to dodge Stonjourner completely.
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 12 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Shuckle used Blobby Hands and hits Keldeo for 3 points!
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Flygon is a ninja and was able to dodge Garchomp completely.
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Stonjourner is a ninja and was able to dodge Kleavor completely.
Team One Status:
Shuckle has 18 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Keldeo was unable to pierce Shuckle fully :(
Team One Status:
Shuckle has 17 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 2 HP
Stonjourner has 17 HP

Hit enter to start the next round


Flygon used Blobby Hands and hits Garchomp for 1 points!
Team One Status:
Shuckle has 17 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 17 HP

Hit enter to start the next round


Kleavor is a ninja and was able to dodge Stonjourner completely.
Team One Status:
Shuckle has 17 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 17 HP

Hit enter to start the next round


Keldeo is a ninja and was able to dodge Shuckle completely.
Team One Status:
Shuckle has 17 HP
Flygon has 7 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 17 HP

Hit enter to start the next round


Garchomp used Blobby Hands and hits Flygon for 10 points!
Flygon is unable to battle!!!
Team One Status:
Shuckle has 17 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 17 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Stonjourner for 6 points!
Team One Status:
Shuckle has 17 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 11 HP

Hit enter to start the next round


Keldeo was unable to pierce Shuckle fully :(
Team One Status:
Shuckle has 16 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 1 HP
Stonjourner has 11 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Garchomp for 9 points!
Garchomp is unable to battle!!!
Team One Status:
Shuckle has 16 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 0 HP
Stonjourner has 11 HP

Hit enter to start the next round


Stonjourner was unable to pierce Shuckle fully :(
Team One Status:
Shuckle has 15 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 9 HP
Garchomp has 0 HP
Stonjourner has 11 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Keldeo for 8 points!
Team One Status:
Shuckle has 15 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 1 HP
Garchomp has 0 HP
Stonjourner has 11 HP

Hit enter to start the next round


Stonjourner was unable to pierce Shuckle fully :(
Team One Status:
Shuckle has 14 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 1 HP
Garchomp has 0 HP
Stonjourner has 11 HP

Hit enter to start the next round


Kleavor used Blobby Hands and hits Keldeo for 8 points!
Keldeo is unable to battle!!!
Team One Status:
Shuckle has 14 HP
Flygon has 0 HP
Kleavor has 12 HP

Team Two Status:
Keldeo has 0 HP
Garchomp has 0 HP
Stonjourner has 11 HP

 

+++++++++++++++++++++++++++++++++++++++++++++++++
Player 1 has won this match!
+++++++++++++++++++++++++++++++++++++++++++++++++

Pay

Blob.hpp, Blob.cpp, AttackBlob.hpp, AttackBlob.cpp, DefenseBlob.hpp, DefenseBlob.cpp, Game.hpp, Game.cpp, SpeedBlob.hpp, SpeedBlob.hpp, Main.cpp, and, screenshot

Blob.hpp
Class
Blob.cpp
Implementation
AttackBlob.hpp
Class
AttackBlob.cpp
Implementation
DefenseBlob.hpp
Class
DefenseBlob.cpp
Implementation
SpeedBlob.hpp
Class
SpeedBlob.cpp
Implementation
Screenshot
Demonstration
Game.hpp
Class
Game.cpp
Implementation
Copy product URL