-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53e1a78
commit fb08296
Showing
26 changed files
with
773 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
namespace linguine { | ||
|
||
struct Fire {}; | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "FireSystem.h" | ||
|
||
#include "components/Fire.h" | ||
#include "components/Transform.h" | ||
|
||
namespace linguine { | ||
|
||
void FireSystem::update(float deltaTime) { | ||
findEntities<Fire, Transform>()->each([this](const Entity& entity) { | ||
auto transform = entity.get<Transform>(); | ||
|
||
auto randomScale = std::uniform_real_distribution(0.2f, 0.3f); | ||
transform->scale = glm::vec3(randomScale(_random)); | ||
}); | ||
} | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "System.h" | ||
|
||
#include <random> | ||
|
||
namespace linguine { | ||
|
||
class FireSystem : public System { | ||
public: | ||
explicit FireSystem(EntityManager& entityManager) : System(entityManager) {} | ||
|
||
void update(float deltaTime) override; | ||
|
||
void fixedUpdate(float fixedDeltaTime) override {} | ||
|
||
private: | ||
std::random_device _random; | ||
}; | ||
|
||
} // namespace linguine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "BoosterMesh.h" | ||
|
||
#include <simd/simd.h> | ||
|
||
namespace linguine::render { | ||
|
||
BoosterMesh::BoosterMesh(MTL::Device& device) { | ||
simd::float2 positions[] = { | ||
// Left Booster A | ||
{ -0.2f, -0.2f }, | ||
{ -0.05f, -0.2f }, | ||
{ -0.05f, -0.3f }, | ||
|
||
// Left Booster B | ||
{ -0.05f, -0.2f }, | ||
{ -0.2f, -0.2f }, | ||
{ -0.2f, -0.15f }, | ||
|
||
// Right Booster A | ||
{ 0.05f, -0.2f }, | ||
{ 0.2f, -0.2f }, | ||
{ 0.05f, -0.3f }, | ||
|
||
// Right Booster B | ||
{ 0.2f, -0.2f }, | ||
{ 0.05f, -0.2f }, | ||
{ 0.2f, -0.15f } | ||
}; | ||
|
||
const auto positionsBufferSize = std::size(positions) * sizeof(simd::float2); | ||
_vertexPositionsBuffer = device.newBuffer(positionsBufferSize, MTL::ResourceStorageModeShared); | ||
|
||
memcpy(_vertexPositionsBuffer->contents(), positions, positionsBufferSize); | ||
} | ||
|
||
BoosterMesh::~BoosterMesh() { | ||
_vertexPositionsBuffer->release(); | ||
} | ||
|
||
void BoosterMesh::bind(MTL::RenderCommandEncoder& encoder) { | ||
encoder.setVertexBuffer(_vertexPositionsBuffer, 0, 0); | ||
} | ||
|
||
void BoosterMesh::draw(MTL::RenderCommandEncoder& encoder) { | ||
encoder.drawPrimitives(MTL::PrimitiveType::PrimitiveTypeTriangle, NS::UInteger(0), NS::UInteger(12)); | ||
} | ||
|
||
} // namespace linguine::render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "Mesh.h" | ||
|
||
namespace linguine::render { | ||
|
||
class BoosterMesh : public Mesh { | ||
public: | ||
explicit BoosterMesh(MTL::Device& device); | ||
|
||
~BoosterMesh() override; | ||
|
||
void bind(MTL::RenderCommandEncoder& encoder) override; | ||
|
||
void draw(MTL::RenderCommandEncoder& encoder) override; | ||
|
||
private: | ||
MTL::Buffer* _vertexPositionsBuffer; | ||
}; | ||
|
||
} // namespace linguine::render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "CockpitMesh.h" | ||
|
||
#include <simd/simd.h> | ||
|
||
namespace linguine::render { | ||
|
||
CockpitMesh::CockpitMesh(MTL::Device& device) { | ||
simd::float2 positions[] = { | ||
{ 0.0f, 0.2f }, | ||
{ 0.1f, -0.1f }, | ||
{ -0.1f, -0.1f }, | ||
|
||
{ -0.1f, -0.1f }, | ||
{ 0.1f, -0.1f }, | ||
{ 0.0f, -0.15f } | ||
}; | ||
|
||
const auto positionsBufferSize = std::size(positions) * sizeof(simd::float2); | ||
_vertexPositionsBuffer = device.newBuffer(positionsBufferSize, MTL::ResourceStorageModeShared); | ||
|
||
memcpy(_vertexPositionsBuffer->contents(), positions, positionsBufferSize); | ||
} | ||
|
||
CockpitMesh::~CockpitMesh() { | ||
_vertexPositionsBuffer->release(); | ||
} | ||
|
||
void CockpitMesh::bind(MTL::RenderCommandEncoder& encoder) { | ||
encoder.setVertexBuffer(_vertexPositionsBuffer, 0, 0); | ||
} | ||
|
||
void CockpitMesh::draw(MTL::RenderCommandEncoder& encoder) { | ||
encoder.drawPrimitives(MTL::PrimitiveType::PrimitiveTypeTriangle, NS::UInteger(0), NS::UInteger(6)); | ||
} | ||
|
||
} // namespace linguine::render |
Oops, something went wrong.