generated from sigonasr2/CPlusPlusProjectTemplate
Consolidate all the tile data into one giant mega array
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
7d6a461c07
commit
d75e381d65
Binary file not shown.
10
TMXParser.h
10
TMXParser.h
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
#include "pixelGameEngine.h"
|
#include <sstream>
|
||||||
#include <strstream>
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
using namespace olc;
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
struct XMLTag{
|
struct XMLTag{
|
||||||
std::string tag;
|
std::string tag;
|
||||||
@ -39,6 +40,7 @@ struct XMLTag{
|
|||||||
|
|
||||||
struct LayerTag{
|
struct LayerTag{
|
||||||
XMLTag tag;
|
XMLTag tag;
|
||||||
|
public:
|
||||||
std::vector<std::vector<int>> tiles;
|
std::vector<std::vector<int>> tiles;
|
||||||
std::string str() {
|
std::string str() {
|
||||||
std::string displayStr=tag.tag+"\n"+tag.FormatTagData(tag.data);
|
std::string displayStr=tag.tag+"\n"+tag.FormatTagData(tag.data);
|
||||||
|
30
main.cpp
30
main.cpp
@ -1,28 +1,32 @@
|
|||||||
#define OLC_PGE_APPLICATION
|
|
||||||
#include "pixelGameEngine.h"
|
|
||||||
#include <strstream>
|
#include <strstream>
|
||||||
#include "TMXParser.h"
|
#include "TMXParser.h"
|
||||||
|
|
||||||
using namespace olc;
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
TMXParser parser("00_test_room.tmx");
|
TMXParser parser("00_test_room.tmx");
|
||||||
Map mData = parser.GetData();
|
Map mData = parser.GetData();
|
||||||
XMLTag mapTag = mData.MapData;
|
XMLTag mapTag = mData.MapData;
|
||||||
double version = mapTag.GetDouble("version");
|
double version = mapTag.GetDouble("version");
|
||||||
int width = mapTag.GetInteger("width");
|
|
||||||
int height = mapTag.GetInteger("height");
|
|
||||||
bool isInfinite = mapTag.GetBool("infinite");
|
bool isInfinite = mapTag.GetBool("infinite");
|
||||||
std::cout<<version<<": "<<width<<","<<height<<","<<isInfinite;
|
|
||||||
|
|
||||||
LayerTag layerTag = mData.LayerData[0];
|
int TOTAL_LAYER_COUNT = mapTag.GetInteger("nextlayerid");
|
||||||
|
int X_TILES_COUNT = mapTag.GetInteger("width");
|
||||||
|
int Y_TILES_COUNT = mapTag.GetInteger("height");
|
||||||
|
|
||||||
XMLTag layer0Tag = layerTag.tag;
|
std::vector<std::vector<std::vector<int>>> tileData;
|
||||||
int layerID=layer0Tag.GetInteger("id");
|
for (int layer=0;layer<TOTAL_LAYER_COUNT-1;layer++) {
|
||||||
|
std::vector<std::vector<int>> mapTileGrid;
|
||||||
|
for (int y=0;y<Y_TILES_COUNT;y++) {
|
||||||
|
std::vector<int> row;
|
||||||
|
for (int x=0;x<X_TILES_COUNT;x++) {
|
||||||
|
row.push_back(mData.LayerData[layer].tiles[y][x]);
|
||||||
|
}
|
||||||
|
mapTileGrid.push_back(row);
|
||||||
|
}
|
||||||
|
tileData.push_back(mapTileGrid);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout<<"\n"<<layerID;
|
printf("Layer 6, Row 116, Col 44 (X:43,Y:117) - %d",tileData[4][116][44]);
|
||||||
|
|
||||||
std::cout<<"\n"<<layerTag.tiles[8][6];
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
2
sig
2
sig
@ -3,7 +3,7 @@ export AUTO_UPDATE=true
|
|||||||
source utils/define.sh
|
source utils/define.sh
|
||||||
|
|
||||||
define PROJECT_NAME "C++ProjectTemplate"
|
define PROJECT_NAME "C++ProjectTemplate"
|
||||||
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple"
|
define CUSTOM_PARAMS "-std=c++17 "
|
||||||
define LANGUAGE "C++"
|
define LANGUAGE "C++"
|
||||||
|
|
||||||
source utils/main.sh
|
source utils/main.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user