Update Stage Plates to include the level type. Created Overworld Menu, and Initialized Character Menu. Story and shops no longer have the change loadout buttons.

pull/28/head
sigonasr2 1 year ago
parent 25b6dc0299
commit 4463fbbae5
  1. 46
      Crawler/CharacterMenuWindow.cpp
  2. 5
      Crawler/ConnectionPoint.h
  3. 12
      Crawler/Crawler.cpp
  4. 4
      Crawler/Crawler.h
  5. 19
      Crawler/Crawler.tiled-project
  6. 8
      Crawler/Crawler.vcxproj
  7. 6
      Crawler/Crawler.vcxproj.filters
  8. 6
      Crawler/Menu.cpp
  9. 6
      Crawler/Menu.h
  10. 58
      Crawler/OverworldMenuWindow.cpp
  11. 7
      Crawler/State_OverworldMap.cpp
  12. 7
      Crawler/TMXParser.h
  13. 2
      Crawler/Version.h
  14. 7
      Crawler/assets/Campaigns/World_Map.tmx

@ -0,0 +1,46 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2018 - 2023 OneLoneCoder.com
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Menu.h"
#include "MenuComponent.h"
#include "Crawler.h"
INCLUDE_game
void Menu::InitializeCharacterMenuWindow(){
Menu*characterMenuWindow=CreateMenu(CHARACTER_MENU,CENTERED,game->GetScreenSize()-vf2d{52,52});
}

