Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <windows.h>
- #include <conio.h>
- using namespace std;
- int Nr_Inamici = 2;
- int morti = 0;
- int N = 5;
- char Tabla[100][100];
- const int Tick = 10000;
- ///Player setting
- const int D_Max_Player_Heal = 100;
- const int D_Max_Player_Damage = 10;
- const int D_Player_i = 1;
- const int D_Player_j = 1;
- ///Inamic TIP 1
- const int D_Max_T1_Heal = 50;
- const int D_Max_T1_Damage = 2;
- struct Player
- {
- int i = D_Player_i;
- int j = D_Player_j;
- int heal = D_Max_Player_Heal;
- int damage = D_Max_Player_Damage;
- };
- struct InamiciTip1
- {
- int i, j;
- int heal = D_Max_T1_Heal;
- int damage = D_Max_T1_Damage;
- bool mort = false;
- } A[3];
- Player P;
- void Creeaza()
- {
- for(int i = 1; i <= N; i++)
- for(int j = 1; j <= N; j++)
- Tabla[i][j] = '-';
- Tabla[1][1] = 'P';
- return;
- }
- bool verificare(int i, int j)
- {
- return (i == N && j == N);
- }
- void A_T()
- {
- system("cls");
- for(int i = 1; i <= N; i++)
- {
- for(int j = 1; j <= N; j++)
- cout << Tabla[i][j] << ' ';
- cout << '\n';
- }
- cout << "Heal: " << P.heal;
- }
- int FindCoord(int i, int j)
- {
- for(int k = 0; k < Nr_Inamici; k++)
- if(A[k].i == i && A[k].j == j)
- return k;
- }
- void G_Key()
- {
- int c = 0;
- while(!_kbhit())
- {
- ///ASTA II MISCAREA INAMICIILOR
- ///E FOARTE PROASTA SO INCA MAI LUCREZ LA EA
- /**c += 2;
- if(c == Tick)
- {
- c = 0;
- char dir = rand() % 4;
- /// 0 -> w
- /// 1 -> a
- /// 2 -> s
- /// 3 -> d
- for(int i = 0; i < Nr_Inamici; i++)
- {
- if(A[i].mort == false)
- {
- Tabla[A[i].i][A[i].j] = '-';
- switch(dir)
- {
- case 0:
- if(A[i].i > 1)
- A[i].i--;
- else
- dir++;
- break;
- case 1:
- if(A[i].j > 1)
- A[i].j--;
- else
- dir++;
- break;
- case 2:
- if(A[i].i < N)
- A[i].i++;
- else
- dir++;
- break;
- case 3:
- if(A[i].j < N)
- A[i].j++;
- else
- dir++;
- break;
- }
- dir %= 4;
- int di[] = {+1, -1, +0, +0};
- int dj[] = {+0, +0, +1, -1};
- bool oke = false;
- for(int z = 0; z < 4; z++)
- {
- int nexti = A[i].i + di[z];
- int nextj = A[i].j + dj[z];
- if(nexti == P.i && nextj == P.j)
- {
- cout << "Ti am dat Damage!!!\n";
- P.heal -= rand() % A[i].damage + 1, oke = true;}
- }
- if(oke == false)
- Tabla[A[i].i][A[i].j] = 'I';
- }
- }
- }*/
- }
- int I = P.i;
- int J = P.j;
- if(_kbhit())
- switch(_getch())
- {
- case 'w':
- if(P.i > 1)
- P.i--;
- break;
- case 'a':
- if(P.j > 1)
- P.j--;
- break;
- case 's':
- if(P.i < N)
- P.i++;
- break;
- case 'd':
- if(P.j < N)
- P.j++;
- break;
- }
- if(Tabla[P.i][P.j] == 'I')
- {
- int k = FindCoord(P.i, P.j);
- while(A[k].heal > 0)
- {
- int Damage_To_I = rand() % P.damage + 1;
- int Damage_From_I = rand() % A[k].damage;
- P.heal -= Damage_From_I;
- A[k].heal -= Damage_To_I;
- if(P.heal < 0)
- exit(0);
- }
- A[k].mort = true;
- morti++;
- Tabla[P.i][P.j] = 'P';
- }
- }
- int main()
- {
- srand(time(0));
- cout << "Dimensiunea tablei de joc (maxim 100): ";
- cin >> N;
- cout << "Nr total de inamici (maxim " << N * N - 1 << "): ";
- cin >> Nr_Inamici;
- cout << "Pozitiile inamicilor (i, j): ";
- Creeaza();
- for(int i = 0; i < Nr_Inamici; i++)
- {
- cin >> A[i].i >> A[i].j;
- Tabla[A[i].i][A[i].j] = 'I';
- }
- A_T();
- START:
- do
- {
- Tabla[P.i][P.j] = '-';
- G_Key();
- Tabla[P.i][P.j] = 'P';
- A_T();
- }
- while( (P.i != N || P.j != N));
- if(morti != Nr_Inamici)
- goto START;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement