MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / save

Method save

engine/src/tile.cpp:42–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40using namespace std;
41
42void TileMap::save(const char *filename) {
43 ofstream file(filename);
44 stringstream ss;
45 if (file.is_open()) {
46 file << has_c_Map << " " << position.x << " " << position.y << " "
47 << w_tileSize.x << " " << w_tileSize.y << " " << w_depth << endl;
48 for (std::uint16_t x = 0; x < imageLayer.size(); x++) {
49 for (std::uint16_t y = 0; y < imageLayer[0].size(); y++) {
50 if (imageLayer[x][y].atileIndex != 0)
51 file << imageLayer[x][y].atileIndex << " ";
52 else
53 file << imageLayer[x][y].tileIndex << " ";
54 }
55 if (x == imageLayer.size() - 1)
56 file << -2;
57 file << endl;
58 }
59 if (has_c_Map) {
60 for (std::uint16_t x = 0; x < collisionLayer.size(); x++) {
61 for (std::uint16_t y = 0; y < collisionLayer[0].size(); y++) {
62 file << collisionLayer[x][y].tileIndex << " ";
63 }
64 file << endl;
65 }
66 }
67 file.close();
68 }
69}
70
71void TileMap::load(const char *filename, TileAtlas *ptexatlas,
72 Camera *pcamera) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected