Read Zone tile data from the map to prepare for special interactions in the game.
This commit is contained in:
parent
d2ab61472a
commit
005c49aa04
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -79,6 +79,7 @@
|
||||
"ios": "cpp",
|
||||
"locale": "cpp",
|
||||
"queue": "cpp",
|
||||
"stack": "cpp"
|
||||
"stack": "cpp",
|
||||
"span": "cpp"
|
||||
}
|
||||
}
|
BIN
Crawler/Crawler
Executable file
BIN
Crawler/Crawler
Executable file
Binary file not shown.
@ -1003,6 +1003,7 @@ MapName Crawler::GetCurrentLevel(){
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout<<std::endl<<"============"<<std::endl;
|
||||
Crawler demo;
|
||||
if (demo.Construct(WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4))
|
||||
demo.Start();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "olcPixelGameEngine.h"
|
||||
#include "olcUTIL_Geometry2D.h"
|
||||
#include <strstream>
|
||||
|
||||
using namespace olc;
|
||||
@ -40,6 +41,7 @@ struct Map{
|
||||
std::vector<XMLTag> TilesetData;
|
||||
std::vector<LayerTag> LayerData;
|
||||
std::vector<SpawnerTag> SpawnerData;
|
||||
std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
||||
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
|
||||
std::string FormatSpawnerData(std::ostream& os, std::vector<SpawnerTag>tiles);
|
||||
friend std::ostream& operator << (std::ostream& os, Map& rhs);
|
||||
@ -57,7 +59,6 @@ class TMXParser{
|
||||
public:
|
||||
TMXParser(std::string file);
|
||||
};
|
||||
|
||||
#ifdef TMX_PARSER_SETUP
|
||||
#undef TMX_PARSER_SETUP
|
||||
const std::string XMLTag::FormatTagData(std::map<std::string,std::string>tiles){
|
||||
@ -201,7 +202,7 @@ class TMXParser{
|
||||
if (newTag.tag=="layer") {
|
||||
LayerTag l = {newTag};
|
||||
parsedMapInfo.LayerData.push_back(l);
|
||||
} else
|
||||
}else
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
|
||||
if(buildingSpawner){
|
||||
parsedMapInfo.SpawnerData.push_back(obj);
|
||||
@ -213,6 +214,17 @@ class TMXParser{
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="PlayerSpawnLocation") {
|
||||
parsedMapInfo.MapData.playerSpawnLocation={newTag.GetInteger("x")-newTag.GetInteger("width")/2,newTag.GetInteger("y")-newTag.GetInteger("height")/2};
|
||||
} else
|
||||
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){
|
||||
//This is an object with a type that doesn't fit into other categories, we can add it to ZoneData.
|
||||
if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){
|
||||
std::vector<geom2d::rect<int>>&zones=parsedMapInfo.ZoneData[newTag.data["type"]];
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
} else {
|
||||
std::vector<geom2d::rect<int>>zones;
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
parsedMapInfo.ZoneData[newTag.data["type"]]=zones;
|
||||
}
|
||||
}
|
||||
if (newTag.tag=="property"&&buildingSpawner) {
|
||||
if(newTag.data["propertytype"]=="MonsterName"){
|
||||
obj.properties.push_back(newTag);
|
||||
|
BIN
Crawler/pixelGameEngine.o
Normal file
BIN
Crawler/pixelGameEngine.o
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user