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