Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //#define PLAYER_ATK 20
- #define ATK 10
- //un gioco a turni basato su un gioco di megaman che ho trovato online
- //a turn based game based on a megaman online game
- class Game {
- public:
- //mostra menu
- //display menu
- void menu();
- //ripristina la salute del giocatore
- // restore player's health
- void heal();
- //danneggia il nemico
- // damages the enemy
- void attack();
- //controllo dei turni di gioco
- //turn game control
- int turn();
- //danneggia il giocatore
- // damages the player
- void enemy_attack();
- //il limite deve essere una combo di 5 attacchi
- // limit is a combo of 5 attacks
- void limit_attack();
- //construttore
- //constructor
- Game(int a){
- level=a;
- //salute del giocatore: 100 per ogni livello
- health=100*level;
- limit=0;
- enemy_limit=0;
- potions=3;
- //salute del nemico: 300 per ogni livello
- enemy_health=300*level;
- your_turn=true;
- };
- private:
- int level;
- int health;
- //percentuale del limite (se il limite è 100 permetti l'esecuzione del comando.
- //limit percentage (if 100 allow execution of the limit)
- int limit;
- //le pozioni devono essere tre
- // potions must be 3
- int potions;
- int enemy_limit;
- int enemy_health;
- bool your_turn;
- };
- int Game::turn(){
- //controlla se il giocatore è ancora vivo
- //check if the player is still alive
- while(health>0){
- //controlla che il nemico sia ancora vivo
- //check if the enemy is still alive
- if (enemy_health>0) {
- //controlla se è il tuo turno o quello del giocatore
- //check if it's your turn or your enemy's
- if (your_turn==true) menu();
- else enemy_attack();
- }
- //HAI VINTO!
- else {cout << "YOU WIN!" << endl;
- return 0;
- }
- //SEI MORTO!
- if (health<1) {cout << "YOU DIED" << endl;
- return 1;
- }
- }
- //C'è un errore nel sistema del controllo dei turni di gioco! (Non dovresti arrivare a questo punto)
- cout << "There was an error with the turn system of the game!";
- return 2;}
- void Game::menu(){
- cout << "HP: " << health << " " << "Enemy: " << enemy_health << endl;
- cout << endl;
- cout << "1) Attack" << endl;
- cout << "2) Potion (" << potions << ")"<< endl;
- cout << "3) Limit (" << limit << "%)" << endl;
- cout << "Choice: ";
- int x;
- cin >> x;
- switch(x){
- case 1: attack();
- case 2: heal();
- case 3: limit_attack();
- default: menu();
- }
- }
- void Game::enemy_attack(){
- int damage=ATK*level;
- //Il terzo attacco è più forte degli altri due (3 volte più forte, giusto per rendere il gioco più divertente e meno monotono
- if(enemy_limit==3) {health=health-damage*enemy_limit;
- enemy_limit=0;}
- else {enemy_limit++;
- health=health-damage;}
- your_turn=true;
- //aumenta il limite di 25
- limit=limit+25;
- }
- //BUG incasina i valori
- // BUG screws up values
- void Game::heal(){
- if (potions>0) {health=100*level;
- potions--;
- your_turn=false;
- }
- }
- void Game::attack(){
- int damage=ATK*level;
- enemy_health=enemy_health-damage;
- your_turn=false;
- }
- // il Limite è una combo di 5 attacchi
- // limit is a combo of 5 attacks
- void Game::limit_attack(){
- if(limit<100) menu();
- else {enemy_health=enemy_health-(ATK*level*5);
- limit=limit-100;}
- }
- int main() {
- Game game();
- //Chiede un numero positivo maggiore di zero per saltare a un determinato livello
- //Asks for a level number that must be positive and major of zero
- int level=0;
- do {
- cout << "Insert Level (Positive Number): ";
- cin >> level;
- }while(level<=0);
- //avvia il gioco
- //initialize game
- int result;
- do{
- Game game(level);
- result=game.turn();
- if (result==0) level++;
- } while(result==0);
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment