Fix State_OverworldMap dependency in TMXParser.h

pull/28/head
sigonasr2 1 year ago
parent 35526016bb
commit c065e9f6fb
  1. 9
      Crawler/ConnectionPoint.h
  2. 2
      Crawler/Crawler.cpp
  3. 2
      Crawler/Crawler.h
  4. 3
      Crawler/Crawler.vcxproj
  5. 12
      Crawler/Crawler.vcxproj.filters
  6. 3
      Crawler/GameState.cpp
  7. 21
      Crawler/GameState.h
  8. 1
      Crawler/MenuAnimatedIconButton.h
  9. 14
      Crawler/Player.h
  10. 3
      Crawler/State_GameRun.cpp
  11. 8
      Crawler/State_GameRun.h
  12. 2
      Crawler/State_MainMenu.cpp
  13. 7
      Crawler/State_MainMenu.h
  14. 22
      Crawler/State_OverworldMap.cpp
  15. 14
      Crawler/State_OverworldMap.h
  16. 4
      Crawler/TMXParser.h
  17. 2
      Crawler/Version.h
  18. 18
      Crawler/assets/Campaigns/World_Map.tmx

@ -1,12 +1,13 @@
#include "olcPixelGameEngine.h"
#include "olcUTIL_Geometry2D.h"
struct ConnectionPoint{
vf2d pos;
geom2d::rect<float>rect;
std::string name;
std::string map;
std::string unlockCondition;
std::array<int,4>neighbors; //Indices into the connectionPoint array.
ConnectionPoint(vf2d pos,std::string map,std::string unlockCondition)
:pos(pos),map(map),unlockCondition(unlockCondition){
ConnectionPoint(geom2d::rect<float>rect,std::string name,std::string map,std::string unlockCondition)
:rect(rect),name(name),map(map),unlockCondition(unlockCondition){
neighbors.fill(-1);
}
};

@ -390,8 +390,6 @@ void Crawler::UpdateCamera(float fElapsedTime){
worldShakeVel.y*=-1;
}
worldShake=player->GetPos()+worldShakeVel*fElapsedTime;
} else {
camera.SetTarget(player->GetPos());
}
worldShakeTime=std::max(0.f,worldShakeTime-fElapsedTime);
camera.Update(fElapsedTime);

@ -17,7 +17,6 @@ class Crawler : public olc::PixelGameEngine
{
friend class State_GameRun;
friend class sig::Animation;
Camera2D camera;
std::unique_ptr<Player>player;
public:
Pathfinding pathfinder;
@ -28,6 +27,7 @@ public:
static InputGroup KEY_DOWN;
static float SIZE_CHANGE_SPEED;
float levelTime;
Camera2D camera;
private:
std::vector<std::unique_ptr<Effect>>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted;
std::vector<TileRenderData*>tilePreparationList,tileForegroundList;

@ -303,6 +303,9 @@
<ClInclude Include="ScrollableWindowComponent.h" />
<ClInclude Include="InventoryScrollableWindowComponent.h" />
<ClInclude Include="State.h" />
<ClInclude Include="State_GameRun.h" />
<ClInclude Include="State_MainMenu.h" />
<ClInclude Include="State_OverworldMap.h" />
<ClInclude Include="Theme.h" />
<ClInclude Include="TMXParser.h" />
<ClInclude Include="Toggleable.h" />

@ -58,6 +58,9 @@
<Filter Include="Documentation\Menus">
<UniqueIdentifier>{bea40439-f3a2-42f8-be1a-c0a815007075}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\State">
<UniqueIdentifier>{948a122a-3110-45f6-82d5-9b6bc499e3d2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h">
@ -213,6 +216,15 @@
<ClInclude Include="ConnectionPoint.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="State_GameRun.h">
<Filter>Header Files\State</Filter>
</ClInclude>
<ClInclude Include="State_OverworldMap.h">
<Filter>Header Files\State</Filter>
</ClInclude>
<ClInclude Include="State_MainMenu.h">
<Filter>Header Files\State</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">

@ -1,4 +1,7 @@
#include "GameState.h"
#include "State_GameRun.h"
#include "State_OverworldMap.h"
#include "State_MainMenu.h"
#define NEW_STATE(state,class) GameState::states[state]=new class();

@ -1,7 +1,6 @@
#pragma once
#include <map>
#include <iostream>
#include "ConnectionPoint.h"
class Crawler;
@ -31,23 +30,3 @@ public:
STATE->OnStateChange(prevState);
}
};
class State_GameRun:public GameState{
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};
class State_OverworldMap:public GameState{
public:
static std::vector<ConnectionPoint>connections;
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};
class State_MainMenu:public GameState{
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};

