Skip to content

Commit 983953f

Browse files
committed
Add money bag easter eggs
- Add money bag easter eggs - Make hud flashing double shot icon for a short time when player just obtained it
1 parent 59226b4 commit 983953f

26 files changed

+198
-70
lines changed

src/GameCuaTao/Castlevania.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
<ClCompile Include="Castlevania\Scenes\Stages\CrossCutscene.cpp" />
235235
<ClCompile Include="Castlevania\Scenes\Stages\Cutscene.cpp" />
236236
<ClCompile Include="Castlevania\Scenes\Stages\GoToCastleCutScene.cpp" />
237+
<ClCompile Include="Castlevania\Scenes\Stages\HiddenMoneyBagCutscene.cpp" />
237238
<ClCompile Include="Castlevania\Scenes\Stages\ResetCutscene.cpp" />
238239
<ClCompile Include="Castlevania\Scenes\Stages\NextMapCutscene.cpp" />
239240
<ClCompile Include="Castlevania\Scenes\Stages\NextRoomCutscene.cpp" />
@@ -410,6 +411,7 @@
410411
<ClInclude Include="Castlevania\Scenes\Stages\CrossCutscene.h" />
411412
<ClInclude Include="Castlevania\Scenes\Stages\GoToCastleCutScene.h" />
412413
<ClInclude Include="Castlevania\Scenes\Stages\Cutscene.h" />
414+
<ClInclude Include="Castlevania\Scenes\Stages\HiddenMoneyBagCutscene.h" />
413415
<ClInclude Include="Castlevania\Scenes\Stages\ResetCutscene.h" />
414416
<ClInclude Include="Castlevania\Scenes\Stages\NextMapCutscene.h" />
415417
<ClInclude Include="Castlevania\Scenes\Stages\NextRoomCutscene.h" />

src/GameCuaTao/Castlevania.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@
489489
<ClCompile Include="Castlevania\Models\Systems\Rendering\EntityRenderingSystem.cpp">
490490
<Filter>Source Files</Filter>
491491
</ClCompile>
492+
<ClCompile Include="Castlevania\Scenes\Stages\HiddenMoneyBagCutscene.cpp">
493+
<Filter>Source Files</Filter>
494+
</ClCompile>
492495
</ItemGroup>
493496
<ItemGroup>
494497
<ClInclude Include="Library\pugixml.hpp">
@@ -1133,6 +1136,9 @@
11331136
<ClInclude Include="Castlevania\Models\Systems\Rendering\EntityRenderingSystem.h">
11341137
<Filter>Header Files</Filter>
11351138
</ClInclude>
1139+
<ClInclude Include="Castlevania\Scenes\Stages\HiddenMoneyBagCutscene.h">
1140+
<Filter>Header Files</Filter>
1141+
</ClInclude>
11361142
</ItemGroup>
11371143
<ItemGroup>
11381144
<None Include="cpp.hint" />

src/GameCuaTao/Castlevania/Content/TiledMaps/Stage_01/Courtyard.tmx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<map version="1.2" tiledversion="1.2.1" orientation="orthogonal" renderorder="right-down" width="24" height="6" tilewidth="64" tileheight="64" infinite="0" backgroundcolor="#3c3c3c" nextlayerid="14" nextobjectid="51">
33
<tileset firstgid="1" source="../Simon.tsx"/>
4-
<tileset firstgid="49" source="../Brazier.tsx"/>
5-
<tileset firstgid="51" source="../Money_Bag.tsx"/>
6-
<tileset firstgid="54" source="../Static_Objects.tsx"/>
4+
<tileset firstgid="73" source="../Brazier.tsx"/>
5+
<tileset firstgid="75" source="../Money_Bag.tsx"/>
6+
<tileset firstgid="78" source="../Static_Objects.tsx"/>
77
<layer id="1" name="TileLayer01" width="24" height="6">
88
<data encoding="base64" compression="gzip">
99
H4sIAAAAAAAACmNgGAWjgHwAAPMY7ENAAgAA
@@ -13,46 +13,44 @@
1313
<image source="Courtyard.png" width="1536" height="365"/>
1414
</imagelayer>
1515
<objectgroup id="4" name="Entities">
16-
<object id="15" name="Brazier" type="Brazier" gid="49" x="175" y="290" width="32" height="64">
16+
<object id="15" name="Brazier" type="Brazier" gid="73" x="175" y="290" width="32" height="64">
1717
<properties>
1818
<property name="Item" value="LargeHeart"/>
1919
</properties>
2020
</object>
21-
<object id="16" name="Brazier" type="Brazier" gid="49" x="434" y="290" width="32" height="64">
21+
<object id="16" name="Brazier" type="Brazier" gid="73" x="434" y="290" width="32" height="64">
2222
<properties>
2323
<property name="Item" value="WhipPowerup"/>
2424
</properties>
2525
</object>
26-
<object id="17" name="Brazier" type="Brazier" gid="49" x="685" y="290" width="32" height="64">
26+
<object id="17" name="Brazier" type="Brazier" gid="73" x="685" y="290" width="32" height="64">
2727
<properties>
2828
<property name="Item" value="WhipPowerup"/>
2929
</properties>
3030
</object>
31-
<object id="18" name="Brazier" type="Brazier" gid="49" x="942" y="290" width="32" height="64">
31+
<object id="18" name="Brazier" type="Brazier" gid="73" x="942" y="290" width="32" height="64">
3232
<properties>
3333
<property name="Item" value="LargeHeart"/>
3434
</properties>
3535
</object>
36-
<object id="19" name="Brazier" type="Brazier" gid="49" x="1199" y="290" width="32" height="64">
36+
<object id="19" name="Brazier" type="Brazier" gid="73" x="1199" y="290" width="32" height="64">
3737
<properties>
3838
<property name="Item" value="DaggerItem"/>
3939
</properties>
4040
</object>
41-
<object id="38" name="MoneyBag" type="FlashingMoneyBag" gid="53" x="1250" y="317" width="30" height="30"/>
4241
</objectgroup>
4342
<objectgroup id="11" name="Foregrounds">
44-
<object id="44" name="Castle" type="Castle" gid="55" x="1408" y="288" width="96" height="288">
43+
<object id="44" name="Castle" type="Castle" gid="79" x="1408" y="288" width="96" height="288">
4544
<properties>
4645
<property name="Visibility" type="bool" value="false"/>
4746
</properties>
4847
</object>
49-
<object id="45" name="DirtBlock" type="DirtBlock" gid="54" x="1248" y="320" width="32" height="32"/>
48+
<object id="45" name="DirtBlock" type="DirtBlock" gid="78" x="1248" y="320" width="32" height="32"/>
5049
</objectgroup>
5150
<objectgroup id="3" name="Bounds">
5251
<object id="20" name="Ground" type="Boundary" x="0" y="288" width="1536" height="32"/>
5352
<object id="22" name="LeftBorder" type="Boundary" x="0" y="0" width="3" height="288"/>
5453
<object id="24" name="RightBorder" type="Boundary" x="1504" y="0" width="32" height="288"/>
55-
<object id="48" name="Block" type="Boundary" x="1250" y="320" width="32" height="32"/>
5654
</objectgroup>
5755
<objectgroup id="9" name="Triggers">
5856
<object id="37" name="MoneyBagTrigger" type="Trigger" x="1424" y="278" width="32" height="10">
@@ -74,7 +72,8 @@
7472
</object>
7573
</objectgroup>
7674
<objectgroup id="8" name="Locations">
77-
<object id="14" name="Entrypoint" type="Position" gid="4" x="69" y="288" width="60" height="66"/>
78-
<object id="47" name="Entrypoint1" type="Position" gid="4" x="1021" y="288" width="60" height="66"/>
75+
<object id="14" name="Entrypoint1" type="Position" gid="4" x="69" y="288" width="60" height="66"/>
76+
<object id="47" name="Entrypoint" type="Position" gid="4" x="1021" y="288" width="60" height="66"/>
77+
<object id="38" name="MoneyBag" type="Position" gid="77" x="1250" y="318" width="30" height="30"/>
7978
</objectgroup>
8079
</map>

