Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- class Blocks {
- public:
- int x;
- int y;
- void Sand();
- void Status();
- private:
- int w,z;
- };
- char world[15][15] =
- {
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
- {'W','W','W','W','W','W','W','W','W','W ','W','W','W','W','W'}
- };
- void drawWorld();
- void Blocks::Sand()
- {
- w = x;
- z = y;
- if (world[z+1][w] == ' ')
- {
- while(world[z+1][w] == ' ')
- z++;
- world[z][w] = 'S';
- drawWorld();
- //z++;
- }
- else
- cout << "no room for sand" << endl;
- }
- void Blocks::Status()
- {
- Blocks::Sand();
- }
- void drawWorld()
- {
- Blocks pos;
- for(pos.y = 0; pos.y < 15; pos.y++) // build world
- {
- cout << endl;
- for (pos.x = 0; pos.x < 15; pos.x++)
- {
- cout << world[pos.y][pos.x];
- }
- }
- }
- int main()
- {
- Blocks pos;
- char i=1;
- int dirt=0; // joe
- int health=100;
- world[0][0]=' '; // sets spawn
- pos.x = 0;
- pos.y = 0;
- do
- {
- cout << endl << endl << endl;
- cout << "===============" << endl;
- cout << "Dirt Blocks: " << dirt << endl;
- drawWorld(); // create world
- cout << endl << world[pos.y][pos.x];
- cout << endl;
- cin >> i;
- switch(i)
- {
- case'w':
- if (pos.y == 0)
- cout << "You can't climb any higher!";
- else
- {
- pos.y--;
- cout << "Moved up";
- world[pos.y][pos.x] = ' ';
- }
- break;
- case's':
- if (pos.y == 14)
- cout << "you can't dig that low, ya doofus!" << endl;
- else
- {
- pos.y++;
- cout << "Moved down" << endl;
- world[pos.y][pos.x] = ' ';
- }
- break;
- case'S':
- if (world[pos.y+1][pos.x] == 'W')
- {
- cout << "dug dirt!" << endl;
- world[pos.y+1][pos.x] = ' ';
- dirt++;
- }
- else
- cout << "nothing to dig!" << endl;
- break;
- case'd':
- if (pos.x == 14)
- cout << "You hit an unbreakable wall you cannot break through" << endl;
- else
- {
- pos.x++;
- cout << "Moved Right" << endl;
- world[pos.y][pos.x] = ' ';
- }
- break;
- case'a':
- if (pos.x == 0)
- cout << "You hit an unbreakable wall you cannot break through" << endl;
- else
- {
- pos.x--;
- cout << "Moved Right" << endl;
- world[pos.y][pos.x] = ' ';
- }
- break;
- case'z':
- if(world[pos.y+1][pos.x] == ' ')
- pos.Sand();
- break;
- default:
- cout << "dont be hurr";
- }
- }while (health != 0);
- cin >> i;
- return 0;
- }
Add Comment
Please, Sign In to add comment