Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
- /*
- * main.cpp
- * Copyright (C) 2015 Reni alkimim dantas <[email protected]>
- *
- */
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- bool gameOver = false;
- using namespace std;
- //funcao principal
- int main(){
- do{
- system("clear");
- srand(time(NULL));
- int vida = 100, ataque = 7, ataqueInimigo = 0 , defesa = 5, defenderUso = 0;
- int vidaDoBicho = 0, inimigoDeAgora = 0, nomeTam = 0, acaoTam, potChoose;
- char inimigos[6][11] = {
- "Vinicius", //0
- "Reni", //1
- "Alan", //2
- "Lucas", //3
- "Higor", //4
- "Alessandro", //5
- };
- inimigoDeAgora = rand() % 5;
- if(inimigoDeAgora == 0){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- else if(inimigoDeAgora == 1){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- else if(inimigoDeAgora == 2){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- else if(inimigoDeAgora == 3){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- else if(inimigoDeAgora == 4){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- else if(inimigoDeAgora == 5){
- vidaDoBicho = 10 + rand() % 22;
- ataqueInimigo = 5 + rand() % 7;
- }
- string acao = "nada", nome = "Reni";
- cout << "Digite um nome para o personagem: " << endl;
- cin >> nome;
- nomeTam = nome.length();
- char map[10][20] = {
- "##################\n", //1
- };
- for(int display = 0; display <= 5; display++){
- cout << map[display];
- if(display == 1)
- cout << "# Vida: " << vida << " #" << endl;
- else if(display == 2)
- cout << "# Defesa: " << defesa << " #" << endl;
- else if(display == 3)
- cout << "# Ataque: " << ataque << " #\n# Espada #\n# Tetano Blade #" << endl;
- else if(display == 4 && nomeTam == 3)
- cout << "# Nome: " << nome << " #" << endl;
- else if(display == 4 && nomeTam == 4)
- cout << "# Nome: " << nome << " #" << endl;
- else if(display == 4 && nomeTam == 5)
- cout << "# Nome: " << nome << " #" << endl;
- else if(display == 4 && nomeTam == 6)
- cout << "# Nome: " << nome << " #" << endl;
- else if(display == 4 && nomeTam == 7)
- cout << "# Nome:" << nome << " #" << endl;
- else if(display == 4 && nomeTam == 8)
- cout << "# Nome:" << nome << " #" << endl;
- else if(display == 4 && nomeTam == 9)
- cout << "# Nome:" << nome << " #" << endl;
- else if(display == 4 && nomeTam == 10)
- cout << "#Nome:" << nome << " #" << endl;
- else if(display == 5)
- cout << "##################" << endl;
- }
- cout << "Exibiremos coisas para se fazer dentro do jogo e se precisar, ao decorrer da sua jornada podera ver comandos apenas digitando /comandos" << endl;
- cout << "Procurar || Atacar || Defender || Recuperar HP || Sair\nSe for recuperar HP, apenas digite hp." << endl;
- do{
- cout << "Digite uma coisa para se fazer: ";
- cin >> acao;
- if(acao == "/comandos" || acao == "/Comandos"){
- cout << "Procurar || Atacar || Defender || Recuperar HP || Sair\nSe for recuperar HP, apenas digite hp." << endl;
- system("read -p \"Pressione enter para prosseguir\" saindo");
- //system("pause"); para Windows
- }
- else if(acao == "Atacar" || acao == "atacar"){
- cout << "Primeiro voce precisa procurar um inimigo" << endl;
- system("read -p \"Pressione enter para prosseguir\" saindo");
- //system("pause"); para Windows
- }
- else if(acao == "Procurar" || acao == "procurar" && inimigos[inimigoDeAgora]){
- cout << "Procurando inimigo..." << endl;
- cout << "Voce esta de frente com " << inimigos[inimigoDeAgora] << endl;
- cout << "Vida do inimigo: " << vidaDoBicho << endl;
- cout << "Digite uma coisa para se fazer: ";
- cin >> acao;
- acaoTam = acao.length();
- do{
- if(acao == "Atacar" || acao == "atacar" && ataque < vidaDoBicho && vida >= 1){
- cout << "Atacando..." << endl;
- ataque += ataque;
- cout << "Inimigo te atacou" << endl;
- ataqueInimigo += ataqueInimigo;
- system("read -p\"Pressione enter para prosseguir\" saindo");
- if(ataque >= vidaDoBicho){
- cout << "Voce matou o inimigo" << endl;
- cout << "Voce tirou " << ataque << " de HP dele no total" << endl;
- cout << "O inimigo tirou " << ataqueInimigo << " de HP seu no total" << endl;
- cout << "Restartando o jogo..." << endl;
- system("read -p\"Pressione enter para prosseguir\" saindo");
- }
- }
- }while(ataque < vidaDoBicho);
- if(acao == "Defender" || acao == "defender" && defenderUso <= 2){
- cout << "Defendendo..." << endl;
- defenderUso++;
- ataqueInimigo -= 5;
- }
- }
- else if(acao == "HP" || acao == "hp" && potChoose == 1){
- cout << "HP recuperado" << endl;
- cout << "Usando pot basic" << endl;
- vida += 20;
- }
- else if(acao == "Sair" || acao == "sair"){
- cout << "Estamos saindo..." << endl;
- return 0;
- }
- }while(acaoTam == 0);
- }while(!gameOver);
- }
Advertisement
Add Comment
Please, Sign In to add comment