src/GameCuaTao/Castlevania/Content/TiledMaps/Stage_01/Great_Hall.tmx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<property name="SpawnObject" value="Zombie"/>
1818
</properties>
1919
</object>
20-
<object id="29" name="BatSpawnArea" type="SpawnArea" x="3072" y="0" width="1008" height="166">
20+
<object id="29" name="BatSpawnArea" type="SpawnArea" x="3072" y="0" width="1008" height="277">
2121
<properties>
2222
<property name="SpawnObject" value="VampireBat"/>
2323
</properties>
@@ -475,7 +475,7 @@
475475
<object id="9" name="Entrypoint2" type="Position" gid="75" x="64" y="320" width="60" height="66"/>
476476
<object id="110" name="Underground_02" type="Position" gid="2147483658" x="3808" y="351" width="60" height="66"/>
477477
<object id="111" name="Underground_01" type="Position" gid="2147483658" x="3168" y="351" width="60" height="66"/>
478-
<object id="120" name="Entrypoint" type="Position" gid="75" x="5044" y="310.83" width="60" height="66"/>
478+
<object id="120" name="Entrypoint" type="Position" gid="75" x="5050" y="310.83" width="60" height="66"/>
479479
<object id="121" name="Checkpoint_01" type="Position" gid="75" x="3151" y="128" width="60" height="66"/>
480480
<object id="122" name="Checkpoint_02" type="Position" gid="75" x="4169" y="128" width="60" height="66"/>
481481
<object id="125" name="Entrypoint1" type="Position" gid="75" x="2944" y="124" width="60" height="66"/>

src/GameCuaTao/Castlevania/Content/TiledMaps/Stage_01/Underground.tmx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<map version="1.2" tiledversion="1.2.1" orientation="orthogonal" renderorder="right-down" width="16" height="6" tilewidth="64" tileheight="64" infinite="0" nextlayerid="9" nextobjectid="36">
2+
<map version="1.2" tiledversion="1.2.1" orientation="orthogonal" renderorder="right-down" width="16" height="6" tilewidth="64" tileheight="64" infinite="0" nextlayerid="9" nextobjectid="41">
33
<tileset firstgid="1" source="../Candle.tsx"/>
44
<tileset firstgid="3" source="../Simon.tsx"/>
55
<tileset firstgid="75" source="../Static_Objects.tsx"/>
6+
<tileset firstgid="83" source="../Money_Bag.tsx"/>
67
<layer id="1" name="TileLayer1" width="16" height="6">
78
<data encoding="base64">
89
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -77,7 +78,10 @@
7778
</properties>
7879
</object>
7980
</objectgroup>
80-
<objectgroup id="8" name="Foregrounds"/>
81+
<objectgroup id="8" name="Foregrounds">
82+
<object id="39" name="Block" type="BrickBlock" gid="81" x="672" y="192" width="32" height="32"/>
83+
<object id="40" name="Block" type="BrickBlock" gid="81" x="704" y="192" width="32" height="32"/>
84+
</objectgroup>
8185
<objectgroup id="6" name="Triggers">
8286
<object id="19" name="StairUp" type="Trigger" x="176" y="64" width="32" height="32">
8387
<properties>
@@ -105,10 +109,16 @@
105109
<property name="SpawnPoint" value="Underground_02"/>
106110
</properties>
107111
</object>
112+
<object id="36" name="MoneyBagTrigger" type="Trigger" x="912" y="278" width="32" height="10">
113+
<properties>
114+
<property name="Enabled" type="bool" value="true"/>
115+
</properties>
116+
</object>
108117
</objectgroup>
109118
<objectgroup id="7" name="Locations">
110119
<object id="24" name="GreatHall_02" type="Position" gid="14" x="738" y="40" width="60" height="66"/>
111120
<object id="23" name="GreatHall_01" type="Position" gid="14" x="98" y="40" width="60" height="66"/>
112121
<object id="34" name="Entrypoint" type="Position" gid="6" x="20" y="160" width="60" height="66"/>
122+
<object id="37" name="MoneyBag" type="Position" gid="85" x="688" y="192" width="30" height="30"/>
113123
</objectgroup>
114124
</map>

src/GameCuaTao/Castlevania/Hud.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using namespace Castlevania;
66

77
constexpr auto HUD_HEIGHT = 83;
8+
constexpr auto POWERUP_FLASHING_TIME = 2500;
89

910
const auto DEFAULT_PLAYER_DATA = PlayerData{};
1011
const auto DEFAULT_BOSS_HEALTH = MAX_HEALTH;
@@ -122,35 +123,33 @@ void Hud::Draw(SpriteExtensions &spriteBatch)
122123

