Skip to content

Commit

Permalink
add collision grid (build successfully but not playable yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
NearHuscarl committed Dec 22, 2018
1 parent 04f91c2 commit 790b565
Show file tree
Hide file tree
Showing 87 changed files with 929 additions and 615 deletions.
16 changes: 7 additions & 9 deletions src/GameCuaTao/Castlevania.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@
<ClCompile Include="Castlevania\Models\Characters\Enemies\VampireBatRenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\Characters\Enemies\Zombie.cpp" />
<ClCompile Include="Castlevania\Models\Characters\Enemies\ZombieResponseSystem.cpp" />
<ClCompile Include="Castlevania\Models\Characters\Player\Player.cpp" />
<ClCompile Include="Castlevania\Models\Facing.cpp" />
<ClCompile Include="Castlevania\Models\Factories\ObjectFactory.cpp" />
<ClCompile Include="Castlevania\Hud.cpp" />
<ClCompile Include="Castlevania\Models\Characters\Player\PlayerRenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\GameObject.cpp" />
<ClCompile Include="Castlevania\Models\Items\Door.cpp" />
<ClCompile Include="Castlevania\Models\Items\DoorRenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\Items\Fireball.cpp" />
Expand All @@ -205,7 +207,6 @@
<ClCompile Include="Castlevania\Models\Spawners\VampireBatSpawnArea.cpp" />
<ClCompile Include="Castlevania\Models\Spawners\ZombieSpawnArea.cpp" />
<ClCompile Include="Castlevania\Models\Systems\CollisionResponse\ResponseSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Collision\EntityCollisionSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Collision\SimpleCollisionSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Collision\StandardCollisionSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Control\ControlSystem.cpp" />
Expand All @@ -217,9 +218,7 @@
<ClCompile Include="Castlevania\Models\Systems\Rendering\EffectRenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Rendering\RenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Rendering\SpriteRenderingSystem.cpp" />
<ClCompile Include="Castlevania\Models\Systems\Collision\StaticCollisionSystem.cpp" />
<ClCompile Include="Castlevania\Models\Trigger.cpp" />
<ClCompile Include="Castlevania\Models\UpdateData.cpp" />
<ClCompile Include="Castlevania\Models\Weapons\DaggerResponseSystem.cpp" />
<ClCompile Include="Castlevania\Models\Weapons\RangedWeapon.cpp" />
<ClCompile Include="Castlevania\Models\Weapons\WhipCollisionSystem.cpp" />
Expand Down Expand Up @@ -258,8 +257,6 @@
<ClCompile Include="Direct2DGame\Extensions\Animations\AnimatedSprite.cpp" />
<ClCompile Include="Direct2DGame\Extensions\Animations\AnimationFactory.cpp" />
<ClCompile Include="Direct2DGame\Content\AnimationFactoryReader.cpp" />
<ClCompile Include="Castlevania\Models\GameObject.cpp" />
<ClCompile Include="Castlevania\Models\Characters\Player\Player.cpp" />
<ClCompile Include="Castlevania\Scenes\AbstractScene.cpp" />
<ClCompile Include="Castlevania\Scenes\GameplayScene.cpp" />
<ClCompile Include="Castlevania\Scenes\IntroScene.cpp" />
Expand Down Expand Up @@ -344,12 +341,14 @@
<ClInclude Include="Castlevania\Models\Characters\Enemies\Zombie.h" />
<ClInclude Include="Castlevania\Models\Characters\Enemies\ZombieResponseSystem.h" />
<ClInclude Include="Castlevania\Models\Characters\Player\NearbyObjects.h" />
<ClInclude Include="Castlevania\Models\Characters\Player\Player.h" />
<ClInclude Include="Castlevania\Models\Facing.h" />
<ClInclude Include="Castlevania\Models\Factories\ObjectCollection.h" />
<ClInclude Include="Castlevania\Models\Factories\ObjectFactory.h" />
<ClInclude Include="Castlevania\Hud.h" />
<ClInclude Include="Castlevania\Models\Characters\Player\PlayerData.h" />
<ClInclude Include="Castlevania\Models\Characters\Player\PlayerRenderingSystem.h" />
<ClInclude Include="Castlevania\Models\GameObject.h" />
<ClInclude Include="Castlevania\Models\IBoss.h" />
<ClInclude Include="Castlevania\Models\Items\Door.h" />
<ClInclude Include="Castlevania\Models\Items\DoorRenderingSystem.h" />
Expand All @@ -369,7 +368,6 @@
<ClInclude Include="Castlevania\Models\Spawners\VampireBatSpawnArea.h" />
<ClInclude Include="Castlevania\Models\Spawners\ZombieSpawnArea.h" />
<ClInclude Include="Castlevania\Models\Systems\CollisionResponse\ResponseSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Collision\EntityCollisionSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Collision\SimpleCollisionSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Collision\StandardCollisionSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Control\ControlSystem.h" />
Expand All @@ -384,7 +382,6 @@
<ClInclude Include="Castlevania\Models\Systems\Rendering\AnimationRenderingSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Rendering\RenderingSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Rendering\SpriteRenderingSystem.h" />
<ClInclude Include="Castlevania\Models\Systems\Collision\StaticCollisionSystem.h" />
<ClInclude Include="Castlevania\Models\Trigger.h" />
<ClInclude Include="Castlevania\Models\TriggerType.h" />
<ClInclude Include="Castlevania\Models\UpdateData.h" />
Expand All @@ -411,8 +408,10 @@
<ClInclude Include="Castlevania\Utilities\CollisionGrid.h" />
<ClInclude Include="Castlevania\Utilities\CollisionCell.h" />
<ClInclude Include="Castlevania\Utilities\CppExtensions.h" />
<ClInclude Include="Castlevania\Utilities\CollisionObject.h" />
<ClInclude Include="Castlevania\Utilities\IObserver.h" />
<ClInclude Include="Castlevania\Utilities\MapSettings.h" />
<ClInclude Include="Castlevania\Scenes\Stages\StageObject.h" />
<ClInclude Include="Castlevania\Utilities\Subject.h" />
<ClInclude Include="Castlevania\Utilities\Timer.h" />
<ClInclude Include="Castlevania\Utilities\TypeConverter.h" />
Expand Down Expand Up @@ -442,8 +441,6 @@
<ClInclude Include="Direct2DGame\Extensions\Animations\AnimatedSprite.h" />
<ClInclude Include="Direct2DGame\Extensions\Animations\AnimationFactory.h" />
<ClInclude Include="Direct2DGame\Content\AnimationFactoryReader.h" />
<ClInclude Include="Castlevania\Models\GameObject.h" />
<ClInclude Include="Castlevania\Models\Characters\Player\Player.h" />
<ClInclude Include="Castlevania\Settings\Animations.h" />
<ClInclude Include="Castlevania\Scenes\AbstractScene.h" />
<ClInclude Include="Castlevania\Scenes\GameplayScene.h" />
Expand Down Expand Up @@ -522,6 +519,7 @@
<ClInclude Include="Library\pugixml\pugixml.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
<None Include="cpp.hint" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
46 changes: 19 additions & 27 deletions src/GameCuaTao/Castlevania.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@
<ClCompile Include="Castlevania\Models\Characters\Player\Controller.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Characters\Player\Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\GameObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Direct2DGame\Extensions\RectF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -201,9 +195,6 @@
<ClCompile Include="Castlevania\Models\Systems\Collision\CollisionSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Systems\Collision\StaticCollisionSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Systems\Rendering\AnimationRenderingSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -219,9 +210,6 @@
<ClCompile Include="Castlevania\Models\Weapons\WhipFlashingRenderingSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Systems\Collision\EntityCollisionSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Systems\Collision\StandardCollisionSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -285,9 +273,6 @@
<ClCompile Include="Castlevania\Scenes\Stages\Stage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\UpdateData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Systems\Rendering\BoundingboxRenderingSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -480,6 +465,12 @@
<ClCompile Include="Castlevania\Utilities\CollisionCell.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\Characters\Player\Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Castlevania\Models\GameObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Library\pugixml.hpp">
Expand Down Expand Up @@ -710,12 +701,6 @@
<ClInclude Include="Castlevania\Models\Characters\Player\Controller.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Characters\Player\Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\GameObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\IGameObject.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -758,9 +743,6 @@
<ClInclude Include="Castlevania\Models\Systems\Movement\IMovementSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Systems\Collision\StaticCollisionSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Systems\Rendering\AnimationRenderingSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -785,9 +767,6 @@
<ClInclude Include="Castlevania\Models\Weapons\WhipFlashingRenderingSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Systems\Collision\EntityCollisionSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Systems\Collision\StandardCollisionSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -1100,8 +1079,21 @@
<ClInclude Include="Castlevania\Utilities\CollisionCell.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Scenes\Stages\StageObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Utilities\CollisionObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\Characters\Player\Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Castlevania\Models\GameObject.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
<None Include="ClassDiagram.cd" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="50">
<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">
<tileset firstgid="1" source="../Simon.tsx"/>
<tileset firstgid="49" source="../Brazier.tsx"/>
<tileset firstgid="51" source="../Money_Bag.tsx"/>
Expand Down Expand Up @@ -50,7 +50,7 @@
</objectgroup>
<objectgroup id="3" name="Bounds">
<object id="20" name="Ground" type="Boundary" x="0" y="288" width="1536" height="32"/>
<object id="22" name="LeftBorder" type="Boundary" x="-22" y="0" width="25" height="288"/>
<object id="22" name="LeftBorder" type="Boundary" x="0" y="0" width="3" height="288"/>
<object id="24" name="RightBorder" type="Boundary" x="1504" y="0" width="32" height="288"/>
<object id="48" name="Block" type="Boundary" x="1250" y="320" width="32" height="32"/>
</objectgroup>
Expand All @@ -75,6 +75,6 @@
</objectgroup>
<objectgroup id="8" name="Locations">
<object id="14" name="Entrypoint1" type="Position" gid="4" x="69" y="288" width="60" height="66"/>
<object id="47" name="Entrypoint" type="Position" gid="4" x="1033" y="283" width="60" height="66"/>
<object id="47" name="Entrypoint" type="Position" gid="4" x="1021" y="136" width="60" height="66"/>
</objectgroup>
</map>
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<object id="77" name="Wall" type="Boundary" x="3056" y="0" width="32" height="32"/>
<object id="78" name="Wall" type="Boundary" x="3056" y="160" width="32" height="160"/>
<object id="79" name="Wall" type="Boundary" x="4080" y="160" width="16" height="160"/>
<object id="80" name="Wall" type="Boundary" x="-30" y="0" width="32" height="320"/>
<object id="80" name="Wall" type="Boundary" x="0" y="0" width="2" height="320"/>
<object id="81" name="Wall" type="Boundary" x="5616" y="0" width="16" height="320"/>
</objectgroup>
<objectgroup id="4" name="Entities">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<object id="6" name="Platform" type="Boundary" x="960" y="224" width="64" height="32"/>
<object id="7" name="Platform" type="Boundary" x="896" y="288" width="64" height="32"/>
<object id="26" name="Wall" type="Boundary" x="1006" y="0" width="18" height="224"/>
<object id="27" name="Wall" type="Boundary" x="-28" y="0" width="32" height="160"/>
<object id="27" name="Wall" type="Boundary" x="0" y="0" width="4" height="160"/>
<object id="33" name="Floor" type="Boundary" x="0" y="365" width="1024" height="16"/>
</objectgroup>
<objectgroup id="2" name="Entities">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ int Enemy::GetExp()
return exp;
}

void Enemy::Update(GameTime gameTime, UpdateData &updateData)
void Enemy::Update(UpdateData &updateData)
{
GameObject::Update(gameTime, updateData);
GameObject::Update(updateData);

auto viewport = updateData.viewport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Castlevania
void SetExp(int exp);
int GetExp();

virtual void Update(GameTime gameTime, UpdateData &updateData) override;
virtual void Update(UpdateData &updateData) override;
void TakeDamage(int damage);
void Die();

Expand Down
11 changes: 6 additions & 5 deletions src/GameCuaTao/Castlevania/Models/Characters/Enemies/Fishman.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Fishman.h"
#include "../../UpdateData.h"
#include "../../Settings.h"
#include "../../../Utilities/CollisionGrid.h"

using namespace Castlevania;

Expand All @@ -21,9 +22,9 @@ FishmanState Fishman::GetFishmanState()
return fishmanState;
}

void Fishman::Update(GameTime gameTime, UpdateData &updateData)
void Fishman::Update(UpdateData &updateData)
{
Enemy::Update(gameTime, updateData);
Enemy::Update(updateData);

switch (fishmanState)
{
Expand All @@ -40,7 +41,7 @@ void Fishman::Update(GameTime gameTime, UpdateData &updateData)
else if (shootingTimer.ElapsedMilliseconds() > RELEASE_FIREBALL_TIME)
{
if (fireball != nullptr)
ReleaseFireball(*updateData.objectCollection);
ReleaseFireball();
}
break;
}
Expand Down Expand Up @@ -95,7 +96,7 @@ void Fishman::SetFishmanState(FishmanState state)
SendMessageToSystems(MOVE_STATE_CHANGED);
}

void Fishman::ReleaseFireball(ObjectCollection &objectCollection)
void Fishman::ReleaseFireball()
{
fireball->SetFacing(facing);

Expand All @@ -114,5 +115,5 @@ void Fishman::ReleaseFireball(ObjectCollection &objectCollection)
else
fireball->SetVelocity_X(-fireballSpeed);

objectCollection.entities.push_back(std::move(fireball));
collisionGrid->Add(std::move(fireball), CollisionObjectType::Entity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Castlevania
void SetLaunchSpeed(float speed);
FishmanState GetFishmanState();

void Update(GameTime gameTime, UpdateData &updateData) override;
void Update(UpdateData &updateData) override;

void Launch();
void WalkRight();
Expand All @@ -41,7 +41,7 @@ namespace Castlevania
void Land();

void SetFishmanState(FishmanState state);
void ReleaseFireball(ObjectCollection &objectCollection);
void ReleaseFireball();

friend class FishmanResponseSystem;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ GameObject &FishmanResponseSystem::GetParent()

void FishmanResponseSystem::Update(UpdateData &updateData)
{
auto &objectCollection = *updateData.objectCollection;
auto collisionData = GetParent().GetBody().GetCollisionData();
auto isOnGround = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "GiantBat.h"
#include "../../UpdateData.h"
#include "../../Settings.h"
#include "../../../Utilities/CollisionGrid.h"

using namespace Castlevania;

Expand Down Expand Up @@ -93,9 +94,9 @@ GiantBatState GiantBat::GetGiantBatState()
return giantBatState;
}

void GiantBat::Update(GameTime gameTime, UpdateData &updateData)
void GiantBat::Update(UpdateData &updateData)
{
Enemy::Update(gameTime, updateData);
Enemy::Update(updateData);

switch (giantBatState)
{
Expand All @@ -121,7 +122,7 @@ void GiantBat::Update(GameTime gameTime, UpdateData &updateData)
if (shootingTimer.ElapsedMilliseconds() > SHOOTING_TIME)
{
if (fireball != nullptr)
updateData.objectCollection->entities.push_back(std::move(fireball));
collisionGrid->Add(std::move(fireball), CollisionObjectType::Entity);

Hover();
shootingTimer.Reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Castlevania
void SetMoveArea(Rect moveArea) override;
GiantBatState GetGiantBatState();

void Update(GameTime gameTime, UpdateData &updateData) override;
void Update(UpdateData &updateData) override;

void Idle();
void Hover();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ void GiantBatCollisionSystem::Update(UpdateData &updateData)
if (!parent.GetBody().Enabled())
return;

auto &objectCollection = *updateData.objectCollection;
auto playerBbox = (Rect)objectCollection.player->GetBoundingBox();
auto playerBbox = (Rect)updateData.player->GetBoundingBox();

CheckZonesCollision(playerBbox);
}
Expand Down
Loading

0 comments on commit 790b565

Please sign in to comment.