Added directional connection points and gamepad/keyboard navigation to overworld map. Set 1_4 to not be an infinite map.

pull/35/head
sigonasr2 10 months ago
parent e15f0332a7
commit 7cd3600f42
  1. 24
      Adventures in Lestoria/Adventures in Lestoria.tiled-project
  2. 6
      Adventures in Lestoria/ConnectionPoint.h
  3. 27
      Adventures in Lestoria/State_OverworldMap.cpp
  4. 38
      Adventures in Lestoria/TMXParser.h
  5. 2
      Adventures in Lestoria/Version.h
  6. 3704
      Adventures in Lestoria/assets/Campaigns/1_4.tmx
  7. 40
      Adventures in Lestoria/assets/Campaigns/World_Map.tmx

@ -342,22 +342,22 @@
"id": 20, "id": 20,
"members": [ "members": [
{ {
"name": "Connection 1", "name": "Connection 1 - North",
"type": "object", "type": "object",
"value": 0 "value": 0
}, },
{ {
"name": "Connection 2", "name": "Connection 2 - East",
"type": "object", "type": "object",
"value": 0 "value": 0
}, },
{ {
"name": "Connection 3", "name": "Connection 3 - South",
"type": "object", "type": "object",
"value": 0 "value": 0
}, },
{ {
"name": "Connection 4", "name": "Connection 4 - West",
"type": "object", "type": "object",
"value": 0 "value": 0
}, },
@ -450,29 +450,29 @@
] ]
}, },
{ {
"color": "#ffa40aa4", "color": "#ffa0a0a4",
"drawFill": true, "drawFill": true,
"id": 10, "id": 31,
"members": [ "members": [
], ],
"name": "UpperZone", "name": "Terrain",
"type": "class", "type": "class",
"useAs": [ "useAs": [
"property", "property",
"object" "tileset"
] ]
}, },
{ {
"color": "#ffa0a0a4", "color": "#ffa40aa4",
"drawFill": true, "drawFill": true,
"id": 31, "id": 10,
"members": [ "members": [
], ],
"name": "Terrain", "name": "UpperZone",
"type": "class", "type": "class",
"useAs": [ "useAs": [
"property", "property",
"tileset" "object"
] ]
} }
] ]

@ -40,6 +40,12 @@ All rights reserved.
#include <array> #include <array>
struct ConnectionPoint{ struct ConnectionPoint{
enum Direction{
NORTH,
EAST,
SOUTH,
WEST
};
friend class State_OverworldMap; friend class State_OverworldMap;
geom2d::rect<float>rect; geom2d::rect<float>rect;
std::string type; std::string type;

@ -141,11 +141,25 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
#pragma region Handle Connection Point Clicking and Movement #pragma region Handle Connection Point Clicking and Movement
for(ConnectionPoint&cp:connections){ for(ConnectionPoint&cp:connections){
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){ if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)
for(int neighborInd:currentConnectionPoint->neighbors){ ||game->KEY_LEFT.Pressed()||game->KEY_RIGHT.Pressed()||game->KEY_UP.Pressed()||game->KEY_DOWN.Pressed()){
if(neighborInd==-1)continue; bool mouseUsed=game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect);
for(int directionInd=0;int neighborInd:currentConnectionPoint->neighbors){
int targetDirection=-1;
if(game->KEY_LEFT.Pressed())targetDirection=ConnectionPoint::WEST;
if(game->KEY_RIGHT.Pressed())targetDirection=ConnectionPoint::EAST;
if(game->KEY_UP.Pressed())targetDirection=ConnectionPoint::NORTH;
if(game->KEY_DOWN.Pressed())targetDirection=ConnectionPoint::SOUTH;
if(neighborInd==-1){
directionInd++;
continue;
}
ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd); ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd);
if(Unlock::IsUnlocked(neighbor.unlockCondition)&&&cp==&neighbor){ if(Unlock::IsUnlocked(neighbor.unlockCondition)&&&cp==&neighbor
&&(mouseUsed||targetDirection==directionInd)){
UpdateCurrentConnectionPoint(neighbor); UpdateCurrentConnectionPoint(neighbor);
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16}; playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
float angleTo=util::angleTo(game->GetPlayer()->GetPos(),playerTargetPos); float angleTo=util::angleTo(game->GetPlayer()->GetPos(),playerTargetPos);
@ -160,12 +174,15 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
}else{ }else{
game->GetPlayer()->UpdateWalkingAnimation(LEFT); game->GetPlayer()->UpdateWalkingAnimation(LEFT);
} }
break; goto doneNavigating;
} }
directionInd++;
} }
} }
} }
#pragma endregion #pragma endregion
doneNavigating:
int a;
}; };
void State_OverworldMap::Draw(AiL*game){ void State_OverworldMap::Draw(AiL*game){
currentTime+=game->GetElapsedTime(); currentTime+=game->GetElapsedTime();

@ -46,6 +46,7 @@ All rights reserved.
using MapName=std::string; using MapName=std::string;
using namespace olc; using namespace olc;
using namespace std::literals;
struct XMLTag{ struct XMLTag{
std::string tag; std::string tag;
@ -512,8 +513,10 @@ class TMXParser{
int iterationCount=0; int iterationCount=0;
for(auto key2:plate.properties){ for(auto key2:plate.properties){
if(key2.first.starts_with("Connection ")){ if(key2.first.starts_with("Connection ")){
newConnection.neighbors[iterationCount]=key2.second.GetInteger(); int direction=stoi(key2.first.substr("Connection "s.length(),1))-1;
iterationCount++; int&neighborElement=newConnection.neighbors[direction];
if(neighborElement!=-1)ERR(std::format("WARNING! Connection Point in direction {} is already occupied by node {}!",direction,neighborElement));
newConnection.neighbors[direction]=key2.second.GetInteger();
} }
} }
State_OverworldMap::connections.push_back(newConnection); State_OverworldMap::connections.push_back(newConnection);
@ -526,17 +529,36 @@ class TMXParser{
} }
} }
for(int counter=0;ConnectionPoint&connection:State_OverworldMap::connections){ for(int counter=0;ConnectionPoint&connection:State_OverworldMap::connections){
for(int val:connection.neighbors){ for(int directionInd=0;int val:connection.neighbors){
if(val!=-1){ if(val!=-1){
ConnectionPoint&neighbor=State_OverworldMap::connections.at(val); ConnectionPoint&neighbor=State_OverworldMap::connections.at(val);
//Find a blank slot that is available.
for(int i=0;i<neighbor.neighbors.size();i++){ //Find the opposite slot.
if(neighbor.neighbors[i]==-1){ //We insert our neighbor pairing here. int targetInd=-1;
neighbor.neighbors[i]=counter;
break; #pragma region Opposite Direction Calculation
switch(directionInd){
case ConnectionPoint::NORTH:{
targetInd=ConnectionPoint::SOUTH;
}break;
case ConnectionPoint::EAST:{
targetInd=ConnectionPoint::WEST;
}break;
case ConnectionPoint::SOUTH:{
targetInd=ConnectionPoint::NORTH;
}break;
case ConnectionPoint::WEST:{
targetInd=ConnectionPoint::EAST;
}break;
} }
#pragma endregion
if(neighbor.neighbors[targetInd]==-1){ //We insert our neighbor pairing here.
neighbor.neighbors[targetInd]=counter;
break;
} }
} }
directionInd++;
} }
counter++; counter++;
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 6155 #define VERSION_BUILD 6168
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

File diff suppressed because it is too large Load Diff

@ -558,8 +558,8 @@
<object id="2" name="Temp Player Spawn" type="PlayerSpawnLocation" x="200" y="325" width="20" height="20"/> <object id="2" name="Temp Player Spawn" type="PlayerSpawnLocation" x="200" y="325" width="20" height="20"/>
<object id="3" name="Stage I-I" 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> <properties>
<property name="Connection 1" type="object" value="4"/> <property name="Connection 2 - East" type="object" value="5"/>
<property name="Connection 2" type="object" value="5"/> <property name="Connection 3 - South" type="object" value="4"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_1"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_1"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="WORLD_MAP"/> <property name="Unlock Condition" propertytype="Level" value="WORLD_MAP"/>
@ -567,7 +567,8 @@
</object> </object>
<object id="4" name="Stage I-II" 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> <properties>
<property name="Connection 1" type="object" value="7"/> <property name="Connection 3 - South" type="object" value="7"/>
<property name="Connection 4 - West" type="object" value="7"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_2"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_2"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/>
@ -575,7 +576,8 @@
</object> </object>
<object id="5" name="Story I" type="StagePlate" x="344" y="476" width="20" height="24"> <object id="5" name="Story I" type="StagePlate" x="344" y="476" width="20" height="24">
<properties> <properties>
<property name="Connection 1" type="object" value="8"/> <property name="Connection 1 - North" type="object" value="8"/>
<property name="Connection 2 - East" type="object" value="8"/>
<property name="Map" propertytype="Level" value="STORY_1_1"/> <property name="Map" propertytype="Level" value="STORY_1_1"/>
<property name="Type" propertytype="StageType" value="STORY"/> <property name="Type" propertytype="StageType" value="STORY"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/>
@ -583,9 +585,8 @@
</object> </object>
<object id="6" name="Stage III" 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> <properties>
<property name="Connection 1" type="object" value="9"/> <property name="Connection 1 - North" type="object" value="9"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 4 - West" type="object" value="9"/>
<property name="Connection 3" type="object" value="0"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_3"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_3"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/>
@ -593,7 +594,8 @@
</object> </object>
<object id="7" name="Story II" type="StagePlate" x="236" y="592" width="20" height="24"> <object id="7" name="Story II" type="StagePlate" x="236" y="592" width="20" height="24">
<properties> <properties>
<property name="Connection 1" type="object" value="6"/> <property name="Connection 3 - South" type="object" value="6"/>
<property name="Connection 4 - West" type="object" value="6"/>
<property name="Map" propertytype="Level" value="STORY_1_2"/> <property name="Map" propertytype="Level" value="STORY_1_2"/>
<property name="Type" propertytype="StageType" value="STORY"/> <property name="Type" propertytype="StageType" value="STORY"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/>
@ -608,8 +610,8 @@
</object> </object>
<object id="9" name="Stage IV" 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> <properties>
<property name="Connection 1" type="object" value="12"/> <property name="Connection 1 - North" type="object" value="12"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 4 - West" type="object" value="12"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_4"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_4"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_3"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_3"/>
@ -617,7 +619,7 @@
</object> </object>
<object id="11" name="Boss I" 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> <properties>
<property name="Connection 1" type="object" value="16"/> <property name="Connection 1 - North" type="object" value="16"/>
<property name="Map" propertytype="Level" value="BOSS_1"/> <property name="Map" propertytype="Level" value="BOSS_1"/>
<property name="Type" propertytype="StageType" value="BOSS"/> <property name="Type" propertytype="StageType" value="BOSS"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_8"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_8"/>
@ -625,8 +627,8 @@
</object> </object>
<object id="12" name="Stage V" type="StagePlate" x="112" y="532" width="44" height="16"> <object id="12" name="Stage V" type="StagePlate" x="112" y="532" width="44" height="16">
<properties> <properties>
<property name="Connection 1" type="object" value="13"/> <property name="Connection 1 - North" type="object" value="13"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 4 - West" type="object" value="13"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_5"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_5"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_4"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_4"/>
@ -634,8 +636,8 @@
</object> </object>
<object id="13" name="Stage VI" type="StagePlate" x="60" y="484" width="44" height="16"> <object id="13" name="Stage VI" type="StagePlate" x="60" y="484" width="44" height="16">
<properties> <properties>
<property name="Connection 1" type="object" value="14"/> <property name="Connection 3 - South" type="object" value="14"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 4 - West" type="object" value="14"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_6"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_6"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_5"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_5"/>
@ -643,8 +645,8 @@
</object> </object>
<object id="14" name="Stage VII" type="StagePlate" x="36" y="556" width="44" height="16"> <object id="14" name="Stage VII" type="StagePlate" x="36" y="556" width="44" height="16">
<properties> <properties>
<property name="Connection 1" type="object" value="15"/> <property name="Connection 2 - East" type="object" value="15"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 3 - South" type="object" value="15"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_7"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_7"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_6"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_6"/>
@ -652,8 +654,8 @@
</object> </object>
<object id="15" name="Stage VIII" type="StagePlate" x="72" y="612" width="44" height="16"> <object id="15" name="Stage VIII" type="StagePlate" x="72" y="612" width="44" height="16">
<properties> <properties>
<property name="Connection 1" type="object" value="11"/> <property name="Connection 2 - East" type="object" value="11"/>
<property name="Connection 2" type="object" value="0"/> <property name="Connection 3 - South" type="object" value="11"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_8"/> <property name="Map" propertytype="Level" value="CAMPAIGN_1_8"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/> <property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_7"/> <property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_7"/>

Loading…
Cancel
Save