@ -1,7 +1,6 @@
#pragma once
#include "MenuIconButton.h"
#include "DEFINES.h"
#include "Crawler.h"
INCLUDE_game
INCLUDE_ANIMATION_DATA

@ -69,13 +69,6 @@ protected:
void SetFacingDirection(Key direction);
void SetLastReleasedMovementKey(Key k);
void Spin(float duration,float spinSpd);
//Returns true if the move was valid and successful.
bool SetX(float x);
//Returns true if the move was valid and successful.
bool SetY(float y);
void SetZ(float z);
//Returns true if the move was valid and successful.
bool SetPos(vf2d pos);
float friction="Player.Friction"_F;
float attack_cooldown_timer=0;
float teleportAnimationTimer=0;
@ -140,6 +133,13 @@ public:
void SetIframes(float duration);
void RestoreMana(int amt);
void ConsumeMana(int amt);
//Returns true if the move was valid and successful.
bool SetX(float x);
//Returns true if the move was valid and successful.
bool SetY(float y);
void SetZ(float z);
//Returns true if the move was valid and successful.
bool SetPos(vf2d pos);
void AddBuff(BuffType type,float duration,float intensity);
std::vector<Buff>GetBuffs(BuffType buff);

@ -1,8 +1,7 @@
#include "GameState.h"
#include "State_GameRun.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "Menu.h"
#include "Item.h"
INCLUDE_MONSTER_LIST

@ -0,0 +1,8 @@
#pragma once
#include "GameState.h"
class State_GameRun:public GameState{
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};

@ -1,4 +1,4 @@
#include "GameState.h"
#include "State_MainMenu.h"
#include "Crawler.h"
#include "Menu.h"

@ -0,0 +1,7 @@
#include "GameState.h"
class State_MainMenu:public GameState{
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};

@ -1,19 +1,35 @@
#include "GameState.h"
#pragma once
#include "State_OverworldMap.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "Menu.h"
#include "Item.h"
INCLUDE_MONSTER_LIST
INCLUDE_game
std::vector<ConnectionPoint>State_OverworldMap::connections;
State_OverworldMap::State_OverworldMap(){
SetStageMarker("Stage I-I"); //Eventually we will load the game from a file and this will not be necessary. We just set it to this for now.
game->GetPlayer()->SetPos(currentConnectionPoint->rect.pos);
}
void State_OverworldMap::OnStateChange(GameState*prevState){
Menu::CloseAllMenus();
};
void State_OverworldMap::OnUserUpdate(Crawler*game){
game->camera.SetTarget(currentConnectionPoint->rect.middle());
game->UpdateCamera(game->GetElapsedTime());
};
void State_OverworldMap::Draw(Crawler*game){
};
void State_OverworldMap::SetStageMarker(std::string connectionName){
for(ConnectionPoint&connection:connections){
if(connection.name==connectionName){
currentConnectionPoint=&connection;
return;
}
}
std::cout<<"WARNING! Could not find a connection point with name "<<connectionName<<"!"<<std::endl;
throw;
}

@ -0,0 +1,14 @@
#pragma once
#include "GameState.h"
#include "ConnectionPoint.h"
class State_OverworldMap:public GameState{
ConnectionPoint*currentConnectionPoint;
public:
State_OverworldMap();
static std::vector<ConnectionPoint>connections;
void SetStageMarker(std::string connectionName);
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;
};