123124
spriteBatch.DrawString(*hudFont, GetHeartCountText(), heartTextPosition, Color::White(), false);
124125
spriteBatch.DrawString(*hudFont, GetLiveCountText(), liveTextPosition, Color::White(), false);
125-
126-
auto powerupTexture = GetPowerupTexture();
127-
if (powerupTexture != nullptr)
128-
spriteBatch.Draw(*powerupTexture, GetPowerupPosition(*powerupTexture), Color::White(), false);
126+
127+
DrawPowerup(spriteBatch);
129128
}
130129

131130
std::string Hud::GetScoreText()
132131
{
133-
return "SCORE-" + padZero(data->playerData->score, 6);
132+
return "SCORE-" + PadZero(data->playerData->score, 6);
134133
}
135134

136135
std::string Hud::GetTimeText()
137136
{
138-
return "TIME " + padZero(data->gameplayData->timeLeft.GetCounter(), 4);
137+
return "TIME " + PadZero(data->gameplayData->timeLeft.GetCounter(), 4);
139138
}
140139

141140
std::string Hud::GetStageText()
142141
{
143-
return "STAGE " + padZero(data->gameplayData->stage, 2);
142+
return "STAGE " + PadZero(data->gameplayData->stage, 2);
144143
}
145144

146145
std::string Hud::GetHeartCountText()
147146
{
148-
return "-" + padZero(data->playerData->hearts, 2);
147+
return "-" + PadZero(data->playerData->hearts, 2);
149148
}
150149

151150
std::string Hud::GetLiveCountText()
152151
{
153-
return "P-" + padZero(data->playerData->lives, 2);
152+
return "P-" + PadZero(data->playerData->lives, 2);
154153
}
155154

156155
std::shared_ptr<Texture> Hud::GetWeaponTexture()
@@ -234,7 +233,31 @@ void Hud::DrawHealthBars(SpriteExtensions &spriteBatch)
234233
}
235234
}
236235

237-
std::string Hud::padZero(int number, int paddingCount)
236+
void Hud::DrawPowerup(SpriteExtensions &spriteBatch)
237+
{
238+
auto currentPowerupTexture = GetPowerupTexture();
239+
240+
if (currentPowerupTexture == nullptr)
241+
return;
242+
243+
if (powerupTexture == nullptr && currentPowerupTexture != nullptr)
244+
powerupFlashingTimer.Start();
245+
246+
if (powerupFlashingTimer.IsRunning())
247+
{
248+
if (powerupFlashingTimer.ElapsedMilliseconds() >= POWERUP_FLASHING_TIME)
249+
powerupFlashingTimer.Reset();
250+
else
251+
spriteBatch.Draw(*currentPowerupTexture, GetPowerupPosition(*currentPowerupTexture),
252+
Stopwatch::Every(60) ? Color::White() : Color::Transparent(), false);
253+
}
254+
else
255+
spriteBatch.Draw(*currentPowerupTexture, GetPowerupPosition(*currentPowerupTexture), Color::White(), false);
256+
257+
powerupTexture = currentPowerupTexture;
258+
}
259+
260+
std::string Hud::PadZero(int number, int paddingCount)
238261
{
239262
auto sstream = std::stringstream{};
240263

src/GameCuaTao/Castlevania/Hud.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace Castlevania
4545
std::shared_ptr<Texture> holyWaterTexture;
4646
std::shared_ptr<Texture> stopwatchTexture;
4747
std::shared_ptr<Texture> doubleShotTexture;
48+
std::shared_ptr<Texture> powerupTexture;
4849

4950
std::unique_ptr<Sprite> playerFullBlock;
5051
std::unique_ptr<Sprite> bossFullBlock;
@@ -69,12 +70,16 @@ namespace Castlevania
6970
std::string GetHeartCountText();
7071
std::string GetLiveCountText();
7172

73+
Stopwatch powerupFlashingTimer;
74+
7275
std::shared_ptr<Texture> GetWeaponTexture();
7376
std::shared_ptr<Texture> GetPowerupTexture();
7477
Vector2 GetWeaponPosition(Texture &weaponTexture);
7578
Vector2 GetPowerupPosition(Texture &powerupTexture);
79+
7680
void DrawHealthBars(SpriteExtensions &spriteBatch);
81+
void DrawPowerup(SpriteExtensions &spriteBatch);
7782

78-
std::string padZero(int number, int paddingCount); // (123, 5) -> "00123"
83+
std::string PadZero(int number, int paddingCount); // (123, 5) -> "00123"
7984
};
8085
}