@ -40,14 +40,15 @@ All rights reserved.
struct ConnectionPoint{
geom2d::rect<float>rect;
std::string type;
std::string name;
std::string map;
std::string unlockCondition;
std::array<int,8>neighbors; //Indices into the connectionPoint array.
std::vector<int>spawns;
bool levelDataExists=false;
inline ConnectionPoint(geom2d::rect<float>rect,std::string name,std::string map,std::string unlockCondition,std::vector<int>spawns)
:rect(rect),name(name),map(map),unlockCondition(unlockCondition),spawns(spawns){
inline ConnectionPoint(geom2d::rect<float>rect,std::string type,std::string name,std::string map,std::string unlockCondition,std::vector<int>spawns)
:rect(rect),type(type),name(name),map(map),unlockCondition(unlockCondition),spawns(spawns){
neighbors.fill(-1);
}
bool IsNeighbor(ConnectionPoint&testPoint);

@ -86,6 +86,7 @@ InputGroup Crawler::KEY_UP;
InputGroup Crawler::KEY_DOWN;
InputGroup Crawler::KEY_ATTACK;
InputGroup Crawler::KEY_CONFIRM;
InputGroup Crawler::KEY_MENU;
float Crawler::SIZE_CHANGE_SPEED=1;
@ -213,7 +214,7 @@ bool Crawler::OnUserUpdate(float fElapsedTime){
RenderMenu();
RenderFadeout();
RenderVersionInfo();
return true;
return !gameEnd;
}
bool Crawler::LeftHeld(){
@ -1933,6 +1934,7 @@ void Crawler::InitializeDefaultKeybinds(){
KEY_DOWN.AddKeybind({KEY,S});
KEY_CONFIRM.AddKeybind({MOUSE,Mouse::LEFT});
KEY_CONFIRM.AddKeybind({KEY,ENTER});
KEY_MENU.AddKeybind({KEY,ESCAPE});
}
void Crawler::SetBossNameDisplay(std::string name,float time){
@ -2000,10 +2002,8 @@ void Crawler::RenderMenu(){
Menu::stack.back()->Update(this);
}
if(Menu::stack.size()>0){
if(Menu::cover){
FillRectDecal({0,0},WINDOW_SIZE,{0,0,0,uint8_t(255*0.4)});
}
for(Menu*menu:Menu::stack){
if(menu->cover)FillRectDecal({0,0},WINDOW_SIZE,{0,0,0,uint8_t(255*0.4)});
menu->Draw(this);
}
}
@ -2217,3 +2217,7 @@ void Crawler::RenderFadeout(){
bool Crawler::GamePaused(){
return fadeOutDuration>0;
}
void Crawler::EndGame(){
gameEnd=true;
}

@ -65,6 +65,7 @@ public:
static InputGroup KEY_RIGHT;
static InputGroup KEY_UP;
static InputGroup KEY_DOWN;
static InputGroup KEY_MENU;
static float SIZE_CHANGE_SPEED;
float levelTime;
Camera2D camera;
@ -107,7 +108,7 @@ private:
float fadeOutTotalTime=0;
float fadeInDuration=0;
States::State transitionState=States::State::GAME_RUN;
bool gameEnd=false;
std::vector<Monster>monstersToBeSpawned;
void ValidateGameStatus();
@ -195,6 +196,7 @@ public:
void ClearLoadoutItem(int slot);
void RenderFadeout();
bool GamePaused();
void EndGame();
struct TileGroupData{
vi2d tilePos;

@ -294,6 +294,12 @@
"type": "string",
"value": "CAMPAIGN_1_1"
},
{
"name": "Type",
"propertyType": "StageType",
"type": "string",
"value": "DUNGEON"
},
{
"name": "Unlock Condition",
"propertyType": "Level",
@ -308,6 +314,19 @@
"object"
]
},
{
"id": 26,
"name": "StageType",
"storageType": "string",
"type": "enum",
"values": [
"DUNGEON",
"BOSS",
"STORY",
"SHOP"
],
"valuesAsFlags": false
},
{
"color": "#ffffaa00",
"drawFill": true,

@ -366,6 +366,10 @@
<ClCompile Include="Arrow.cpp" />
<ClCompile Include="Bullet.cpp" />
<ClCompile Include="CharacterInfoWindow.cpp" />
<ClCompile Include="CharacterMenuWindow.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="ChargedArrow.cpp" />
<ClCompile Include="ClassSelectionWindow.cpp" />
<ClCompile Include="ConnectionPoint.cpp" />
@ -393,6 +397,10 @@
<ClCompile Include="MenuComponent.cpp" />
<ClCompile Include="Meteor.cpp" />
<ClCompile Include="OverworldMapLevelWindow.cpp" />
<ClCompile Include="OverworldMenuWindow.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="RunAway.cpp" />
<ClCompile Include="RunTowards.cpp" />
<ClCompile Include="Pathfinding.cpp" />

@ -464,6 +464,12 @@
<ClCompile Include="State_Story.cpp">
<Filter>Source Files\Game States</Filter>
</ClCompile>
<ClCompile Include="OverworldMenuWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
<ClCompile Include="CharacterMenuWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -65,7 +65,6 @@ std::vector<MenuComponent*>Menu::unhandledComponents;
//////////////////////////////////////////////////////////////////////////////////////////////////
MenuType Menu::lastMenuTypeCreated;
std::string Menu::lastRegisteredComponent;
bool Menu::cover;
INCLUDE_game
INCLUDE_GFX
@ -96,6 +95,8 @@ void Menu::InitializeMenus(){
InitializeOverworldMapLevelWindow();
InitializeItemLoadoutWindow();
InitializeLevelCompleteWindow();
InitializeOverworldMenuWindow();
InitializeCharacterMenuWindow();
for(MenuType type=TEST;type<MenuType::ENUM_END;type=MenuType(int(type+1))){
if(menus.count(type)==0){
@ -384,8 +385,7 @@ void Menu::Draw(Crawler*game){
};
void Menu::OpenMenu(MenuType menu,bool cover){
Menu::cover=cover;
stack.clear();
menus[menu]->cover=cover;
stack.push_back(menus[menu]);
}

@ -57,6 +57,8 @@ enum MenuType{
OVERWORLD_LEVEL_SELECT,
ITEM_LOADOUT,
LEVEL_COMPLETE,
OVERWORLD_MENU,
CHARACTER_MENU,
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
///////////////////////////////////////////////////////////
@ -133,6 +135,8 @@ private:
static void InitializeOverworldMapLevelWindow();
static void InitializeItemLoadoutWindow();
static void InitializeLevelCompleteWindow();
static void InitializeOverworldMenuWindow();
static void InitializeCharacterMenuWindow();
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
static void DrawScaledWindowBackground(Crawler*game,vf2d menuPos,vf2d size,Pixel renderColor);
@ -145,7 +149,7 @@ private:
Pixel GetRenderColor();
static bool MOUSE_NAVIGATION;
static bool cover; //A black cover for when a menu pops up to fade out the stuff behind it.
bool cover; //A black cover for when a menu pops up to fade out the stuff behind it.
};
template<typename T>

@ -0,0 +1,58 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2018 - 2023 OneLoneCoder.com
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Menu.h"
#include "MenuComponent.h"
#include "Crawler.h"
INCLUDE_game
void Menu::InitializeOverworldMenuWindow(){
Menu*overworldMenuWindow=CreateMenu(OVERWORLD_MENU,CENTERED,vi2d{96,164});
MenuComponent*resumeButton=NEW MenuComponent(OVERWORLD_MENU,{{4,12+28*0},{88,24}},"Resume",[](MenuFuncData data){Menu::CloseMenu();return true;});
MenuComponent*characterButton=NEW MenuComponent(OVERWORLD_MENU,{{4,12+28*1},{88,24}},"Character",[](MenuFuncData data){Menu::OpenMenu(CHARACTER_MENU);return true;});
MenuComponent*inventoryButton=NEW MenuComponent(OVERWORLD_MENU,{{4,12+28*2},{88,24}},"Inventory",[](MenuFuncData data){/*Menu::OpenMenu(INVENTORY_MENU);*/return true;});
MenuComponent*settingsButton=NEW MenuComponent(OVERWORLD_MENU,{{4,12+28*3},{88,24}},"Settings",[](MenuFuncData data){/*Menu::OpenMenu(SETTINGS_MENU);*/return true;});
MenuComponent*quitButton=NEW MenuComponent(OVERWORLD_MENU,{{4,12+28*4},{88,24}},"Quit Game",[](MenuFuncData data){game->EndGame();return true;});
overworldMenuWindow->AddComponent("Resume Button",resumeButton);
overworldMenuWindow->AddComponent("Character Button",characterButton);
overworldMenuWindow->AddComponent("Inventory Button",inventoryButton);
overworldMenuWindow->AddComponent("Settings Button",settingsButton);
overworldMenuWindow->AddComponent("Quit Button",quitButton);
}

@ -85,6 +85,11 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){
}
}
if(Crawler::KEY_MENU.Pressed()){
Menu::OpenMenu(OVERWORLD_MENU);
}
#pragma region Handle Connection Point Clicking and Movement
for(ConnectionPoint&cp:connections){
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){
for(int neighborInd:currentConnectionPoint->neighbors){
@ -108,11 +113,13 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){
Component<MenuLabel>(OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
Component<EncountersSpawnListScrollableWindowComponent>(OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
Component<MenuComponent>(OVERWORLD_LEVEL_SELECT,"Enter Button")->Enable(currentConnectionPoint->levelDataExists);
Component<MenuComponent>(OVERWORLD_LEVEL_SELECT,"Change Loadout Button")->Enable(!(currentConnectionPoint->type=="STORY"||currentConnectionPoint->type=="SHOP"));
break;
}
}
}
}
#pragma endregion
};
void State_OverworldMap::Draw(Crawler*game){
currentTime+=game->GetElapsedTime();

@ -249,8 +249,6 @@ class TMXParser{
return parsedMapInfo;
}
void TMXParser::ParseTag(std::string tag) {
auto ReadNextTag=[&](){
XMLTag newTag;
//First character is a '<' so we discard it.
@ -342,9 +340,6 @@ class TMXParser{
parsedMapInfo.MapData.playerSpawnLocation={newTag.GetInteger("x")-newTag.GetInteger("width")/2,newTag.GetInteger("y")-newTag.GetInteger("height")/2};
} else
if (newTag.tag=="object"&&newTag.data["type"]=="Monster") {
//XMLTag monsterTag=ReadNextTag();
//XMLTag spawnerLinkTag=ReadNextTag();
//newTag.data["value"]=monsterTag.GetInteger("value"); //Value now contains which monster name this spawn represents.
monsterTag=newTag;
monsterPropertyTagCount=0;
} else
@ -458,7 +453,7 @@ class TMXParser{
for(auto key:stagePlates){
StagePlate&plate=key.second;
idToIndexMap[plate.tag.GetInteger("id")]=int(State_OverworldMap::connections.size());
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,{}};
ConnectionPoint newConnection={{{plate.tag.GetFloat("x"),plate.tag.GetFloat("y")},{plate.tag.GetFloat("width"),plate.tag.GetFloat("height")}},plate.properties["Type"].value,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 ")){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 3321
#define VERSION_BUILD 3326
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -560,6 +560,7 @@
<property name="Connection 1" type="object" value="4"/>
<property name="Connection 2" type="object" value="5"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_1"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="WORLD_MAP"/>
</properties>
</object>
@ -567,6 +568,7 @@
<properties>
<property name="Connection 1" type="object" value="7"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_2"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/>
</properties>
</object>
@ -574,6 +576,7 @@
<properties>
<property name="Connection 1" type="object" value="8"/>
<property name="Map" propertytype="Level" value="STORY_1_1"/>
<property name="Type" propertytype="StageType" value="STORY"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/>
</properties>
</object>
@ -583,6 +586,7 @@
<property name="Connection 2" type="object" value="0"/>
<property name="Connection 3" type="object" value="0"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_3"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/>
</properties>
</object>
@ -590,12 +594,14 @@
<properties>
<property name="Connection 1" type="object" value="6"/>
<property name="Map" propertytype="Level" value="STORY_1_2"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_2"/>
</properties>
</object>
<object id="8" name="Blacksmith I" type="StagePlate" x="416" y="416" width="20" height="24">
<properties>
<property name="Map" propertytype="Level" value="BLACKSMITH"/>
<property name="Type" propertytype="StageType" value="SHOP"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_3"/>
</properties>
</object>
@ -604,6 +610,7 @@
<property name="Connection 1" type="object" value="0"/>
<property name="Connection 2" type="object" value="0"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_4"/>
<property name="Type" propertytype="StageType" value="DUNGEON"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_3"/>
</properties>
</object>

Loading…
Cancel
Save