1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class player
{
public:
int hit ()
{
health=health-10;
if (health>10)
{
cout << "your dead innit"<<endl;
return 1;
}
}
int health;
string name;
int attackpower;
char you;
};
class baddy
{
public:
int takehit ()
{
bealth=bealth-10;
if (bealth>10)
{
cout << "you got the wanker"<<endl;
return 2;
}
}
int bealth;
string bame;
int battackpower;
int bosx;
int bosy;
char bad;
};
char z = '*';
char x = ' ';
char brdray [10] [10] = { {z,z,z,z,z,z,z,z,z,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z},
{z,x,x,x,x,x,x,x,x,z}, {z,z,z,z,z,z,z,z,z,z} };
int bosx=2;
int bosy=2;
char them = '!';
char you = 'O';
void start ();
void getbrd ();
void bdymove ();
void move ();
int posx = 5;
int posy = 5;
int main ()
{
start();
while (1)
{
getbrd();
move();
bdymove();
system ("CLS");
}
return 0;
}
void getbrd ()
{
for (int a = 0;a<10;a++)
{
for (int b =0;b<10;b++)
cout << brdray [a][b];
cout<<endl;
}
}
void move ()
{
int mv;
cout << "1 is up, 2 is down, 3 is left and 4 is right"<< endl;
cin >> mv;
char w;
char a,x,d,n;
brdray [posx] [posy] = x;
switch (mv)
{
case 1:
posx=posx-1;
break;
case 2:
posx=posx+1;
break;
case 3:
posy=posy-1;
break;
case 4:
posy=posy+1;
break;
}
if (posx||posy=z) //remove this line to.....
{
posx=5;
posy=5;
} //...this line if you want to see what the program does.
brdray [posx] [posy] =you;
}
void start()
{
brdray [posx] [posy]=you;
brdray [bosx] [bosy]=them;
}
void bdymove ()
{
brdray [bosx] [bosy] = x;
if (posx>bosx)
{
bosx++;
}
if (posx<bosx)
{
bosx--;
}
if (posy>bosy)
{
bosy++;
}
if (posy<bosy)
{
bosy--;
}
brdray [bosx] [bosy]=them;
}
|