src/GameCuaTao/Castlevania/Models/Characters/Player/PlayerResponseSystem.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ void PlayerResponseSystem::OnCollideWithTrigger(CollisionResult &result, Respons
255255
OnCollideWithNextMapTrigger(trigger);
256256
break;
257257

258+
case TriggerType::MONEY_BAG_EASTER_EGG:
259+
OnCollideWithMoneyBagTrigger(trigger);
260+
break;
261+
258262
case TriggerType::CASTLE_ENTRANCE:
259263
OnCollideWithCastleEntranceTrigger(trigger);
260264
break;
@@ -469,18 +473,18 @@ void PlayerResponseSystem::OnCollideWithStairDownTrigger(Trigger &trigger)
469473

470474
void PlayerResponseSystem::OnCollideWithNextMapTrigger(Trigger &trigger)
471475
{
472-
if (trigger.Enabled())
473-
{
474-
parent.Notify(NEXT_MAP_CUTSCENE_STARTED);
475-
trigger.Enabled(false);
476-
}
476+
parent.Notify(NEXT_MAP_CUTSCENE_STARTED);
477+
trigger.GetBody().Enabled(false);
478+
}
479+
480+
void PlayerResponseSystem::OnCollideWithMoneyBagTrigger(Trigger &trigger)
481+
{
482+
parent.Notify(HIDDEN_MONEY_BAG_FOUND);
483+
trigger.GetBody().Enabled(false);
477484
}
478485

479486
void PlayerResponseSystem::OnCollideWithCastleEntranceTrigger(Trigger &trigger)
480487
{
481-
if (trigger.Enabled())
482-
{
483-
parent.Notify(GO_TO_CASTLE_CUTSCENE_STARTED);
484-
trigger.Enabled(false);
485-
}
488+
parent.Notify(GO_TO_CASTLE_CUTSCENE_STARTED);
489+
trigger.GetBody().Enabled(false);
486490
}

src/GameCuaTao/Castlevania/Models/Characters/Player/PlayerResponseSystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace Castlevania
4848
void OnCollideWithStairUpTrigger(Trigger &trigger);
4949
void OnCollideWithStairDownTrigger(Trigger &trigger);
5050
void OnCollideWithNextMapTrigger(Trigger &trigger);
51+
void OnCollideWithMoneyBagTrigger(Trigger &trigger);
5152
void OnCollideWithCastleEntranceTrigger(Trigger &trigger);
5253
};
5354
}

src/GameCuaTao/Castlevania/Models/Factories/ObjectFactory.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949

5050
using namespace Castlevania;
5151

52-
constexpr auto ITEM_FALL_SPEED = 225.0f;
53-
5452
ObjectFactory::ObjectFactory(ContentManager &content) : content{ content }
5553
{
5654
effectFactory = std::make_unique<EffectFactory>(content);
@@ -1003,6 +1001,18 @@ std::unique_ptr<GameObject> ObjectFactory::CreateCastle(Vector2 position)
10031001
return object;
10041002
}
10051003

1004+
std::unique_ptr<GameObject> ObjectFactory::CreateBrickBlock(Vector2 position)
1005+
{
1006+
auto object = std::make_unique<GameObject>(ObjectId::Unknown);
1007+
auto renderingSystem = std::make_unique<SpriteRenderingSystem>(*object, "TiledMaps/Stage_01/Block.png");
1008+
1009+
object->SetPosition(position);
1010+
object->Attach(std::move(renderingSystem));
1011+
object->LoadContent(content);
1012+
1013+
return object;
1014+
}
1015+
10061016
std::unique_ptr<GameObject> ObjectFactory::CreateDirtBlock(Vector2 position)
10071017
{
10081018
auto object = std::make_unique<GameObject>(ObjectId::DirtBlock);
@@ -1085,7 +1095,6 @@ std::unique_ptr<SpawnArea> ObjectFactory::ConstructSpawnArea(ObjectId type)
10851095
object = std::make_unique<FishmanSpawnArea>(*this);
10861096
stats = content.Load<Dictionary>("GameStats/SpawnAreas/FishmanSpawnArea.xml");
10871097
break;
1088-
return object;
10891098
}
10901099

10911100
default:

0 commit comments

Comments
 (0)