diff --git a/.vscode/launch.json b/.vscode/launch.json
index c4505ce..ae1a672 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -11,7 +11,7 @@
"program": "${workspaceFolder}/build/bin/Debug/IAERuntime.exe",
"args": [],
"stopAtEntry": false,
- "cwd": "${workspaceFolder}",
+ "cwd": "${workspaceFolder}/Samples/SpaceInvaders",
"environment": [],
"console": "externalTerminal",
"preLaunchTask": "CMake: build"
diff --git a/Engine/CMakeLists.txt b/Engine/CMakeLists.txt
index a81e0cc..7414493 100644
--- a/Engine/CMakeLists.txt
+++ b/Engine/CMakeLists.txt
@@ -1,5 +1,6 @@
set(SRC_FILES
"Src/Imp/CPP/Time.cpp"
+ "Src/Imp/CPP/Scene.cpp"
"Src/Imp/CPP/Random.cpp"
"Src/Imp/CPP/Engine.cpp"
"Src/Imp/CPP/InternalEngine.cpp"
@@ -15,6 +16,17 @@ set(SRC_FILES
"Src/Imp/CPP/Renderer/Renderer.cpp"
"Src/Imp/CPP/Renderer/UIRenderer.cpp"
"Src/Imp/CPP/Renderer/GPUResourceManager.cpp"
+
+ "Src/Imp/CPP/Nodes/Node2D.cpp"
+ "Src/Imp/CPP/Nodes/TextureNode.cpp"
+ "Src/Imp/CPP/Nodes/CameraNode.cpp"
+
+ "Src/Imp/CPP/Components/CameraComponent.cpp"
+ "Src/Imp/CPP/Components/PhysicsComponent.cpp"
+ "Src/Imp/CPP/Components/SpriteComponent.cpp"
+ "Src/Imp/CPP/Components/TextureComponent.cpp"
+ "Src/Imp/CPP/Components/TileMapComponent.cpp"
+ "Src/Imp/CPP/Components/SoundEmitterComponent.cpp"
)
add_library(IAEngine SHARED ${SRC_FILES})
diff --git a/Engine/Src/Imp/CPP/Components/CameraComponent.cpp b/Engine/Src/Imp/CPP/Components/CameraComponent.cpp
new file mode 100644
index 0000000..6a24724
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Components/CameraComponent.cpp
@@ -0,0 +1,53 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+
+#include
+
+namespace ia::iae
+{
+ CameraComponent::CameraComponent(IN Node2D *node) : IComponent(node)
+ {
+ }
+
+ VOID CameraComponent::SetViewport(IN INT32 width, IN INT32 height)
+ {
+ m_viewport.x = 0;
+ m_viewport.y = 0;
+ m_viewport.z = width;
+ m_viewport.w = height;
+
+ m_projectionMatrix =
+ glm::orthoLH(0.0f, (FLOAT32) width, (FLOAT32) height, 0.0f, Renderer::MIN_DEPTH, Renderer::MAX_DEPTH);
+ }
+
+ VOID CameraComponent::Draw()
+ {
+ }
+
+ VOID CameraComponent::DebugDraw()
+ {
+ }
+
+ VOID CameraComponent::Update()
+ {
+ }
+
+ VOID CameraComponent::FixedUpdate()
+ {
+ }
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/Components/PhysicsComponent.cpp b/Engine/Src/Imp/CPP/Components/PhysicsComponent.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Imp/CPP/Components/SoundEmitterComponent.cpp b/Engine/Src/Imp/CPP/Components/SoundEmitterComponent.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Imp/CPP/Components/SpriteComponent.cpp b/Engine/Src/Imp/CPP/Components/SpriteComponent.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Imp/CPP/Components/TextureComponent.cpp b/Engine/Src/Imp/CPP/Components/TextureComponent.cpp
new file mode 100644
index 0000000..aeef5fc
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Components/TextureComponent.cpp
@@ -0,0 +1,60 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+#include
+
+namespace ia::iae
+{
+ TextureComponent::TextureComponent(IN Node2D *node) : IComponent(node)
+ {
+ }
+
+ VOID TextureComponent::SetTexture(IN Handle image)
+ {
+ const auto t = Engine::GetImageExtent(image);
+
+ m_texture = image;
+ m_textureExtent = {t.x, t.y};
+ }
+
+ VOID TextureComponent::Draw()
+ {
+ m_drawnSize = m_node->GetScale() * m_textureExtent * m_scaleOffset;
+
+ Engine::SetRenderState_Texture(m_texture);
+ Engine::SetRenderState_FlippedH(m_isFlippedH);
+ Engine::SetRenderState_FlippedV(m_isFlippedV);
+ Engine::SetRenderState_ColorOverlay(m_colorOverlay);
+ Engine::SetRenderState_TextureOffset(m_textureOffset);
+ Engine::SetRenderState_CameraRelative(m_isCameraRelative);
+ Engine::SetRenderState_Transform(m_node->GetPosition() + m_positionOffset, m_drawnSize, m_node->GetRotation() + m_rotationOffset, m_node->Layer(), m_node->SortIndex());
+
+ Engine::DrawGeometry(Engine::GetGeometry_Quad());
+ }
+
+ VOID TextureComponent::DebugDraw()
+ {
+ }
+
+ VOID TextureComponent::Update()
+ {
+ }
+
+ VOID TextureComponent::FixedUpdate()
+ {
+ }
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/Components/TileMapComponent.cpp b/Engine/Src/Imp/CPP/Components/TileMapComponent.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Imp/CPP/Engine.cpp b/Engine/Src/Imp/CPP/Engine.cpp
index 0e12cb4..9d7be5a 100644
--- a/Engine/Src/Imp/CPP/Engine.cpp
+++ b/Engine/Src/Imp/CPP/Engine.cpp
@@ -17,6 +17,8 @@
#include
#include
+#include
+
#include
EXTERN GameFunctionTable g_gameFunctions;
@@ -37,4 +39,22 @@ namespace ia::iae
Renderer::OnScreenResize(newWidth, newHeight);
g_gameFunctions.OnResize(newWidth, newHeight);
}
+
+ Handle Engine::CreateImageFromFile(IN CONST String &path)
+ {
+ const auto data = File::ReadToVector(path.c_str());
+ return CreateImage(data.data(), data.size());
+ }
+
+ Handle Engine::CreateSoundFromFile(IN CONST String &path)
+ {
+ const auto data = File::ReadToVector(path.c_str());
+ return CreateSound(data.data(), data.size());
+ }
+
+ Handle Engine::CreateSceneFromFile(IN CONST String &path)
+ {
+ const auto data = File::ReadToString(path.c_str());
+ return CreateScene(data);
+ }
} // namespace ia::iae
diff --git a/Engine/Src/Imp/CPP/InternalEngine.cpp b/Engine/Src/Imp/CPP/InternalEngine.cpp
index facb647..95e0c92 100644
--- a/Engine/Src/Imp/CPP/InternalEngine.cpp
+++ b/Engine/Src/Imp/CPP/InternalEngine.cpp
@@ -85,6 +85,9 @@ namespace ia::iae
VOID __Internal_Engine::Iterate()
{
WorldManager::Update();
+ WorldManager::FixedUpdate();
+ g_gameFunctions.OnUpdate(Time::GetFrameDeltaTime());
+ g_gameFunctions.OnFixedUpdate();
Renderer::BeginFrame();
WorldManager::Draw();
diff --git a/Engine/Src/Imp/CPP/Nodes/CameraNode.cpp b/Engine/Src/Imp/CPP/Nodes/CameraNode.cpp
new file mode 100644
index 0000000..f32c857
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Nodes/CameraNode.cpp
@@ -0,0 +1,25 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+#include
+
+namespace ia::iae
+{
+ CameraNode::CameraNode(IN CONST String &name) : Node2D(name), m_cameraComponent(AddComponent())
+ {
+ }
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/Nodes/Node2D.cpp b/Engine/Src/Imp/CPP/Nodes/Node2D.cpp
new file mode 100644
index 0000000..0cae9a7
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Nodes/Node2D.cpp
@@ -0,0 +1,63 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+#include
+
+namespace ia::iae
+{
+ Node2D::Node2D(IN CONST String &name) : INode(name)
+ {
+ }
+
+ Node2D::~Node2D()
+ {
+ for(auto& t: m_components)
+ delete t;
+ }
+
+ VOID Node2D::Draw()
+ {
+ for(auto& t: m_components)
+ t->Draw();
+ for(auto& t: m_children)
+ t->Draw();
+ }
+
+ VOID Node2D::DebugDraw()
+ {
+ for(auto& t: m_components)
+ t->DebugDraw();
+ for(auto& t: m_children)
+ t->DebugDraw();
+ }
+
+ VOID Node2D::Update()
+ {
+ for(auto& t: m_components)
+ t->Update();
+ for(auto& t: m_children)
+ t->Update();
+ }
+
+ VOID Node2D::FixedUpdate()
+ {
+ for(auto& t: m_components)
+ t->FixedUpdate();
+ for(auto& t: m_children)
+ t->FixedUpdate();
+ }
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/Nodes/TextureNode.cpp b/Engine/Src/Imp/CPP/Nodes/TextureNode.cpp
new file mode 100644
index 0000000..b595c72
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Nodes/TextureNode.cpp
@@ -0,0 +1,25 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+#include
+
+namespace ia::iae
+{
+ TextureNode::TextureNode(IN CONST String &name) : Node2D(name), m_textureComponent(AddComponent())
+ {
+ }
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp b/Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp
index a5c5ec6..0171595 100644
--- a/Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp
+++ b/Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp
@@ -23,6 +23,9 @@
#include
#include
+#include
+EXTERN GameFunctionTable g_gameFunctions;
+
namespace ia::iae
{
EXTERN SDL_Window *g_windowHandle;
@@ -67,6 +70,7 @@ namespace ia::iae
ImGui::NewFrame();
WorldManager::DebugDraw();
+ g_gameFunctions.OnDebugDraw();
ImGui::Render();
}
diff --git a/Engine/Src/Imp/CPP/Renderer/Renderer.cpp b/Engine/Src/Imp/CPP/Renderer/Renderer.cpp
index 39490e2..af1a2b8 100644
--- a/Engine/Src/Imp/CPP/Renderer/Renderer.cpp
+++ b/Engine/Src/Imp/CPP/Renderer/Renderer.cpp
@@ -144,10 +144,12 @@ namespace ia::iae
&s_state.DepthStencilTargetInfo);
SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_geometryPipeline->GetHandle());
- SDL_PushGPUVertexUniformData(s_state.ActiveCommandBuffer, 0, &s_state.ProjectionMatrix, sizeof(Mat4));
+ SDL_PushGPUVertexUniformData(
+ s_state.ActiveCommandBuffer, 0,
+ s_state.ActiveCamera ? s_state.ActiveCamera->GetProjectionMatrix() : &IdentityMatrix, sizeof(Mat4));
SDL_PushGPUVertexUniformData(
s_state.ActiveCommandBuffer, 1,
- (s_state.ActiveCamera && !s_state.CameraRelative) ? s_state.ActiveCamera->GetMatrix() : &IdentityMatrix,
+ (s_state.ActiveCamera && !s_state.CameraRelative) ? s_state.ActiveCamera->GetViewMatrix() : &IdentityMatrix,
sizeof(Mat4));
}
@@ -210,8 +212,17 @@ namespace ia::iae
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr,
SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle));
- s_state.ProjectionMatrix =
- glm::orthoLH(0.0f, (FLOAT32) s_screenWidth, (FLOAT32) s_screenHeight, 0.0f, -2097152.0f, 2097152.0f);
+ s_state.Scissor = {0, 0, newWidth, newHeight};
+
+ s_state.ActiveViewport.x = 0;
+ s_state.ActiveViewport.y = 0;
+ s_state.ActiveViewport.w = newWidth;
+ s_state.ActiveViewport.h = newHeight;
+ s_state.ActiveViewport.min_depth = 0.0f;
+ s_state.ActiveViewport.max_depth = 1.0f;
+
+ if (s_state.ActiveCamera)
+ s_state.ActiveCamera->SetViewport(newWidth, newHeight);
}
SDL_GPUTextureFormat Renderer::GetRenderTargetFormat()
@@ -233,6 +244,8 @@ namespace ia::iae
VOID Renderer::DestroyGeometry(IN Geometry *handle)
{
+ GPUResourceManager::DestroyBuffer(handle->VertexBuffer);
+ GPUResourceManager::DestroyBuffer(handle->IndexBuffer);
delete handle;
}
@@ -250,8 +263,7 @@ namespace ia::iae
#pragma pack(pop)
- s_fragmentUniform.ColorOverlay = Vec4(s_state.ColorOverlay.R / 255.0f, s_state.ColorOverlay.G / 255.0f,
- s_state.ColorOverlay.B / 255.0f, s_state.ColorOverlay.A / 255.0f);
+ s_fragmentUniform.ColorOverlay = s_state.ColorOverlay.GetAsFloatVec();
s_fragmentUniform.FlippedH = s_state.FlippedH;
s_fragmentUniform.FlippedV = s_state.FlippedV;
s_fragmentUniform.TextureOffset = s_state.TextureOffset;
@@ -261,6 +273,7 @@ namespace ia::iae
SDL_PushGPUFragmentUniformData(s_state.ActiveCommandBuffer, 0, &s_fragmentUniform, sizeof(s_fragmentUniform));
SDL_SetGPUScissor(s_state.ActiveRenderPass, &s_state.Scissor);
+ SDL_SetGPUViewport(s_state.ActiveRenderPass, &s_state.ActiveViewport);
SDL_GPUBufferBinding bufferBindings[] = {{.buffer = handle->VertexBuffer, .offset = 0},
{.buffer = handle->IndexBuffer, .offset = 0}};
@@ -272,9 +285,10 @@ namespace ia::iae
namespace ia::iae
{
- VOID Engine::SetActiveCamera(IN ICameraComponent *cameraComponent)
+ VOID Engine::SetActiveCamera(IN CameraComponent *cameraComponent)
{
Renderer::s_state.ActiveCamera = cameraComponent;
+ Renderer::OnScreenResize(Renderer::s_screenWidth, Renderer::s_screenHeight);
}
Handle Engine::CreateGeometry(IN CONST Vector &vertices, IN CONST Vector &indices)
@@ -354,6 +368,6 @@ namespace ia::iae
Handle Engine::GetGeometry_Quad()
{
- return (Handle)Renderer::s_quadGeometry;
+ return (Handle) Renderer::s_quadGeometry;
}
} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/CPP/ResourceManager.cpp b/Engine/Src/Imp/CPP/ResourceManager.cpp
index 0cf09d0..4bfef19 100644
--- a/Engine/Src/Imp/CPP/ResourceManager.cpp
+++ b/Engine/Src/Imp/CPP/ResourceManager.cpp
@@ -27,6 +27,8 @@
namespace ia::iae
{
+ Vector ResourceManager::s_images;
+ Vector ResourceManager::s_sounds;
Map ResourceManager::s_imageExtents;
VOID ResourceManager::Initialize()
@@ -35,6 +37,10 @@ namespace ia::iae
VOID ResourceManager::Terminate()
{
+ for (const auto &t : s_images)
+ GPUResourceManager::DestroyTexture((SDL_GPUTexture *) t);
+ for (const auto &t : s_sounds)
+ AudioManager::DestoryAudio(t);
}
Handle ResourceManager::CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
@@ -51,12 +57,15 @@ namespace ia::iae
const auto handle = (Handle) GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER, width, height,
rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM);
s_imageExtents[handle] = (((UINT64) width) << 32) | height;
+ s_images.pushBack(handle);
return handle;
}
Handle ResourceManager::CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
- return AudioManager::CreateAudio(encodedData, encodedDataSize);
+ const auto handle = AudioManager::CreateAudio(encodedData, encodedDataSize);
+ s_sounds.pushBack(handle);
+ return handle;
}
VOID ResourceManager::DestroyImage(IN Handle image)
@@ -80,7 +89,6 @@ namespace ia::iae
const auto currentExtent = GetImageExtent(image);
const auto pixelData =
GPUResourceManager::GetTexturePixelData((SDL_GPUTexture *) image, currentExtent.x, currentExtent.y);
- GPUResourceManager::DestroyTexture((SDL_GPUTexture *) image);
const auto newPixelData =
stbir_resize_uint8_linear(pixelData.data(), currentExtent.x, currentExtent.y, currentExtent.x * 4, nullptr,
newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA);
@@ -92,7 +100,8 @@ namespace ia::iae
Handle ResourceManager::CombineImages(IN CONST Vector &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY)
{
- return (Handle)GPUResourceManager::CombineTextures((SDL_GPUTexture**)images.data(), unitWidth, unitHeight, unitCountX, unitCountY);
+ return (Handle) GPUResourceManager::CombineTextures((SDL_GPUTexture **) images.data(), unitWidth, unitHeight,
+ unitCountX, unitCountY);
}
} // namespace ia::iae
diff --git a/Engine/Src/Imp/CPP/Scene.cpp b/Engine/Src/Imp/CPP/Scene.cpp
new file mode 100644
index 0000000..2c410ad
--- /dev/null
+++ b/Engine/Src/Imp/CPP/Scene.cpp
@@ -0,0 +1,77 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#include
+#include
+
+namespace ia::iae
+{
+ Scene *Scene::Create()
+ {
+ return new Scene();
+ }
+
+ Scene *Scene::Create(IN CONST String &sceneXML)
+ {
+ const auto scene = new Scene();
+
+ return scene;
+ }
+
+ VOID Scene::Destroy(IN Scene *scene)
+ {
+ delete scene;
+ }
+
+ VOID Scene::Draw()
+ {
+ for (auto &t : m_nodes)
+ t->Value->Draw();
+ }
+
+ VOID Scene::DebugDraw()
+ {
+ for (auto &t : m_nodes)
+ t->Value->DebugDraw();
+ }
+
+ VOID Scene::FixedUpdate()
+ {
+ for (auto &t : m_nodes)
+ t->Value->FixedUpdate();
+ }
+
+ VOID Scene::Update()
+ {
+ for (auto &t : m_nodes)
+ t->Value->Update();
+ }
+
+ VOID Scene::AddNode(IN RefPtr node)
+ {
+ m_nodes[node->GetName()] = node;
+ }
+
+ INode *Scene::GetNode(IN CONST String &name)
+ {
+ return m_nodes[name].get();
+ }
+
+ VOID Scene::RemoveNode(IN CONST String &name)
+ {
+ m_nodes[name] = nullptr;
+ }
+} // namespace ia::iae
diff --git a/Engine/Src/Imp/CPP/WorldManager.cpp b/Engine/Src/Imp/CPP/WorldManager.cpp
index 9a4b5a2..bd390dd 100644
--- a/Engine/Src/Imp/CPP/WorldManager.cpp
+++ b/Engine/Src/Imp/CPP/WorldManager.cpp
@@ -19,74 +19,104 @@
namespace ia::iae
{
+ Scene *WorldManager::m_activeScene{};
+
VOID WorldManager::Initialize()
{
+ m_activeScene = Scene::Create();
}
VOID WorldManager::Terminate()
{
+ if (m_activeScene)
+ Scene::Destroy(m_activeScene);
}
VOID WorldManager::Draw()
{
+ m_activeScene->Draw();
}
VOID WorldManager::DebugDraw()
{
+ m_activeScene->DebugDraw();
}
VOID WorldManager::Update()
{
+ m_activeScene->Update();
+ }
+
+ VOID WorldManager::FixedUpdate()
+ {
+ m_activeScene->FixedUpdate();
+ }
+
+ VOID WorldManager::ChangeActiveScene(IN Scene *scene)
+ {
+ m_activeScene = scene;
+ }
+
+ VOID WorldManager::AddNodeToActiveScene(IN RefPtr node)
+ {
+ m_activeScene->AddNode(node);
+ }
+
+ INode *WorldManager::GetNodeFromActiveScene(IN CONST String &name)
+ {
+ return m_activeScene->GetNode(name);
+ }
+
+ VOID WorldManager::RemoveNodeFromActiveScene(IN CONST String &name)
+ {
+ m_activeScene->RemoveNode(name);
}
} // namespace ia::iae
namespace ia::iae
{
- Handle Engine::CreatePhysicsBody()
- {
- return INVALID_HANDLE;
- }
-
- VOID Engine::DestroyPhysicsBody(IN Handle body)
+ Handle Engine::CreateScene(IN CONST String &sceneXML)
{
+ return (Handle) Scene::Create(sceneXML);
}
Handle Engine::CreateEmptyScene()
{
- return INVALID_HANDLE;
+ return (Handle) Scene::Create();
}
VOID Engine::DestroyScene(IN Handle handle)
{
+ Scene::Destroy((Scene *) handle);
}
VOID Engine::ChangeActiveScene(IN Handle scene)
{
+ WorldManager::ChangeActiveScene((Scene *) scene);
}
VOID Engine::AddNodeToActiveScene(IN RefPtr node)
{
+ WorldManager::AddNodeToActiveScene(node);
}
INode *Engine::GetNodeFromActiveScene(IN CONST String &name)
{
- return nullptr;
+ return WorldManager::GetNodeFromActiveScene(name);
}
VOID Engine::RemoveNodeFromActiveScene(IN CONST String &name)
{
+ WorldManager::RemoveNodeFromActiveScene(name);
}
VOID Engine::AddNodeToScene(IN Handle scene, IN RefPtr node)
{
+ ((Scene *) scene)->AddNode(node);
}
VOID Engine::RemoveNodeFromScene(IN Handle scene, IN CONST String &name)
{
- }
-
- Handle Engine::CreateScene(IN CONST String& sceneXML)
- {
- return INVALID_HANDLE;
+ ((Scene *) scene)->RemoveNode(name);
}
} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/HPP/Renderer/Renderer.hpp b/Engine/Src/Imp/HPP/Renderer/Renderer.hpp
index 8cbf148..6f3f5b7 100644
--- a/Engine/Src/Imp/HPP/Renderer/Renderer.hpp
+++ b/Engine/Src/Imp/HPP/Renderer/Renderer.hpp
@@ -24,6 +24,9 @@ namespace ia::iae
class Renderer
{
public:
+ STATIC CONSTEXPR FLOAT32 MIN_DEPTH = -2097152.0f;
+ STATIC CONSTEXPR FLOAT32 MAX_DEPTH = 2097152.0f;
+
struct Geometry
{
INT32 IndexCount{};
@@ -41,16 +44,16 @@ namespace ia::iae
Vec2 TextureOffset{0.0f, 0.0f};
SDL_Rect Scissor{0, 0, 0, 0};
SDL_GPUTexture* ActiveTexture{nullptr};
+ SDL_GPUViewport ActiveViewport{};
Mat4 ModelMatrix{1.0f};
- Mat4 ProjectionMatrix{1.0f};
SDL_GPURenderPass* ActiveRenderPass{};
SDL_GPUCommandBuffer* ActiveCommandBuffer{};
SDL_GPUColorTargetInfo ColorTargetInfo{};
SDL_GPUDepthStencilTargetInfo DepthStencilTargetInfo{};
- class ICameraComponent *ActiveCamera{};
+ class CameraComponent *ActiveCamera{};
};
public:
diff --git a/Engine/Src/Imp/HPP/ResourceManager.hpp b/Engine/Src/Imp/HPP/ResourceManager.hpp
index 2a47810..3b3822e 100644
--- a/Engine/Src/Imp/HPP/ResourceManager.hpp
+++ b/Engine/Src/Imp/HPP/ResourceManager.hpp
@@ -46,6 +46,8 @@ namespace ia::iae
IN INT32 unitCountX, IN INT32 unitCountY);
private:
+ STATIC Vector s_images;
+ STATIC Vector s_sounds;
STATIC Map s_imageExtents;
};
} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/HPP/Scene.hpp b/Engine/Src/Imp/HPP/Scene.hpp
new file mode 100644
index 0000000..f6efd23
--- /dev/null
+++ b/Engine/Src/Imp/HPP/Scene.hpp
@@ -0,0 +1,48 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#pragma once
+
+#include
+
+#include
+
+namespace ia::iae
+{
+ class Scene
+ {
+ public:
+ STATIC Scene *Create();
+ STATIC Scene *Create(IN CONST String &sceneXML);
+
+ STATIC VOID Destroy(IN Scene *scene);
+
+ public:
+ VOID Draw();
+ VOID DebugDraw();
+
+ VOID FixedUpdate();
+ VOID Update();
+
+ public:
+ VOID AddNode(IN RefPtr node);
+ INode *GetNode(IN CONST String &name);
+ VOID RemoveNode(IN CONST String &name);
+
+ private:
+ Map> m_nodes;
+ };
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Imp/HPP/WorldManager.hpp b/Engine/Src/Imp/HPP/WorldManager.hpp
index b35e393..677c9be 100644
--- a/Engine/Src/Imp/HPP/WorldManager.hpp
+++ b/Engine/Src/Imp/HPP/WorldManager.hpp
@@ -17,6 +17,7 @@
#pragma once
#include
+#include
#include
@@ -24,7 +25,7 @@ namespace ia::iae
{
class WorldManager
{
- public:
+ public:
STATIC VOID Initialize();
STATIC VOID Terminate();
@@ -32,5 +33,15 @@ namespace ia::iae
STATIC VOID DebugDraw();
STATIC VOID Update();
+ STATIC VOID FixedUpdate();
+
+ public:
+ STATIC VOID ChangeActiveScene(IN Scene* scene);
+ STATIC VOID AddNodeToActiveScene(IN RefPtr node);
+ STATIC INode *GetNodeFromActiveScene(IN CONST String &name);
+ STATIC VOID RemoveNodeFromActiveScene(IN CONST String &name);
+
+ private:
+ STATIC Scene *m_activeScene;
};
-}
\ No newline at end of file
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Base.hpp b/Engine/Src/Inc/IAEngine/Base.hpp
index 897137b..e8abb4f 100644
--- a/Engine/Src/Inc/IAEngine/Base.hpp
+++ b/Engine/Src/Inc/IAEngine/Base.hpp
@@ -16,6 +16,12 @@
#pragma once
+#if defined(__BUILDING_IAENGINE) && (__BUILDING_IAENGINE)
+ #define IAE_DLL_API IA_DLL_EXPORT
+#else
+ #define IAE_DLL_API IA_DLL_IMPORT
+#endif
+
#include
#include
#include
@@ -108,6 +114,11 @@ namespace ia::iae
UINT8 G{0xFF};
UINT8 B{0xFF};
UINT8 A{0xFF};
+
+ Vec4 GetAsFloatVec() CONST
+ {
+ return {(FLOAT32)R/255.0f, (FLOAT32)G/255.0f, (FLOAT32)B/255.0f, (FLOAT32)A/255.0f};
+ }
};
/* Adopted from SDL3 */
diff --git a/Engine/Src/Inc/IAEngine/Components/CameraComponent.hpp b/Engine/Src/Inc/IAEngine/Components/CameraComponent.hpp
index 1d4b7ec..116b865 100644
--- a/Engine/Src/Inc/IAEngine/Components/CameraComponent.hpp
+++ b/Engine/Src/Inc/IAEngine/Components/CameraComponent.hpp
@@ -20,8 +20,39 @@
namespace ia::iae
{
- struct ICameraComponent: public IComponent
+ class CameraComponent : public IComponent
{
- PURE_VIRTUAL(Mat4* GetMatrix() CONST);
+ public:
+ CameraComponent(IN Node2D *node);
+
+ public:
+ VOID Draw();
+ VOID DebugDraw();
+
+ VOID Update();
+ VOID FixedUpdate();
+
+ public:
+ VOID SetViewport(IN INT32 width, IN INT32 height);
+
+ Vec4 GetViewport() CONST
+ {
+ return m_viewport;
+ }
+
+ CONST Mat4 *GetViewMatrix() CONST
+ {
+ return &m_viewMatrix;
+ }
+
+ CONST Mat4 *GetProjectionMatrix() CONST
+ {
+ return &m_projectionMatrix;
+ }
+
+ private:
+ Vec4 m_viewport{};
+ Mat4 m_viewMatrix{1.0f};
+ Mat4 m_projectionMatrix{1.0f};
};
-}
\ No newline at end of file
+} // namespace ia::iae
diff --git a/Engine/Src/Inc/IAEngine/Components/IComponent.hpp b/Engine/Src/Inc/IAEngine/Components/IComponent.hpp
index 5828ba4..7e4bb48 100644
--- a/Engine/Src/Inc/IAEngine/Components/IComponent.hpp
+++ b/Engine/Src/Inc/IAEngine/Components/IComponent.hpp
@@ -20,10 +20,32 @@
namespace ia::iae
{
- class INode;
+ class Node2D;
- struct IComponent
+ class IComponent
{
- INode* Node{};
+ public:
+ PURE_VIRTUAL(VOID Draw());
+ PURE_VIRTUAL(VOID DebugDraw());
+ PURE_VIRTUAL(VOID Update());
+ PURE_VIRTUAL(VOID FixedUpdate());
+
+ public:
+ IComponent(IN Node2D *node) : m_node(node)
+ {
+ }
+
+ Node2D *GetNode()
+ {
+ return m_node;
+ }
+
+ CONST Node2D *GetNode() CONST
+ {
+ return m_node;
+ }
+
+ protected:
+ Node2D *CONST m_node{};
};
-}
\ No newline at end of file
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Components/PhysicsComponent.hpp b/Engine/Src/Inc/IAEngine/Components/PhysicsComponent.hpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Inc/IAEngine/Components/SoundEmitterComponent.hpp b/Engine/Src/Inc/IAEngine/Components/SoundEmitterComponent.hpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Inc/IAEngine/Components/SpriteComponent.hpp b/Engine/Src/Inc/IAEngine/Components/SpriteComponent.hpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Inc/IAEngine/Components/TextureComponent.hpp b/Engine/Src/Inc/IAEngine/Components/TextureComponent.hpp
new file mode 100644
index 0000000..b939b8e
--- /dev/null
+++ b/Engine/Src/Inc/IAEngine/Components/TextureComponent.hpp
@@ -0,0 +1,102 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#pragma once
+
+#include
+
+namespace ia::iae
+{
+ class TextureComponent : public IComponent
+ {
+ public:
+ IAE_DLL_API TextureComponent(IN Node2D *node);
+
+ public:
+ VOID Draw();
+ VOID DebugDraw();
+
+ VOID Update();
+ VOID FixedUpdate();
+
+ public:
+ IAE_DLL_API VOID SetTexture(IN Handle image);
+
+ Handle GetTexture() CONST
+ {
+ return m_texture;
+ }
+
+ Vec2 &PositionOffset()
+ {
+ return m_positionOffset;
+ }
+
+ Vec2 &ScaleOffset()
+ {
+ return m_scaleOffset;
+ }
+
+ FLOAT32 &RotationOffset()
+ {
+ return m_rotationOffset;
+ }
+
+ Vec2 &TextureOffset()
+ {
+ return m_textureOffset;
+ }
+
+ Color &ColorOverlay()
+ {
+ return m_colorOverlay;
+ }
+
+ BOOL &IsFlippedH()
+ {
+ return m_isFlippedH;
+ }
+
+ BOOL &IsFlippedV()
+ {
+ return m_isFlippedV;
+ }
+
+ BOOL &IsCameraRelative()
+ {
+ return m_isCameraRelative;
+ }
+
+ Vec2 &DrawnSize()
+ {
+ return m_drawnSize;
+ }
+
+ private:
+ BOOL m_isFlippedH{};
+ BOOL m_isFlippedV{};
+ BOOL m_isCameraRelative{true};
+ Vec2 m_positionOffset{};
+ Vec2 m_textureOffset{};
+ Vec2 m_scaleOffset{1.0f, 1.0f};
+ FLOAT32 m_rotationOffset{};
+ Color m_colorOverlay{};
+ Vec2 m_drawnSize{};
+
+ Vec2 m_textureExtent{};
+ Handle m_texture{INVALID_HANDLE};
+ };
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Components/TileMapComponent.hpp b/Engine/Src/Inc/IAEngine/Components/TileMapComponent.hpp
new file mode 100644
index 0000000..e69de29
diff --git a/Engine/Src/Inc/IAEngine/Engine.hpp b/Engine/Src/Inc/IAEngine/Engine.hpp
index b89444a..772cb8e 100644
--- a/Engine/Src/Inc/IAEngine/Engine.hpp
+++ b/Engine/Src/Inc/IAEngine/Engine.hpp
@@ -16,8 +16,13 @@
#pragma once
-#include
+#include
+#include
+#include
+#include
+
#include
+#include
namespace ia::iae
{
@@ -25,96 +30,95 @@ namespace ia::iae
{
public:
// Event Functions
- STATIC Handle CreateEvent(IN CONST String& name);
- STATIC VOID DestroyEvent(IN Handle event);
- STATIC Handle GetEventByName(IN CONST String& name);
- STATIC VOID AddEventListener(IN Handle event, IN std::function callback);
- STATIC VOID AddEventListener(IN CONST String& eventName, IN std::function callback);
- STATIC VOID BroadcastEvent(IN Handle event);
- STATIC VOID BroadcastEvent(IN CONST String& eventName);
-
- // Physics Functions
- STATIC Handle CreatePhysicsBody();
- STATIC VOID DestroyPhysicsBody(IN Handle body);
+ STATIC IAE_DLL_API Handle CreateEvent(IN CONST String& name);
+ STATIC IAE_DLL_API VOID DestroyEvent(IN Handle event);
+ STATIC IAE_DLL_API Handle GetEventByName(IN CONST String& name);
+ STATIC IAE_DLL_API VOID AddEventListener(IN Handle event, IN std::function callback);
+ STATIC IAE_DLL_API VOID AddEventListener(IN CONST String& eventName, IN std::function callback);
+ STATIC IAE_DLL_API VOID BroadcastEvent(IN Handle event);
+ STATIC IAE_DLL_API VOID BroadcastEvent(IN CONST String& eventName);
// Renderer Functions
- STATIC Handle GetGeometry_Quad();
- STATIC Handle CreateGeometry(IN CONST Vector& vertices, IN CONST Vector& indices);
- STATIC VOID DestroyGeometry(IN Handle geometry);
- STATIC VOID DrawGeometry(IN Handle handle);
- STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
+ STATIC IAE_DLL_API Handle GetGeometry_Quad();
+ STATIC IAE_DLL_API Handle CreateGeometry(IN CONST Vector& vertices, IN CONST Vector& indices);
+ STATIC IAE_DLL_API VOID DestroyGeometry(IN Handle geometry);
+ STATIC IAE_DLL_API VOID DrawGeometry(IN Handle handle);
+ STATIC IAE_DLL_API VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
// Renderer State Functions
- STATIC VOID SetRenderState_Scissor(IN IVec4 rect);
- STATIC VOID SetRenderState_FlippedH(IN BOOL value);
- STATIC VOID SetRenderState_FlippedV(IN BOOL value);
- STATIC VOID SetRenderState_TextureOffset(IN Vec2 off);
- STATIC VOID SetRenderState_YSortingEnabled(IN BOOL value);
- STATIC VOID SetRenderState_ColorOverlay(IN Color color);
- STATIC VOID SetRenderState_CameraRelative(IN BOOL value);
- STATIC VOID SetRenderState_Texture(IN Handle image);
- STATIC VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN INT16 sortIndex);
+ STATIC IAE_DLL_API VOID SetRenderState_Scissor(IN IVec4 rect);
+ STATIC IAE_DLL_API VOID SetRenderState_FlippedH(IN BOOL value);
+ STATIC IAE_DLL_API VOID SetRenderState_FlippedV(IN BOOL value);
+ STATIC IAE_DLL_API VOID SetRenderState_TextureOffset(IN Vec2 off);
+ STATIC IAE_DLL_API VOID SetRenderState_YSortingEnabled(IN BOOL value);
+ STATIC IAE_DLL_API VOID SetRenderState_ColorOverlay(IN Color color);
+ STATIC IAE_DLL_API VOID SetRenderState_CameraRelative(IN BOOL value);
+ STATIC IAE_DLL_API VOID SetRenderState_Texture(IN Handle image);
+ STATIC IAE_DLL_API VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN INT16 sortIndex);
// Debug Draw Functions
- STATIC VOID DebugDraw_SetColor(IN Color color);
- STATIC VOID DebugDraw_StrokeWidth(IN FLOAT32 width);
- STATIC VOID DebugDraw_Line(IN Vec2 from, IN Vec2 to);
- STATIC VOID DebugDraw_FillRect(IN Vec2 position, IN Vec2 size);
- STATIC VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
+ STATIC IAE_DLL_API VOID DebugDraw_SetColor(IN Color color);
+ STATIC IAE_DLL_API VOID DebugDraw_StrokeWidth(IN FLOAT32 width);
+ STATIC IAE_DLL_API VOID DebugDraw_Line(IN Vec2 from, IN Vec2 to);
+ STATIC IAE_DLL_API VOID DebugDraw_FillRect(IN Vec2 position, IN Vec2 size);
+ STATIC IAE_DLL_API VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
// Resource Functions
- STATIC Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
- STATIC Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
- STATIC Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
- STATIC VOID DestroyImage(IN Handle image);
- STATIC VOID DestroySound(IN Handle sound);
- STATIC IVec2 GetImageExtent(IN Handle image);
- STATIC Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
- STATIC Handle CombineImages(IN CONST Vector& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
+ STATIC IAE_DLL_API Handle CreateImageFromFile(IN CONST String& path);
+ STATIC IAE_DLL_API Handle CreateSoundFromFile(IN CONST String& path);
+ STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
+ STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
+ STATIC IAE_DLL_API Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
+ STATIC IAE_DLL_API VOID DestroyImage(IN Handle image);
+ STATIC IAE_DLL_API VOID DestroySound(IN Handle sound);
+ STATIC IAE_DLL_API IVec2 GetImageExtent(IN Handle image);
+ STATIC IAE_DLL_API Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
+ STATIC IAE_DLL_API Handle CombineImages(IN CONST Vector& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
// Game Functions
- STATIC VOID SetTimeScale(IN FLOAT32 scale);
- STATIC VOID SetActiveCamera(IN ICameraComponent* cameraComponent);
+ STATIC IAE_DLL_API VOID SetTimeScale(IN FLOAT32 scale);
+ STATIC IAE_DLL_API VOID SetActiveCamera(IN CameraComponent* cameraComponent);
// Scene Functions
- STATIC Handle CreateScene(IN CONST String& sceneXML);
- STATIC Handle CreateEmptyScene();
- STATIC VOID DestroyScene(IN Handle handle);
- STATIC VOID ChangeActiveScene(IN Handle scene);
- STATIC VOID AddNodeToActiveScene(IN RefPtr node);
- STATIC INode* GetNodeFromActiveScene(IN CONST String& name);
- STATIC VOID RemoveNodeFromActiveScene(IN CONST String& name);
- STATIC VOID AddNodeToScene(IN Handle scene, IN RefPtr node);
- STATIC VOID RemoveNodeFromScene(IN Handle scene, IN CONST String& name);
+ STATIC IAE_DLL_API Handle CreateSceneFromFile(IN CONST String& path);
+ STATIC IAE_DLL_API Handle CreateScene(IN CONST String& sceneXML);
+ STATIC IAE_DLL_API Handle CreateEmptyScene();
+ STATIC IAE_DLL_API VOID DestroyScene(IN Handle handle);
+ STATIC IAE_DLL_API VOID ChangeActiveScene(IN Handle scene);
+ STATIC IAE_DLL_API VOID AddNodeToActiveScene(IN RefPtr node);
+ STATIC IAE_DLL_API INode* GetNodeFromActiveScene(IN CONST String& name);
+ STATIC IAE_DLL_API VOID RemoveNodeFromActiveScene(IN CONST String& name);
+ STATIC IAE_DLL_API VOID AddNodeToScene(IN Handle scene, IN RefPtr node);
+ STATIC IAE_DLL_API VOID RemoveNodeFromScene(IN Handle scene, IN CONST String& name);
// Input Functions
- STATIC Vec2 GetInputAxis();
- STATIC VOID SwitchInputModeToText();
- STATIC VOID SwitchInputModeToAction();
- STATIC Vec2 GetInputPointerPosition();
- STATIC BOOL IsInputKeyDown(IN InputKey key);
- STATIC BOOL WasInputKeyPressed(IN InputKey key);
- STATIC BOOL WasInputKeyReleased(IN InputKey key);
- STATIC BOOL IsInputActionDown(IN Handle action);
- STATIC BOOL WasInputActionPressed(IN Handle action);
- STATIC BOOL WasInputActionReleased(IN Handle action);
- STATIC BOOL IsInputActionDown(IN CONST String& action);
- STATIC BOOL WasInputActionPressed(IN CONST String& action);
- STATIC BOOL WasInputActionReleased(IN CONST String& action);
- STATIC Handle BindInputAction(IN CONST String& name, IN InputKey key);
- STATIC VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
+ STATIC IAE_DLL_API Vec2 GetInputAxis();
+ STATIC IAE_DLL_API VOID SwitchInputModeToText();
+ STATIC IAE_DLL_API VOID SwitchInputModeToAction();
+ STATIC IAE_DLL_API Vec2 GetInputPointerPosition();
+ STATIC IAE_DLL_API BOOL IsInputKeyDown(IN InputKey key);
+ STATIC IAE_DLL_API BOOL WasInputKeyPressed(IN InputKey key);
+ STATIC IAE_DLL_API BOOL WasInputKeyReleased(IN InputKey key);
+ STATIC IAE_DLL_API BOOL IsInputActionDown(IN Handle action);
+ STATIC IAE_DLL_API BOOL WasInputActionPressed(IN Handle action);
+ STATIC IAE_DLL_API BOOL WasInputActionReleased(IN Handle action);
+ STATIC IAE_DLL_API BOOL IsInputActionDown(IN CONST String& action);
+ STATIC IAE_DLL_API BOOL WasInputActionPressed(IN CONST String& action);
+ STATIC IAE_DLL_API BOOL WasInputActionReleased(IN CONST String& action);
+ STATIC IAE_DLL_API Handle BindInputAction(IN CONST String& name, IN InputKey key);
+ STATIC IAE_DLL_API VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
// Random Functions
- STATIC FLOAT32 GetRandomFloat();
- STATIC INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
+ STATIC IAE_DLL_API FLOAT32 GetRandomFloat();
+ STATIC IAE_DLL_API INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
// Time Functions
- STATIC INT64 GetTickCount();
- STATIC INT64 GetUnixSecond();
- STATIC INT64 GetUnixMillisecond();
- STATIC FLOAT32 GetFrameDeltaTime();
+ STATIC IAE_DLL_API INT64 GetTickCount();
+ STATIC IAE_DLL_API INT64 GetUnixSecond();
+ STATIC IAE_DLL_API INT64 GetUnixMillisecond();
+ STATIC IAE_DLL_API FLOAT32 GetFrameDeltaTime();
// Engine Functions
- STATIC BOOL IsDebugMode();
+ STATIC IAE_DLL_API BOOL IsDebugMode();
};
}
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/EngineLibraryInterface.hpp b/Engine/Src/Inc/IAEngine/EngineLibraryInterface.hpp
index 494f058..9863aa3 100644
--- a/Engine/Src/Inc/IAEngine/EngineLibraryInterface.hpp
+++ b/Engine/Src/Inc/IAEngine/EngineLibraryInterface.hpp
@@ -18,10 +18,4 @@
#include
-#if defined(__BUILDING_IAENGINE) && (__BUILDING_IAENGINE)
- #define IAE_DLL_API IA_DLL_EXPORT
-#else
- #define IAE_DLL_API IA_DLL_IMPORT
-#endif
-
C_DECL(IAE_DLL_API INT32 IAEngine_Run(IN GameFunctionTable gameFunctionTable));
diff --git a/Engine/Src/Inc/IAEngine/Nodes/CameraNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/CameraNode.hpp
new file mode 100644
index 0000000..63d1501
--- /dev/null
+++ b/Engine/Src/Inc/IAEngine/Nodes/CameraNode.hpp
@@ -0,0 +1,38 @@
+// IAEngine: 2D Game Engine by IA
+// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#pragma once
+
+#include
+#include
+
+namespace ia::iae
+{
+ class CameraNode : public Node2D
+ {
+ public:
+ IAE_DLL_API CameraNode(IN CONST String &name);
+
+ public:
+ CameraComponent *GetCameraComponent()
+ {
+ return m_cameraComponent;
+ }
+
+ protected:
+ CameraComponent *CONST m_cameraComponent{};
+ };
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Nodes/INode.hpp b/Engine/Src/Inc/IAEngine/Nodes/INode.hpp
index 94919f7..82a24a8 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/INode.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/INode.hpp
@@ -20,8 +20,25 @@
namespace ia::iae
{
- struct INode
+ class INode
{
- String Name{};
+ public:
+ INode(IN CONST String &name) : m_name(name)
+ {
+ }
+
+ PURE_VIRTUAL(VOID Draw());
+ PURE_VIRTUAL(VOID DebugDraw());
+ PURE_VIRTUAL(VOID Update());
+ PURE_VIRTUAL(VOID FixedUpdate());
+
+ public:
+ CONST String &GetName() CONST
+ {
+ return m_name;
+ }
+
+ protected:
+ CONST String m_name;
};
-}
\ No newline at end of file
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Nodes/Node2D.hpp b/Engine/Src/Inc/IAEngine/Nodes/Node2D.hpp
index 0d4d965..13054fb 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/Node2D.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/Node2D.hpp
@@ -16,9 +16,185 @@
#pragma once
+#include
#include
namespace ia::iae
{
-
-}
\ No newline at end of file
+ class Node2D : public INode
+ {
+ public:
+ IAE_DLL_API Node2D(IN CONST String &name);
+ IAE_DLL_API ~Node2D();
+
+ public:
+ template _component_type *AddComponent()
+ {
+ const auto t = new _component_type(this);
+ m_components.pushBack(t);
+ return t;
+ }
+
+ template _component_type *GetComponent()
+ {
+ for (auto &c : m_components)
+ {
+ _component_type *comp = dynamic_cast<_component_type *>(c.get());
+ if (comp)
+ return comp;
+ }
+ return nullptr;
+ }
+
+ template Vector<_component_type *> GetComponents()
+ {
+ Vector<_component_type *> result;
+ for (auto &c : m_components)
+ {
+ _component_type *comp = dynamic_cast<_component_type *>(c.get());
+ if (comp)
+ result.pushBack(comp);
+ }
+ return result;
+ }
+
+ public:
+ VOID Translate(IN Vec2 v)
+ {
+ m_local.Position += v;
+ RecalculatePosition();
+ }
+
+ VOID Scale(IN FLOAT32 v)
+ {
+ m_local.Scale *= v;
+ RecalculateScale();
+ }
+
+ VOID Scale(IN Vec2 v)
+ {
+ m_local.Scale *= v;
+ RecalculateScale();
+ }
+
+ VOID Rotate(IN FLOAT32 v)
+ {
+ m_local.Rotation += v;
+ RecalculateRotation();
+ }
+
+ VOID SetLocalPosition(IN CONST Vec2 &v)
+ {
+ m_local.Position = v;
+ RecalculatePosition();
+ }
+
+ VOID SetLocalScale(IN CONST Vec2 &v)
+ {
+ m_local.Scale = v;
+ RecalculateScale();
+ }
+
+ VOID SetLocalRotation(IN FLOAT32 v)
+ {
+ m_local.Rotation = v;
+ RecalculateRotation();
+ }
+
+ public:
+ CONST Vec2 &GetPosition() CONST
+ {
+ return m_global.Position;
+ }
+
+ CONST Vec2 &GetScale() CONST
+ {
+ return m_global.Scale;
+ }
+
+ CONST FLOAT32 &GetRotation() CONST
+ {
+ return m_global.Rotation;
+ }
+
+ CONST Vec2 &GetLocalPosition() CONST
+ {
+ return m_local.Position;
+ }
+
+ CONST Vec2 &GetLocalScale() CONST
+ {
+ return m_local.Scale;
+ }
+
+ CONST FLOAT32 &GetLocalRotation() CONST
+ {
+ return m_local.Rotation;
+ }
+
+ UINT8 &Layer()
+ {
+ return m_layer;
+ }
+
+ INT16 &SortIndex()
+ {
+ return m_sortIndex;
+ }
+
+ CONST UINT8 &Layer() CONST
+ {
+ return m_layer;
+ }
+
+ CONST INT16 &SortIndex() CONST
+ {
+ return m_sortIndex;
+ }
+
+ protected:
+ VOID RecalculatePosition()
+ {
+ m_global.Position = (m_parent ? m_parent->GetPosition() : Vec2{}) + m_local.Position;
+ for (auto &c : m_children)
+ c->RecalculatePosition();
+ }
+
+ VOID RecalculateRotation()
+ {
+ m_global.Rotation = (m_parent ? m_parent->GetRotation() : 0) + m_local.Rotation;
+ for (auto &c : m_children)
+ c->RecalculateRotation();
+ }
+
+ VOID RecalculateScale()
+ {
+ m_global.Scale = (m_parent ? m_parent->GetScale() : Vec2{}) + m_local.Scale;
+ for (auto &c : m_children)
+ c->RecalculateScale();
+ }
+
+ protected:
+ RefPtr m_parent{};
+ Vector m_components;
+ Vector> m_children{};
+
+ private:
+ struct
+ {
+ FLOAT32 Rotation{0.0f};
+ Vec2 Position{0.0f, 0.0f};
+ Vec2 Scale{1.0f, 1.0f};
+ } m_local{}, m_global{};
+
+ UINT8 m_layer{};
+ INT16 m_sortIndex{};
+
+ public:
+ VOID Draw();
+ VOID DebugDraw();
+
+ VOID Update();
+ VOID FixedUpdate();
+ };
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Nodes/SpriteNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/SpriteNode.hpp
index 0d4d965..759df24 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/SpriteNode.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/SpriteNode.hpp
@@ -16,7 +16,8 @@
#pragma once
-#include
+#include
+#include
namespace ia::iae
{
diff --git a/Engine/Src/Inc/IAEngine/Nodes/SpriteObjectNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/SpriteObjectNode.hpp
index 0d4d965..0d79a50 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/SpriteObjectNode.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/SpriteObjectNode.hpp
@@ -16,7 +16,7 @@
#pragma once
-#include
+#include
namespace ia::iae
{
diff --git a/Engine/Src/Inc/IAEngine/Nodes/TextureNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/TextureNode.hpp
index 0d4d965..9557a07 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/TextureNode.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/TextureNode.hpp
@@ -16,9 +16,23 @@
#pragma once
-#include
+#include
+#include
namespace ia::iae
{
-
-}
\ No newline at end of file
+ class TextureNode : public Node2D
+ {
+ public:
+ IAE_DLL_API TextureNode(IN CONST String &name);
+
+ public:
+ TextureComponent *GetTextureComponent()
+ {
+ return m_textureComponent;
+ }
+
+ protected:
+ TextureComponent *CONST m_textureComponent{};
+ };
+} // namespace ia::iae
\ No newline at end of file
diff --git a/Engine/Src/Inc/IAEngine/Nodes/TextureObjectNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/TextureObjectNode.hpp
index 0d4d965..3f91a00 100644
--- a/Engine/Src/Inc/IAEngine/Nodes/TextureObjectNode.hpp
+++ b/Engine/Src/Inc/IAEngine/Nodes/TextureObjectNode.hpp
@@ -16,7 +16,7 @@
#pragma once
-#include
+#include
namespace ia::iae
{
diff --git a/Engine/Src/Inc/IAEngine/Nodes/TileMapNode.hpp b/Engine/Src/Inc/IAEngine/Nodes/TileMapNode.hpp
new file mode 100644
index 0000000..e69de29
diff --git a/Samples/SpaceInvaders/Resources/Sprites/LICENCE b/Samples/SpaceInvaders/Resources/Sprites/LICENCE
new file mode 100644
index 0000000..dbcb9e2
--- /dev/null
+++ b/Samples/SpaceInvaders/Resources/Sprites/LICENCE
@@ -0,0 +1 @@
+Shout out to Anim86 for this amazing sprite pack! https://anim86.itch.io/space-shoter-starter-pack
diff --git a/Samples/SpaceInvaders/Resources/Sprites/SpaceShip.png b/Samples/SpaceInvaders/Resources/Sprites/SpaceShip.png
new file mode 100644
index 0000000..733fa8e
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/SpaceShip.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/Stars-A.png b/Samples/SpaceInvaders/Resources/Sprites/Stars-A.png
new file mode 100644
index 0000000..90dfcf8
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/Stars-A.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/Stars-B.png b/Samples/SpaceInvaders/Resources/Sprites/Stars-B.png
new file mode 100644
index 0000000..447905d
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/Stars-B.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bg.png b/Samples/SpaceInvaders/Resources/Sprites/bg.png
new file mode 100644
index 0000000..a093151
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bg.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bonus_life.png b/Samples/SpaceInvaders/Resources/Sprites/bonus_life.png
new file mode 100644
index 0000000..56c2160
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bonus_life.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bonus_shield.png b/Samples/SpaceInvaders/Resources/Sprites/bonus_shield.png
new file mode 100644
index 0000000..2823eca
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bonus_shield.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bonus_time.png b/Samples/SpaceInvaders/Resources/Sprites/bonus_time.png
new file mode 100644
index 0000000..e3f6bf1
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bonus_time.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bullet-1.png b/Samples/SpaceInvaders/Resources/Sprites/bullet-1.png
new file mode 100644
index 0000000..75d7806
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bullet-1.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bullet-2.png b/Samples/SpaceInvaders/Resources/Sprites/bullet-2.png
new file mode 100644
index 0000000..1d87ab2
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bullet-2.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/bullet.png b/Samples/SpaceInvaders/Resources/Sprites/bullet.png
new file mode 100644
index 0000000..6b0f167
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/bullet.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/fire.png b/Samples/SpaceInvaders/Resources/Sprites/fire.png
new file mode 100644
index 0000000..e6502c1
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/fire.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/insect-1.png b/Samples/SpaceInvaders/Resources/Sprites/insect-1.png
new file mode 100644
index 0000000..c904764
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/insect-1.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/insect-2.png b/Samples/SpaceInvaders/Resources/Sprites/insect-2.png
new file mode 100644
index 0000000..be492ff
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/insect-2.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/large-A.png b/Samples/SpaceInvaders/Resources/Sprites/large-A.png
new file mode 100644
index 0000000..100e05d
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/large-A.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/large-B.png b/Samples/SpaceInvaders/Resources/Sprites/large-B.png
new file mode 100644
index 0000000..4167ddd
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/large-B.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/laser-1.png b/Samples/SpaceInvaders/Resources/Sprites/laser-1.png
new file mode 100644
index 0000000..1e81094
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/laser-1.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/laser-2.png b/Samples/SpaceInvaders/Resources/Sprites/laser-2.png
new file mode 100644
index 0000000..c805148
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/laser-2.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/laser-3.png b/Samples/SpaceInvaders/Resources/Sprites/laser-3.png
new file mode 100644
index 0000000..4513bbf
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/laser-3.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/medium-A.png b/Samples/SpaceInvaders/Resources/Sprites/medium-A.png
new file mode 100644
index 0000000..5fd1c10
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/medium-A.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/medium-B.png b/Samples/SpaceInvaders/Resources/Sprites/medium-B.png
new file mode 100644
index 0000000..ec1392b
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/medium-B.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/plasm.png b/Samples/SpaceInvaders/Resources/Sprites/plasm.png
new file mode 100644
index 0000000..9a4219f
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/plasm.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/rocket.png b/Samples/SpaceInvaders/Resources/Sprites/rocket.png
new file mode 100644
index 0000000..ec7bfe3
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/rocket.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/shield.png b/Samples/SpaceInvaders/Resources/Sprites/shield.png
new file mode 100644
index 0000000..50b4f75
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/shield.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/small-A.png b/Samples/SpaceInvaders/Resources/Sprites/small-A.png
new file mode 100644
index 0000000..ba0d2a7
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/small-A.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/small-B.png b/Samples/SpaceInvaders/Resources/Sprites/small-B.png
new file mode 100644
index 0000000..33f700b
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/small-B.png differ
diff --git a/Samples/SpaceInvaders/Resources/Sprites/support.png b/Samples/SpaceInvaders/Resources/Sprites/support.png
new file mode 100644
index 0000000..61dc6a2
Binary files /dev/null and b/Samples/SpaceInvaders/Resources/Sprites/support.png differ
diff --git a/Samples/SpaceInvaders/Src/Imp/CPP/Game.cpp b/Samples/SpaceInvaders/Src/Imp/CPP/Game.cpp
index 615f6f3..bdd6031 100644
--- a/Samples/SpaceInvaders/Src/Imp/CPP/Game.cpp
+++ b/Samples/SpaceInvaders/Src/Imp/CPP/Game.cpp
@@ -16,14 +16,24 @@
#include
+Handle g_spriteBG;
+RefPtr backgroundNode;
+RefPtr mainCamera;
+
C_DECL(IA_DLL_EXPORT VOID Game_OnInitialize())
{
- GAME_LOG_INFO("Booting Game");
+ g_spriteBG = Engine::RescaleImage(Engine::CreateImageFromFile("Resources/Sprites/bg.png"), 800, 600);
+
+ mainCamera = MakeRefPtr("MainCamera");
+ Engine::SetActiveCamera(mainCamera->GetCameraComponent());
+
+ backgroundNode = MakeRefPtr("BG");
+ backgroundNode->GetTextureComponent()->SetTexture(g_spriteBG);
+ Engine::AddNodeToActiveScene(backgroundNode);
}
C_DECL(IA_DLL_EXPORT VOID Game_OnTerminate())
{
- GAME_LOG_INFO("Shutting down Game");
}
C_DECL(IA_DLL_EXPORT VOID Game_OnDebugDraw())