@ -2,7 +2,6 @@
#include "olcPixelGameEngine.h"
#include "olcUTIL_Geometry2D.h"
#include <sstream>
#include "GameState.h"
using namespace olc;
@ -97,6 +96,7 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
#ifdef TMX_PARSER_SETUP
#undef TMX_PARSER_SETUP
#include "State_OverworldMap.h"
extern bool _DEBUG_MAP_LOAD_INFO;
const std::string XMLTag::FormatTagData(std::map<std::string,std::string>tiles){
std::string displayStr="";
@ -405,7 +405,7 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
for(auto key:stagePlates){
StagePlate&plate=key.second;
idToIndexMap[plate.tag.GetInteger("id")]=State_OverworldMap::connections.size();
ConnectionPoint newConnection={{plate.tag.GetFloat("x"),plate.tag.GetFloat("y")},plate.properties["Map"].value,plate.properties["Unlock Condition"].value};
ConnectionPoint newConnection={{{plate.tag.GetFloat("x"),plate.tag.GetFloat("y")},{plate.tag.GetFloat("width"),plate.tag.GetFloat("height")}},plate.tag.data["name"],plate.properties["Map"].value,plate.properties["Unlock Condition"].value};
int iterationCount=0;
for(auto key2:plate.properties){
if(key2.first.starts_with("Connection ")){

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 2428
#define VERSION_BUILD 2450
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="left-down" width="250" height="177" tilewidth="4" tileheight="4" infinite="0" nextlayerid="5" nextobjectid="12">
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="left-down" width="250" height="177" tilewidth="4" tileheight="4" infinite="0" nextlayerid="5" nextobjectid="12">
<properties>
<property name="Optimize" type="bool" value="true"/>
</properties>
@ -554,27 +554,27 @@
</layer>
<objectgroup id="4" name="Object Layer 1">
<object id="2" name="Temp Player Spawn" type="PlayerSpawnLocation" x="200" y="325" width="20" height="20"/>
<object id="3" name="Stage 1" type="StagePlate" x="252" y="496" width="44" height="16">
<object id="3" name="Stage I-I" type="StagePlate" x="252" y="496" width="44" height="16">
<properties>
<property name="Connection 1" type="object" value="4"/>
<property name="Connection 2" type="object" value="5"/>
</properties>
</object>
<object id="4" name="Stage 2" type="StagePlate" x="248" y="552" width="44" height="16">
<object id="4" name="Stage I-II" type="StagePlate" x="248" y="552" width="44" height="16">
<properties>
<property name="Connection 1" type="object" value="7"/>
<property name="Map" value="CAMPAIGN_1_2"/>
<property name="Unlock Condition" value="CAMPAIGN_1_1"/>
</properties>
</object>
<object id="5" name="Shop 1" type="StagePlate" x="344" y="476" width="20" height="24">
<object id="5" name="Shop I" type="StagePlate" x="344" y="476" width="20" height="24">
<properties>
<property name="Connection 1" type="object" value="8"/>
<property name="Map" value="SHOP_1_1"/>
<property name="Unlock Condition" value="CAMPAIGN_1_1"/>
</properties>
</object>
<object id="6" name="Stage 3" type="StagePlate" x="196" y="636" width="44" height="16">
<object id="6" name="Stage III" type="StagePlate" x="196" y="636" width="44" height="16">
<properties>
<property name="Connection 1" type="object" value="9"/>
<property name="Connection 2" type="object" value="0"/>
@ -583,20 +583,20 @@
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/>
</properties>
</object>
<object id="7" name="Shop 2" type="StagePlate" x="236" y="592" width="20" height="24">
<object id="7" name="Shop II" type="StagePlate" x="236" y="592" width="20" height="24">
<properties>
<property name="Connection 1" type="object" value="6"/>
<property name="Map" value="SHOP_1_2"/>
<property name="Unlock Condition" value="CAMPAIGN_1_2"/>
</properties>
</object>
<object id="8" name="Blacksmith" type="StagePlate" x="416" y="416" width="20" height="24">
<object id="8" name="Blacksmith I" type="StagePlate" x="416" y="416" width="20" height="24">
<properties>
<property name="Map" value="BLACKSMITH"/>
<property name="Unlock Condition" value="CAMPAIGN_1_3"/>
</properties>
</object>
<object id="9" name="Stage 4" type="StagePlate" x="172" y="580" width="44" height="16">
<object id="9" name="Stage IV" type="StagePlate" x="172" y="580" width="44" height="16">
<properties>
<property name="Connection 1" type="object" value="0"/>
<property name="Connection 2" type="object" value="0"/>
@ -604,7 +604,7 @@
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_3"/>
</properties>
</object>
<object id="11" name="Boss 1" type="StagePlate" x="156" y="644" width="32" height="24">
<object id="11" name="Boss I" type="StagePlate" x="156" y="644" width="32" height="24">
<properties>
<property name="Connection 1" type="object" value="0"/>
<property name="Unlock Condition" type="object" value="0"/>

Loading…
Cancel
Save