Skip to content
Permalink
Browse files
Random map, movement's bugged, can only move thru empty spaces, not d…
…ots.
  • Loading branch information
ivascua committed Mar 4, 2020
1 parent 5ea1e4c commit f72f9bb478edc00e4fe1389a2b91985e34aae889
Show file tree
Hide file tree
Showing 4 changed files with 447 additions and 39 deletions.
@@ -1,18 +1,4 @@
#include "Character.h"

char map[15][15] = { //static map in array
"**************",
"*@ *",
"* *",
"* *",
"* *",
"* *",
"* *",
"* *",
"* *",
"* *",
"**************"
};



@@ -4,13 +4,13 @@
#include <time.h> /* time */
#pragma once
extern std::string lastTurnsMessages;
extern char map[15][15];
extern char map[40][20];
extern int willWalkIntoSomebody;
class Character
{
public:

int health=10,xp=0,attack=4,x=1,y=1,inventory[8],maxhp=10,level=1,totalxp,gold=0;
int health=10,xp=0,attack=4,x,y,inventory[8],maxhp=10,level=1,totalxp,gold=0;

//void Movement(int Vertical, int Horizontal);

@@ -19,38 +19,38 @@ public:
int x2 = x + Horizontal; // movement on x-axis
int y2 = y + Vertical; // movement on y-axis

if (map[y][x2] == ' ') // if player moves horizontally the space before becomes an empty space and the space moved to becomes '@'
if (map[x2][y] == ' ') // if player moves horizontally the space before becomes an empty space and the space moved to becomes '@'
{
map[y][x] = ' ';
map[x][y] = ' ';
x += Horizontal;
map[y][x] = '@';
map[x][y] = '@';
}
if (map[y][x2] == 'M')
if (map[x2][y] == 'M')
{
map[y][x] = ' ';
map[x][y] = ' ';
x+=Horizontal;
map[y][x] = '@';
map[x][y] = '@';
gold+=rand()%100;
srand (time(NULL));
}



if (map[y2][x] == ' ') // if player moves vertically the space before becomes an empty space and the space moved to becomes '@'
if (map[x][y2] == ' ') // if player moves vertically the space before becomes an empty space and the space moved to becomes '@'
{
map[y][x] = ' ';
map[x][y] = ' ';
y += Vertical;
map[y][x] = '@';
map[x][y] = '@';
}
if (map[y2][x] == 'M')
if (map[x][y2] == 'M')
{
map[y][x] = ' ';
map[x][y] = ' ';
y+=Vertical;
map[y][x] = '@';
map[x][y] = '@';
gold+=rand()%100;
srand (time(NULL));
}
}


void LevelUp()
{
//oldxp=xp;
@@ -7,7 +7,7 @@
#include "Character.h"
#include "Windows.h"
#include "saveAndLoad.h"

#include "mapPrototype.h"
using namespace std;

bool gameStarted = true;
@@ -22,9 +22,10 @@ vector < pair <int, string>> vScore; //creates avector and pairs the values with
Character character;
int willWalkIntoSomebody = 0;
string lastTurnsMessages;
char map[40][20];
int main()
{
int monsterPresentHere = 0;
int monsterPresentHere = 0, playerAlreadyPlaced = 0;
cout << "Choices: \n1 start playing, 2 manual, 3 View Leaderboards What do you choose? ";
int choice = 0;
cin >> choice;
@@ -57,6 +58,24 @@ int main()
break;
}


Dungeon d(40,20);
d.generate(20);
for (int i=0; i<40; i++)
{
for (int j=0; j<20; j++)
{
map[i][j] = d.getTile(i,j);
if ((playerAlreadyPlaced == 0) && (map[i][j] == ' '))
{
character.x = i;
character.y = j;
map[i][j] = '@';
playerAlreadyPlaced = 1;
}
}
}

monster monsterArray[5];

for (int i = 0; i < 2; i++)
@@ -71,26 +90,24 @@ int main()


cout << "HP: " << character.health << "/" << character.maxhp << " BASE DAMAGE:" << character.attack << " \n";
cout << "XP: " << character.xp << " LEVEL:" << character.level << " GOLD:" << character.gold << "\n";
cout << "XP: " << character.xp << " LEVEL:" << character.level << " GOLD:" << character.gold << " x POSITION:" << character.x << " y POSITION:"<< character.y << "\n";


for (int i = 0; i < 15; i++)
for (int i = 0; i < 40; i++)
{
for (int j = 0; j < 15; j++)
for (int j = 0; j < 20; j++)
{
for (int k = 0; k < 2; k++)
{
if ((monsterArray[k].x == j) && (monsterArray[k].y == i) && (monsterArray[k].Alive == true)) monsterPresentHere = 1;
}
if (map[i][j] == '*') cout << '*';
else if (monsterPresentHere) //MAP
if (monsterPresentHere) //MAP
{
cout << 'G';
monsterPresentHere = 0;
}
else if (map[i][j] == 'M') cout << 'M';
else if (map[i][j] == ' ') cout << ' ';
else if (map[i][j] == '@') cout << '@';
else cout<<map[i][j];
}
cout << endl;
}

0 comments on commit f72f9bb

Please sign in to comment.