Added ability to select a loadout item from the inventory menu screen.

pull/28/head
sigonasr2 1 year ago
parent 7e371f6779
commit 1bf30f4392
  1. 2
      Crawler/Arrow.cpp
  2. 2
      Crawler/Attributable.h
  3. 2
      Crawler/CharacterAbilityPreviewComponent.h
  4. 2
      Crawler/ChargedArrow.cpp
  5. 2
      Crawler/Crawler.cpp
  6. 6
      Crawler/Crawler.vcxproj
  7. 36
      Crawler/Crawler.vcxproj.filters
  8. 2
      Crawler/EnergyBolt.cpp
  9. 2
      Crawler/FireBolt.cpp
  10. 17
      Crawler/InventoryScrollableWindowComponent.h
  11. 2
      Crawler/InventoryWindow.cpp
  12. 2
      Crawler/Item.h
  13. 2
      Crawler/LightningBolt.cpp
  14. 2
      Crawler/LightningBoltEmitter.cpp
  15. 2
      Crawler/Menu.h
  16. 20
      Crawler/MenuItemButton.h
  17. 2
      Crawler/MenuLabel.h
  18. 2
      Crawler/Meteor.cpp
  19. 2
      Crawler/Monster.cpp
  20. 2
      Crawler/MonsterAttribute.h
  21. 8
      Crawler/Player.cpp
  22. 3
      Crawler/Player.h
  23. 2
      Crawler/PulsatingFire.cpp
  24. 2
      Crawler/Ranger.cpp
  25. 2
      Crawler/SlimeKing.cpp
  26. 2
      Crawler/SpawnEncounterLabel.h
  27. 35
      Crawler/State_OverworldMap.cpp
  28. 2
      Crawler/Turret.cpp
  29. 2
      Crawler/Version.h
  30. 2
      Crawler/Wizard.cpp
  31. 137
      Crawler/drawutil.cpp
  32. 11
      Crawler/drawutil.h
  33. 2
      Crawler/util.cpp
  34. 0
      Crawler/util.h

@ -2,7 +2,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
#include "util.h"
#include "olcUTIL_Geometry2D.h"
INCLUDE_game

