[ADD] Saving game!
[ADD] AStar files to VC++ project.
This commit is contained in:
parent
2874786ae6
commit
cb4f7f54d1
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" ?>
|
||||
<save>
|
||||
<name>Allanis</name>
|
||||
<x>150</x>
|
||||
<y>150</y>
|
||||
<map>map</map>
|
||||
<name>Allanis</name>
|
||||
<x>572</x>
|
||||
<y>364</y>
|
||||
<map>map</map>
|
||||
</save>
|
||||
|
@ -153,6 +153,14 @@
|
||||
RelativePath="..\..\..\src\libUnuk\ApplySurface.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\libUnuk\AStar.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\libUnuk\AStar.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\libUnuk\Button.cpp"
|
||||
>
|
||||
@ -277,6 +285,10 @@
|
||||
RelativePath="..\..\..\src\libUnuk\MemManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\libUnuk\Node.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\libUnuk\NPC.cpp"
|
||||
>
|
||||
|
@ -147,6 +147,7 @@ void Game::HandleInput(void) {
|
||||
_ingameMenu.SetStatus(false);
|
||||
break;
|
||||
case ingameMenuSaveGame:
|
||||
SaveSavegame();
|
||||
break;
|
||||
case ingameMenuLoadGame:
|
||||
break;
|
||||
@ -247,8 +248,41 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
||||
void Game::SaveSavegame(void) {
|
||||
string saveFilename = "../Save/" + _saveGameID;
|
||||
|
||||
ofstream saveFile(saveFilename.c_str());
|
||||
assert(saveFile.is_open());
|
||||
TiXmlDocument doc;
|
||||
|
||||
// Write stuff.
|
||||
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
|
||||
|
||||
TiXmlElement* saveElement = new TiXmlElement("save");
|
||||
|
||||
TiXmlElement* nameElement = new TiXmlElement("name");
|
||||
TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom
|
||||
nameElement->LinkEndChild(nameText);
|
||||
|
||||
char xString[16];
|
||||
itoa(_player->GetX(), xString, 10);
|
||||
|
||||
TiXmlElement* xElement = new TiXmlElement("x");
|
||||
TiXmlText* xText = new TiXmlText(xString);
|
||||
xElement->LinkEndChild(xText);
|
||||
|
||||
char yString[16];
|
||||
itoa(_player->GetY(), yString, 10);
|
||||
|
||||
TiXmlElement* yElement = new TiXmlElement("y");
|
||||
TiXmlText* yText = new TiXmlText(yString);
|
||||
yElement->LinkEndChild(yText);
|
||||
|
||||
TiXmlElement* mapElement = new TiXmlElement("map");
|
||||
TiXmlText* mapText = new TiXmlText("map"); //TODO: replace with actual map name.
|
||||
mapElement->LinkEndChild(mapText);
|
||||
|
||||
saveElement->LinkEndChild(nameElement);
|
||||
saveElement->LinkEndChild(xElement);
|
||||
saveElement->LinkEndChild(yElement);
|
||||
saveElement->LinkEndChild(mapElement);
|
||||
|
||||
doc.LinkEndChild(decl);
|
||||
doc.LinkEndChild(saveElement);
|
||||
|
||||
doc.SaveFile(saveFilename.c_str());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user