diff --git a/src/main.cpp b/src/main.cpp index dc0fd86..c715447 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include "entities/entitybase.hpp" #include "render/textures.hpp" #include "tiles/tilebase.hpp" +#include "saving/saving.hpp" #include #include @@ -19,6 +20,12 @@ void PlayerController(Entity &e, float deltatime) { e.rect.y += acceleration.y * 100 * deltatime; } +struct Tiles { + int chunkx; + int chunky; + int tileindex; +}; + int main() { int screenWidth = 1200; int screenHeight = 800; @@ -97,6 +104,7 @@ int main() { gamemap.layers[1].chunks[Coordinate{chunkx, chunky}].tiles[tileindex].spriteid = 1; + } @@ -111,12 +119,22 @@ int main() { player.Draw(); - EndMode2D(); EndDrawing(); } // UnloadTexture() and CloseWindow() are called automatically. + + std::cout << "Saving Data...\n"; + + std::cout << "Player is at: " << player.rect.x << ", " << player.rect.y << "\n"; + std::cout << "chunkx: " << chunkx << "\n"; + std::cout << "chunky: " << chunky << "\n"; + // std::cout << "tileindex: " << tileindex << "\n"; + + SaveGame(player.rect.x, player.rect.y); + + std::cout << "Data Saved!\n"; return 0; } diff --git a/src/saving/saving.cpp b/src/saving/saving.cpp new file mode 100644 index 0000000..7537b65 --- /dev/null +++ b/src/saving/saving.cpp @@ -0,0 +1,11 @@ +#include +#include +using namespace std; + +void SaveGame(int x, int y) { + ofstream outfile("save.json"); + + outfile << x << " " << y << std::endl; + + outfile.close(); +} diff --git a/src/saving/saving.hpp b/src/saving/saving.hpp new file mode 100644 index 0000000..b994f7c --- /dev/null +++ b/src/saving/saving.hpp @@ -0,0 +1,7 @@ +#ifndef SAVES_HPP +#define SAVES_HPP + +void SaveGame(int x, int y); +void LoadGame(int &x, int &y); + +#endif