@ -5,7 +5,7 @@
#include <variant>
class IAttributable{
protected:
public:
inline virtual ~IAttributable(){};
std::map<Attribute,std::variant<VARIANTS>>attributes;
inline float&GetFloat(Attribute a){

@ -2,7 +2,7 @@
#include "MenuLabel.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
#include "Ability.h"
INCLUDE_game

@ -2,7 +2,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
#include "util.h"
#include "olcUTIL_Geometry2D.h"
INCLUDE_game

@ -10,7 +10,7 @@
#include "TSXParser.h"
#include "Map.h"
#include "DEFINES.h"
#include "utils.h"
#include "util.h"
#include <set>
#include <queue>
#include "Emitter.h"

@ -273,6 +273,7 @@
<ClInclude Include="Crawler.h" />
<ClInclude Include="DamageNumber.h" />
<ClInclude Include="DEFINES.h" />
<ClInclude Include="drawutil.h" />
<ClInclude Include="Effect.h" />
<ClInclude Include="Emitter.h" />
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h" />
@ -314,7 +315,7 @@
<ClInclude Include="Toggleable.h" />
<ClInclude Include="TSXParser.h" />
<ClInclude Include="Unlock.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="util.h" />
<ClInclude Include="Version.h" />
</ItemGroup>
<ItemGroup>
@ -328,6 +329,7 @@
<ClCompile Include="ConnectionPoint.cpp" />
<ClCompile Include="Crawler.cpp" />
<ClCompile Include="DamageNumber.cpp" />
<ClCompile Include="drawutil.cpp" />
<ClCompile Include="Effect.cpp" />
<ClCompile Include="Emitter.cpp" />
<ClCompile Include="EnergyBolt.cpp" />
@ -368,7 +370,7 @@
<ClCompile Include="Turret.cpp" />
<ClCompile Include="Unlock.cpp" />
<ClCompile Include="Warrior.cpp" />
<ClCompile Include="utils.cpp" />
<ClCompile Include="util.cpp" />
<ClCompile Include="Witch.cpp" />
<ClCompile Include="Wizard.cpp" />
</ItemGroup>

@ -61,6 +61,12 @@
<Filter Include="Header Files\State">
<UniqueIdentifier>{948a122a-3110-45f6-82d5-9b6bc499e3d2}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Utils">
<UniqueIdentifier>{2c68f315-9f2b-46c7-abca-cc97b5e0e515}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Utils">
<UniqueIdentifier>{7d5c4dfd-a5a1-4a3d-8231-ace70551db5a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h">
@ -135,9 +141,6 @@
<ClInclude Include="Pathfinding.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Emitter.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -171,9 +174,6 @@
<ClInclude Include="MenuLabel.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="Attributable.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="GameState.h">
<Filter>Header Files\Game States</Filter>
</ClInclude>
@ -228,15 +228,24 @@
<ClInclude Include="Error.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Ability.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpawnEncounterLabel.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="util.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
<ClInclude Include="drawutil.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
<ClInclude Include="Attributable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Ability.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">
@ -278,9 +287,6 @@
<ClCompile Include="FireBolt.cpp">
<Filter>Source Files\Bullet Types</Filter>
</ClCompile>
<ClCompile Include="utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Animation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -398,6 +404,12 @@
<ClCompile Include="ConnectionPoint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="util.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="drawutil.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -2,7 +2,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
#include "util.h"
INCLUDE_game

@ -2,7 +2,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
#include "util.h"
INCLUDE_game
INCLUDE_MONSTER_LIST

@ -69,9 +69,22 @@ protected:
int buttonSize="ThemeGlobal.InventoryButtonSize"_I;
int totalSpacing="ThemeGlobal.InventoryItemSpacing"_I+buttonSize;
MenuFunc useItemFunc=[](MenuFuncData data){
MenuFunc useItemFunc=[&](MenuFuncData data){
MenuItemButton*button=(MenuItemButton*)data.component;
return !button->UseItem();
if(!data.game->GetPlayer()->GetLoadoutItem(data.menu.I(A::LOADOUT_SLOT)).IsBlank()){ //This loadout slot seems to have an item in it already, so deselect that one first.
data.game->GetPlayer()->ClearLoadoutItem(data.menu.I(A::LOADOUT_SLOT));
for(MenuComponent*component:components){
if(component->GetName().starts_with("item")){
MenuItemButton*button=(MenuItemButton*)component;//HACK ALERT! This is probably an item since we populated item lists using this name for the components. So we assume these are MenuItemButton classes.
if(button->selected==data.menu.I(A::LOADOUT_SLOT)){
button->selected=-1;
}
}
}
}
button->selected=data.menu.I(A::LOADOUT_SLOT);
data.game->GetPlayer()->SetLoadoutItem(button->selected,button->GetItem().Name());
return true;
};
MenuItemButton*button=NEW MenuItemButton{parentMenu,{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc};

@ -21,6 +21,8 @@ void Menu::InitializeInventoryWindow(){
Menu*inventoryWindow=CreateMenu(INVENTORY,CENTERED,windowSize);
inventoryWindow->I(A::LOADOUT_SLOT)=0;
InventoryScrollableWindowComponent*inventory=NEW InventoryScrollableWindowComponent(INVENTORY,{{1,0},{windowSize.x,float(totalSpacing*3-itemSpacing)}});
inventoryWindow->AddComponent("inventory",inventory);
Menu::AddInventoryListener(inventory,"Consumables");

@ -17,7 +17,7 @@ typedef std::function<bool(Crawler*,ItemProps)> ItemScript;
class Item{
friend class Inventory;
friend class Palyer;
friend class Player;
private:
uint32_t amt;
ItemInfo*it;

@ -3,7 +3,7 @@
#include "Crawler.h"
#include "DEFINES.h"
#include "Emitter.h"
#include "utils.h"
#include "util.h"
INCLUDE_game
INCLUDE_MONSTER_LIST

@ -1,6 +1,6 @@
#include "Emitter.h"
#include "olcUTIL_Geometry2D.h"
#include "utils.h"
#include "util.h"
#include "Crawler.h"
#include "DEFINES.h"

@ -27,7 +27,7 @@ T*Component(MenuType menu,std::string componentName){
return (T*)Menu::menus[menu]->components[componentName];
}
class Menu:IAttributable{
class Menu:public IAttributable{
friend class Crawler;
friend class Player;
friend class ItemInfo;

@ -1,10 +1,13 @@
#pragma once
#include "Menu.h"
#include "MenuLabel.h"
#include "MenuIconButton.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "Item.h"
#include "safemap.h"
#include "olcPGEX_Graphics2D.h"
#include "drawutil.h"
INCLUDE_game
INCLUDE_ITEM_DATA
@ -14,9 +17,10 @@ private:
std::vector<IT>&invRef;
int inventoryIndex=0;
public:
int selected=-1; //0-2 representing which loadout slot this item consumes. -1 means not selected.
inline MenuItemButton(MenuType parent,geom2d::rect<float>rect,std::vector<IT>&invRef,int invIndex,MenuFunc onClick)
:MenuIconButton(parent,rect,invRef.size()>invIndex?ITEM_DATA.at(invRef[invIndex]).Decal():nullptr,onClick),invRef(invRef),inventoryIndex(invIndex){
draggable=true;
draggable=false;
valid=invRef.size()>invIndex;
}
inline Item GetItem(){
@ -39,9 +43,9 @@ protected:
switch(parentMenu){
case INVENTORY:{
//There should be an itemName label to modify.
menu->components.at("itemName")->label=ITEM_DATA.at(invRef[inventoryIndex]).Name();
Component<MenuLabel>(INVENTORY,"itemName")->label=ITEM_DATA.at(invRef[inventoryIndex]).Name();
//There should be an itemDescription label to modify.
menu->components.at("itemDescription")->label=ITEM_DATA.at(invRef[inventoryIndex]).Description();
Component<MenuLabel>(INVENTORY,"itemDescription")->label=ITEM_DATA.at(invRef[inventoryIndex]).Description();
}break;
}
}
@ -51,15 +55,21 @@ protected:
switch(parentMenu){
case INVENTORY:{
//There should be an itemName label to modify.
menu->components.at("itemName")->label="";
Component<MenuLabel>(INVENTORY,"itemName")->label="";
//There should be an itemDescription label to modify.
menu->components.at("itemDescription")->label="";
Component<MenuLabel>(INVENTORY,"itemDescription")->label="";
}break;
}
}
}
}
}
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
MenuIconButton::Draw(game,parentPos);
if(selected!=-1){
drawutil::DrawCrosshair(game,{parentPos+rect.pos,rect.size},0);
}
}
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
MenuIconButton::DrawDecal(game,parentPos,focused);
if(valid){

@ -2,7 +2,7 @@
#include "MenuComponent.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
INCLUDE_game

@ -1,7 +1,7 @@
#include "Effect.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
#include "safemap.h"
INCLUDE_game

@ -6,7 +6,7 @@
#include "DEFINES.h"
#include "safemap.h"
#include "MonsterStrategyHelpers.h"
#include "utils.h"
#include "util.h"
#include "MonsterAttribute.h"
INCLUDE_ANIMATION_DATA

@ -30,4 +30,6 @@ enum class Attribute{
INDEXED_THEME,
SCROLL_OFFSET,
CLASS_SELECTION, //A class name that represents what the menu's class is.
LOADOUT_SLOT, //Which loadout slot we are selecting an item for.
ALLOW_DRAGGING, //Whether or not to allow inventory dragging.
};

@ -6,7 +6,7 @@
#include "BulletTypes.h"
#include "DEFINES.h"
#include "safemap.h"
#include "utils.h"
#include "util.h"
#include "Key.h"
#include "Menu.h"
#include "GameState.h"
@ -734,6 +734,7 @@ void Player::SetLoadoutItem(int slot,std::string itemName){
ERR("Trying to set item "+itemName+" in Loadout slot "+std::to_string(slot)+" when said item does not exist in our inventory!");
}
}
void Player::UseLoadoutItem(int slot){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(GetLoadoutItem(slot).Amt()>0){
@ -741,4 +742,9 @@ void Player::UseLoadoutItem(int slot){
GetLoadoutItem(slot).OnUseAction();
GetLoadoutItem(slot).amt--;
}
}
void Player::ClearLoadoutItem(int slot){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
loadout[slot]={};
}

@ -10,6 +10,7 @@
#include "config.h"
#include "Key.h"
#include "Class.h"
#include "Item.h"
#undef GetClassName
@ -161,6 +162,8 @@ public:
Item&GetLoadoutItem(int slot);
void SetLoadoutItem(int slot,std::string itemName);
void UseLoadoutItem(int slot);
//Blanks out this loadout item.
void ClearLoadoutItem(int slot);
//Triggers when the player has moved.
void Moved();
virtual ~Player()=default;

@ -1,7 +1,7 @@
#include "Effect.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
#include "safemap.h"
INCLUDE_game

@ -5,7 +5,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "BulletTypes.h"
#include "utils.h"
#include "util.h"
#include "config.h"
INCLUDE_MONSTER_LIST

@ -2,7 +2,7 @@
#include "MonsterStrategyHelpers.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
#include "safemap.h"
#include "Effect.h"
#include "FallingDebris.h"

@ -2,7 +2,7 @@
#include "MenuLabel.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
INCLUDE_game
INCLUDE_MONSTER_DATA

@ -5,7 +5,8 @@
#include "Menu.h"
#include "Unlock.h"
#include "ConnectionPoint.h"
#include "utils.h"
#include "util.h"
#include "drawutil.h"
#include "MenuLabel.h"
#include "EncountersSpawnListScrollableWindowComponent.h"
@ -84,37 +85,7 @@ void State_OverworldMap::Draw(Crawler*game){
}
for(ConnectionPoint&cp:connections){
if(Unlock::IsUnlocked(cp)&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&(&cp==currentConnectionPoint||cp.IsNeighbor(*currentConnectionPoint))){
float borderThickness=4;
vf2d crosshairExtension={std::min(0.25f*cp.rect.size.x-borderThickness/2,12.f),std::min(0.25f*cp.rect.size.y-borderThickness/2,12.f)};
vf2d pulsatingAmt=vf2d{1,1}*std::abs(std::sin(currentTime*3))*2;
//Lower-Left Corner
vf2d pos=cp.rect.pos+vf2d{0,cp.rect.size.y-borderThickness}+vf2d{-pulsatingAmt.x,pulsatingAmt.y};
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Lower-Right Corner
pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,cp.rect.size.y-borderThickness}+vf2d{pulsatingAmt.x,pulsatingAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Upper-Left Corner
pos=cp.rect.pos+vf2d{0,0}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Upper-Right Corner
pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulsatingAmt.x,-pulsatingAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
drawutil::DrawCrosshairDecalTransformedView(game->view,cp.rect,currentTime);
break;
}
}

@ -2,7 +2,7 @@
#include "MonsterStrategyHelpers.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
#include "util.h"
#include "MonsterAttribute.h"
typedef Attribute A;

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 2794
#define VERSION_BUILD 2812
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -6,7 +6,7 @@
#include "Crawler.h"
#include "BulletTypes.h"
#include "config.h"
#include "utils.h"
#include "util.h"
INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST

@ -0,0 +1,137 @@
#include "drawutil.h"
#include "Crawler.h"
#include "DEFINES.h"
INCLUDE_game
void drawutil::DrawCrosshair(Crawler*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt,float borderThickness){
vf2d crosshairExtension={std::min(0.25f*rect.size.x-borderThickness/2,12.f),std::min(0.25f*rect.size.y-borderThickness/2,12.f)};
vf2d pulseAmt=vf2d{1,1}*std::abs(std::sin(accTime*3))*2;
//Lower-Left Corner
vf2d pos=rect.pos+vf2d{0,rect.size.y-borderThickness}+vf2d{-pulseAmt.x,pulseAmt.y};
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRect(pos,size,RED);
pos=vf2d{pos.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->FillRect(pos,size,RED);
//Lower-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,rect.size.y-borderThickness}+vf2d{pulseAmt.x,pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRect(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->FillRect(pos,size,RED);
//Upper-Left Corner
pos=rect.pos+vf2d{0,0}+vf2d{-pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRect(pos,size,RED);
pos=vf2d{pos.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->FillRect(pos,size,RED);
//Upper-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRect(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->FillRect(pos,size,RED);
};
void drawutil::DrawCrosshairTransformedView(olc::TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt,float borderThickness){
vf2d crosshairExtension={std::min(0.25f*rect.size.x-borderThickness/2,12.f),std::min(0.25f*rect.size.y-borderThickness/2,12.f)};
vf2d pulseAmt=vf2d{1,1}*std::abs(std::sin(accTime*3))*2;
//Lower-Left Corner
vf2d pos=rect.pos+vf2d{0,rect.size.y-borderThickness}+vf2d{-pulseAmt.x,pulseAmt.y};
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRect(pos,size,RED);
pos=vf2d{pos.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRect(pos,size,RED);
//Lower-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,rect.size.y-borderThickness}+vf2d{pulseAmt.x,pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRect(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRect(pos,size,RED);
//Upper-Left Corner
pos=rect.pos+vf2d{0,0}+vf2d{-pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRect(pos,size,RED);
pos=vf2d{pos.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRect(pos,size,RED);
//Upper-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRect(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRect(pos,size,RED);
}
void drawutil::DrawCrosshairDecal(Crawler*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt,float borderThickness){
vf2d crosshairExtension={std::min(0.25f*rect.size.x-borderThickness/2,12.f),std::min(0.25f*rect.size.y-borderThickness/2,12.f)};
vf2d pulseAmt=vf2d{1,1}*std::abs(std::sin(accTime*3))*2;
//Lower-Left Corner
vf2d pos=rect.pos+vf2d{0,rect.size.y-borderThickness}+vf2d{-pulseAmt.x,pulseAmt.y};
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->FillRectDecal(pos,size,RED);
//Lower-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,rect.size.y-borderThickness}+vf2d{pulseAmt.x,pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->FillRectDecal(pos,size,RED);
//Upper-Left Corner
pos=rect.pos+vf2d{0,0}+vf2d{-pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->FillRectDecal(pos,size,RED);
//Upper-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->FillRectDecal(pos,size,RED);
};
void drawutil::DrawCrosshairDecalTransformedView(olc::TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt,float borderThickness){
vf2d crosshairExtension={std::min(0.25f*rect.size.x-borderThickness/2,12.f),std::min(0.25f*rect.size.y-borderThickness/2,12.f)};
vf2d pulseAmt=vf2d{1,1}*std::abs(std::sin(accTime*3))*2;
//Lower-Left Corner
vf2d pos=rect.pos+vf2d{0,rect.size.y-borderThickness}+vf2d{-pulseAmt.x,pulseAmt.y};
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Lower-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,rect.size.y-borderThickness}+vf2d{pulseAmt.x,pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Upper-Left Corner
pos=rect.pos+vf2d{0,0}+vf2d{-pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
//Upper-Right Corner
pos=rect.pos+vf2d{rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulseAmt.x,-pulseAmt.y};
size={borderThickness+crosshairExtension.x,borderThickness};
game->view.FillRectDecal(pos,size,RED);
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
}

@ -0,0 +1,11 @@
#pragma once
#include "olcUTIL_Geometry2D.h"
#include "olcPGEX_TransformedView.h"
class Crawler;
namespace drawutil{
void DrawCrosshair(Crawler*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawCrosshairTransformedView(TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawCrosshairDecal(Crawler*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawCrosshairDecalTransformedView(TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
}

@ -1,4 +1,4 @@
#include "utils.h"
#include "util.h"
#include "olcPixelGameEngine.h"
float util::random(float range){
Loading…
Cancel
Save