Skip to content
Permalink
Browse files
Only saving works
And when saving, it only saves the player's (x,y) coordinates, health, attack and xp; it does not save the map.

Save by pressing P.
  • Loading branch information
ivascua committed Feb 8, 2020
1 parent a4cc9d1 commit ff8237ada62924cb26068b1c9c86af5b61a6c367
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
@@ -1,7 +1,7 @@
#include <iostream>
#include "Character.h"
#include "Windows.h"
#include "saveAndLoad.cpp"
#include "saveAndLoad.h"

using namespace std;

@@ -40,6 +40,7 @@ int main()
if (goblin.health < 0){
cout<<"You killed him lmao";
map[goblin.x][goblin.y]=' ';
character.xp+=10;
}
}
if (((character.x==goblin.x-1) && (character.y==goblin.y)) || ((character.x==goblin.x+1) && (character.y==goblin.y)) || ((character.x==goblin.x) && (character.y==goblin.y+1)) || ((character.x==goblin.x) && (character.y==goblin.y-1))){
@@ -50,7 +51,12 @@ int main()
}
if (GetAsyncKeyState(0x50)) //0x50 is the virtual key code for the p key, checks if P has been pressed
{ //Hopefully creates a .txt file
//saveGame();
int playerx=character.x;
int playery=character.y;
int playerhealth=character.health;
int playerattack=character.attack;
int playerxp=character.xp;
saveGame(playerx,playery,playerhealth,playerattack,playerxp);
}

if (GetAsyncKeyState(0x4C))
@@ -0,0 +1,17 @@
#include <iostream>
#include <fstream>
using namespace std;

void saveGame(int x, int y, int health, int attack, int xp){
ofstream f("latestSaveFile.txt");
f << x;
f << ".";
f << y;
f << ".";
f << health;
f << ".";
f << attack;
f << ".";
f << xp;
f.close();
}

0 comments on commit ff8237a

Please sign in to comment.