Compare commits

...

2 Commits

Author SHA1 Message Date
ce9ea1fd52 Fixes 2025-10-12 20:42:31 +05:30
4380705f81 Fixes 2025-10-12 16:39:29 +05:30
19 changed files with 558 additions and 171 deletions

View File

@ -1,10 +1,11 @@
set(SRC_FILES
"Src/Imp/CPP/UI.cpp"
"Src/Imp/CPP/Time.cpp"
"Src/Imp/CPP/Utils.cpp"
"Src/Imp/CPP/Scene.cpp"
"Src/Imp/CPP/Random.cpp"
"Src/Imp/CPP/Engine.cpp"
"Src/Imp/CPP/Utils.cpp"
"Src/Imp/CPP/Physics.cpp"
"Src/Imp/CPP/InternalEngine.cpp"
"Src/Imp/CPP/InputManager.cpp"

View File

@ -46,7 +46,7 @@ namespace ia::iae
VOID CameraComponent::Update()
{
const auto pos = m_node->GetPosition();
const auto pos = m_node->GetPosition() + m_positionOffset;
m_viewMatrix = glm::lookAtLH(glm::vec3{pos, -2.0f}, {pos, 0.0f}, {0.0f, 1.0f, 0.0f});
}

View File

@ -0,0 +1,83 @@
// 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 <https://www.gnu.org/licenses/>.
#include <Physics.hpp>
#include <IAEngine/Nodes/Node2D.hpp>
#include <IAEngine/Components/PhysicsComponent.hpp>
namespace ia::iae
{
PhysicsComponent::PhysicsComponent(IN Node2D *node) : IComponent(node)
{
m_physicsHandle = Physics::RegisterComponent(this);
}
VOID PhysicsComponent::Draw()
{
}
VOID PhysicsComponent::DebugDraw()
{
}
VOID PhysicsComponent::Update()
{
m_velocity = {};
}
VOID PhysicsComponent::FixedUpdate()
{
}
Handle PhysicsComponent::CreateCollider()
{
m_colliders.pushBack({});
return m_colliders.size() - 1;
}
Handle PhysicsComponent::AddCollider(IN Collider collider)
{
m_colliders.pushBack(collider);
return m_colliders.size() - 1;
}
PhysicsComponent::Collider &PhysicsComponent::GetCollider(IN Handle handle)
{
return m_colliders[handle];
}
VOID PhysicsComponent::Move(IN glm::vec2 direction)
{
IA_ASSERT(m_isDynamic);
const auto v = direction * m_movementSpeed;
m_velocity += v;
for(const auto& t: m_colliders)
{
if(!Physics::CanMove(m_physicsHandle, t, v))
return;
}
m_node->SetLocalPosition(m_node->GetLocalPosition() + v);
}
VOID PhysicsComponent::Jump(IN FLOAT32 force)
{
}
VOID PhysicsComponent::OnCollision(IN PhysicsComponent *other)
{
}
} // namespace ia::iae

View File

@ -24,7 +24,6 @@
namespace ia::iae
{
EXTERN GameFunctionTable g_gameFunctions;
EXTERN SDL_Window *g_windowHandle;
SIZE_T g_resourceNameCounter = 1;
@ -37,13 +36,27 @@ namespace ia::iae
#endif
}
Direction Engine::GetVectorPointingDirection(IN Vec2 v)
{
STATIC CONSTEXPR Direction DIRECTION_MAP[] = {Direction::RIGHT, Direction::DOWN_RIGHT, Direction::DOWN, Direction::DOWN_LEFT,
Direction::LEFT, Direction::UP_LEFT, Direction::UP, Direction::UP_RIGHT};
if ((abs(v.x) <= FLOAT32_EPSILON) && (abs(v.y) <= FLOAT32_EPSILON))
return Direction::NONE;
auto angle = glm::degrees(atan2(v.y, v.x));
if (angle < 0)
angle += 360;
return DIRECTION_MAP[INT32((angle + 22.5) / 45) % 8];
}
VOID Engine::ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight)
{
Renderer::WaitForGPUIdle();
SDL_SetWindowSize(g_windowHandle, newWidth, newHeight);
Renderer::OnScreenResize(newWidth, newHeight);
UI::OnScreenResize(newWidth, newHeight);
g_gameFunctions.OnResize(newWidth, newHeight);
Game_OnResize(newWidth, newHeight);
}
Handle Engine::CreateImageFromFile(IN CONST String &name, IN CONST String &path, IN INT32 resizeToWidth,

View File

@ -22,6 +22,7 @@
#include <Renderer/Renderer.hpp>
#include <ResourceManager.hpp>
#include <Time.hpp>
#include <Physics.hpp>
#include <WorldManager.hpp>
#include <IAEngine/Engine.hpp>
@ -32,28 +33,32 @@
namespace ia::iae
{
GameFunctionTable g_gameFunctions{};
String g_gameName;
String g_gamePackageName;
String g_gameDeveloperName;
String g_gamePublisherName;
IA_VERSION_TYPE g_gameVersion{};
SDL_Window *g_windowHandle;
VOID __Internal_Engine::Initialize()
{
const auto config = g_gameFunctions.GetConfigRequest();
const auto config = Game_GetConfigRequest();
IAE_LOG_INFO("Booting IAEngine for ", g_gameFunctions.GetName());
IAE_LOG_INFO("Booting IAEngine for ", g_gameName);
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
if (!(g_windowHandle = SDL_CreateWindow(g_gameFunctions.GetName(), config.ScreenWidth, config.ScreenHeight,
if (!(g_windowHandle = SDL_CreateWindow(g_gameName.c_str(), config.ScreenWidth, config.ScreenHeight,
SDL_WINDOW_RESIZABLE)))
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
// SDL_SetWindowResizable(g_windowHandle, false);
const auto gameVersion = g_gameFunctions.GetVersion();
SDL_SetAppMetadata(g_gameFunctions.GetName(), BuildString(gameVersion).c_str(),
g_gameFunctions.GetPackageName());
const auto gameVersion = g_gameVersion;
SDL_SetAppMetadata(g_gameName.c_str(), IA_STRINGIFY_VERSION(gameVersion).c_str(),
g_gamePackageName.c_str());
Time::Initialize();
Random::Initialize();
@ -64,14 +69,16 @@ namespace ia::iae
ResourceManager::Initialize();
WorldManager::Initialize();
UI::Initialize();
Physics::Initialize();
g_gameFunctions.OnInitialize();
Game_OnInitialize();
}
VOID __Internal_Engine::Terminate()
{
g_gameFunctions.OnTerminate();
Game_OnTerminate();
Physics::Terminate();
UI::Terminate();
WorldManager::Terminate();
ResourceManager::Terminate();
@ -90,10 +97,11 @@ namespace ia::iae
VOID __Internal_Engine::Iterate()
{
UI::Update();
Physics::Update();
WorldManager::Update();
WorldManager::FixedUpdate();
g_gameFunctions.OnUpdate(Time::GetFrameDeltaTime());
g_gameFunctions.OnFixedUpdate();
Game_OnUpdate(Time::GetFrameDeltaTime());
Game_OnFixedUpdate();
Renderer::BeginFrame();
WorldManager::Draw();
@ -120,43 +128,13 @@ namespace ia::iae
return (FLOAT32) m_value + ((FLOAT32) m_value * (Random::Get() * m_randomAdjustment) / 100.0f);
}
BOOL ValidateGameFunctionTable(IN GameFunctionTable gameFunctionTable)
INT32 Run(IN CONST String& name, IN CONST String& packageName, IN CONST String& developerName, IN CONST String& publisherName, IN IA_VERSION_TYPE version)
{
if (!gameFunctionTable.GetConfigRequest)
return false;
if (!gameFunctionTable.OnInitialize)
return false;
if (!gameFunctionTable.OnTerminate)
return false;
if (!gameFunctionTable.OnDebugDraw)
return false;
if (!gameFunctionTable.OnFixedUpdate)
return false;
if (!gameFunctionTable.OnUpdate)
return false;
if (!gameFunctionTable.OnResize)
return false;
if (!gameFunctionTable.GetName)
return false;
if (!gameFunctionTable.GetVersion)
return false;
if (!gameFunctionTable.GetPackageName)
return false;
if (!gameFunctionTable.GetDeveloperName)
return false;
if (!gameFunctionTable.GetPublisherName)
return false;
return true;
}
INT32 Run(IN GameFunctionTable gameFunctionTable)
{
if (!ValidateGameFunctionTable(gameFunctionTable))
{
IAE_LOG_ERROR("Invalid game function table was passed to the engine. Exiting..");
return -1;
}
g_gameFunctions = gameFunctionTable;
g_gameName = name;
g_gameVersion = version;
g_gamePackageName = packageName;
g_gameDeveloperName = developerName;
g_gamePublisherName = publisherName;
__Internal_Engine::Initialize();

View File

@ -0,0 +1,95 @@
// 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 <https://www.gnu.org/licenses/>.
#include <IAEngine/Engine.hpp>
#include <Physics.hpp>
namespace ia::iae
{
BOOL g_physicsDebugDrawEnabled = false;
Vector<PhysicsComponent *> g_physicsComponents;
VOID Physics::Initialize()
{
}
VOID Physics::Terminate()
{
}
VOID Physics::Update()
{
if(Engine::WasInputKeyPressed(InputKey::F6))
g_physicsDebugDrawEnabled = !g_physicsDebugDrawEnabled;
}
VOID Physics::DebugDraw()
{
if (!g_physicsDebugDrawEnabled)
return;
for (const auto &t : g_physicsComponents)
{
for (const auto &c : t->Colliders())
{
auto color = Color{192, 0, 0, 0xFF};
if (c.IsTrigger)
color = {64, 96, 192, 192};
Engine::DebugDraw_SetColor(color);
Engine::DebugDraw_SetStrokeWidth(2);
Engine::DebugDraw_StrokeRect(t->GetNode()->GetPosition() + c.Position -
Engine::GetActiveCamera()->GetNode()->GetPosition(),
c.Size);
}
}
}
Handle Physics::RegisterComponent(IN PhysicsComponent *component)
{
g_physicsComponents.pushBack(component);
return g_physicsComponents.size() - 1;
}
BOOL Physics::CanMove(IN Handle handle, IN CONST PhysicsComponent::Collider &collider, IN glm::vec2 movement)
{
const auto comp = g_physicsComponents[handle];
const auto pos = comp->GetNode()->GetPosition() + movement + collider.Position;
for (const auto &t : g_physicsComponents)
{
if (t == comp)
continue;
for (const auto &tc : t->Colliders())
{
const auto tPos = t->GetNode()->GetPosition() + tc.Position;
const auto xColliding = ((pos.x + collider.Size.x) >= tPos.x) && ((tPos.x + tc.Size.x) >= pos.x);
const auto yColliding = ((pos.y + collider.Size.y) >= tPos.y) && ((tPos.y + tc.Size.y) >= pos.y);
if (xColliding && yColliding)
{
// Collision callback
comp->OnCollision(t);
t->OnCollision(comp);
// Overlap block
if (tc.IsTrigger)
continue;
return false;
}
}
}
return true;
}
} // namespace ia::iae

View File

@ -18,6 +18,7 @@
#include <Renderer/Renderer.hpp>
#include <Renderer/DebugDraw.hpp>
#include <Physics.hpp>
#include <WorldManager.hpp>
#include <IAEngine/imgui/backends/imgui_impl_sdl3.h>
@ -27,7 +28,6 @@
namespace ia::iae
{
EXTERN GameFunctionTable g_gameFunctions;
EXTERN SDL_Window *g_windowHandle;
ImGuiIO g_imGUIIO{};
@ -69,8 +69,9 @@ namespace ia::iae
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
Physics::DebugDraw();
WorldManager::DebugDraw();
g_gameFunctions.OnDebugDraw();
Game_OnDebugDraw();
ImGui::Render();
}
@ -89,7 +90,7 @@ namespace ia::iae
g_debugDrawState.ActiveColor = IM_COL32(color.R, color.G, color.B, color.A);
}
VOID Engine::DebugDraw_StrokeWidth(IN FLOAT32 width)
VOID Engine::DebugDraw_SetStrokeWidth(IN FLOAT32 width)
{
g_debugDrawState.ActiveStrokeWidth = width;
}

View File

@ -239,7 +239,8 @@ namespace ia::iae
const auto sceneExtent = activeScene->Extent();
s_state.SceneScaleFactor = {(FLOAT32) newWidth / (FLOAT32) sceneExtent.x,
(FLOAT32) newHeight / (FLOAT32) sceneExtent.y};
IAE_LOG_INFO("Updated Scene Scale Factor: (", s_state.SceneScaleFactor.x, ", ", s_state.SceneScaleFactor.y, ")");
IAE_LOG_INFO("Updated Scene Scale Factor: (", s_state.SceneScaleFactor.x, ", ", s_state.SceneScaleFactor.y,
")");
}
}
@ -319,6 +320,11 @@ namespace ia::iae
Renderer::OnScreenResize(Renderer::s_screenWidth, Renderer::s_screenHeight);
}
CameraComponent *Engine::GetActiveCamera()
{
return Renderer::s_state.ActiveCamera;
}
Handle Engine::CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices)
{
return (Handle) Renderer::CreateGeometry(vertices, indices);
@ -379,7 +385,7 @@ namespace ia::iae
sortIndex += static_cast<INT16>(position.y);
position *= Renderer::s_state.SceneScaleFactor;
//scale *= Renderer::s_state.SceneScaleFactor;
// scale *= Renderer::s_state.SceneScaleFactor;
Renderer::s_state.ModelMatrix =
glm::translate(glm::mat4(1.0f), glm::vec3{position.x, position.y,

View File

@ -52,10 +52,71 @@ namespace ia::iae
{
}
VOID ProcessEvent(IN Rml::Event &event)
VOID AddClickListener(IN Rml::Element *element, IN std::function<VOID()> callback)
{
element->AddEventListener("click", this);
m_clickCallbacks[element->GetId().c_str()] = callback;
}
// VOID AddHoverEnterListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
//{
// m_document->GetElementById(elementId)->AddEventListener("mouseover", this);
// m_hoverEnterCallbacks[elementId] = callback;
// }
//
// VOID AddHoverExitListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
//{
// m_document->GetElementById(elementId)->AddEventListener("mouseout", this);
// m_hoverExitCallbacks[elementId] = callback;
//}
//
// VOID AddPointerDownListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
//{
// m_document->GetElementById(elementId)->AddEventListener("mousedown", this);
// m_pointerDownCallbacks[elementId] = callback;
//}
//
// VOID AddPointerUpListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
//{
// m_document->GetElementById(elementId)->AddEventListener("mouseup", this);
// m_pointerUpCallbacks[elementId] = callback;
//}
VOID ProcessEvent(IN Rml::Event &event)
{
switch (event.GetId())
{
case Rml::EventId::Click:
m_clickCallbacks[event.GetTargetElement()->GetId().c_str()]();
break;
case Rml::EventId::Mouseover:
m_hoverEnterCallbacks[event.GetTargetElement()->GetId().c_str()]();
break;
case Rml::EventId::Mouseout:
m_hoverExitCallbacks[event.GetTargetElement()->GetId().c_str()]();
break;
case Rml::EventId::Mousedown:
m_pointerDownCallbacks[event.GetTargetElement()->GetId().c_str()]();
break;
case Rml::EventId::Mouseup:
m_pointerUpCallbacks[event.GetTargetElement()->GetId().c_str()]();
break;
default:
break;
}
}
private:
Map<String, std::function<VOID()>> m_clickCallbacks;
Map<String, std::function<VOID()>> m_hoverEnterCallbacks;
Map<String, std::function<VOID()>> m_hoverExitCallbacks;
Map<String, std::function<VOID()>> m_pointerDownCallbacks;
Map<String, std::function<VOID()>> m_pointerUpCallbacks;
} g_eventListener{};
/* Taken from https://github.com/mikke89/RmlUi/blob/master/Backends/RmlUi_Platform_SDL.cpp */
@ -396,6 +457,11 @@ namespace ia::iae
g_document->SetInnerRML(
BuildString("<body style=\"display: block; width: 100%; height: 100%;\">", source, "</body>").c_str());
}
VOID UI::AddClickEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)
{
g_eventListener.AddClickListener(g_document->GetElementById(elementId), callback);
}
} // namespace ia::iae
namespace ia::iae

View File

@ -0,0 +1,40 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Components/PhysicsComponent.hpp>
namespace ia::iae
{
class Physics
{
public:
STATIC Handle RegisterComponent(IN PhysicsComponent* component);
STATIC BOOL CanMove(IN Handle handle, IN CONST PhysicsComponent::Collider& collider, IN glm::vec2 movement);
private:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID Update();
STATIC VOID DebugDraw();
friend class DebugDraw;
friend class __Internal_Engine;
};
}

View File

@ -102,6 +102,18 @@ namespace ia::iae
Vec4 Color{};
};
enum class Direction : UINT8 {
NONE = 255,
DOWN = 0,
DOWN_LEFT,
LEFT,
UP_LEFT,
UP,
UP_RIGHT,
RIGHT,
DOWN_RIGHT
};
struct Color
{
UINT8 R{0xFF};

View File

@ -35,6 +35,11 @@ namespace ia::iae
public:
VOID SetViewport(IN INT32 width, IN INT32 height);
Vec2& PositionOffset()
{
return m_positionOffset;
}
Vec4 GetViewport() CONST
{
return m_viewport;
@ -53,6 +58,7 @@ namespace ia::iae
private:
Vec4 m_viewport{};
Mat4 m_viewMatrix{1.0f};
Vec2 m_positionOffset{};
Mat4 m_projectionMatrix{1.0f};
};
} // namespace ia::iae

View File

@ -0,0 +1,83 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Components/IComponent.hpp>
namespace ia::iae
{
class PhysicsComponent : public IComponent
{
public:
struct Collider
{
BOOL IsTrigger{false};
Vec2 Position{};
Vec2 Size{};
};
public:
PhysicsComponent(IN Node2D *node);
Handle CreateCollider();
Handle AddCollider(IN Collider collider);
Collider &GetCollider(IN Handle handle);
VOID Move(IN glm::vec2 direction);
VOID Jump(IN FLOAT32 force);
public:
BOOL &IsDynamic()
{
return m_isDynamic;
}
FLOAT32 &MovementSpeed()
{
return m_movementSpeed;
}
Vector<Collider> &Colliders()
{
return m_colliders;
}
CONST Vec2 &GetVelocity() CONST
{
return m_velocity;
}
private:
Vec2 m_velocity{};
BOOL m_isDynamic{false};
Vector<Collider> m_colliders;
FLOAT32 m_movementSpeed{1.0f};
Handle m_physicsHandle{INVALID_HANDLE};
VOID OnCollision(IN PhysicsComponent *other);
friend class Physics;
public:
VIRTUAL VOID Draw();
VIRTUAL VOID DebugDraw();
VIRTUAL VOID Update();
VIRTUAL VOID FixedUpdate();
};
} // namespace ia::iae

View File

@ -24,8 +24,8 @@
#include <IAEngine/Components/CameraComponent.hpp>
#include <IAEngine/Components/SoundEmitterComponent.hpp>
#include <IAEngine/UI.hpp>
#include <IAEngine/Scene.hpp>
#include <IAEngine/UI.hpp>
#include <IAEngine/Utils.hpp>
namespace ia::iae
@ -34,103 +34,104 @@ 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<VOID()> callback);
STATIC VOID AddEventListener(IN CONST String &eventName, IN std::function<VOID()> callback);
STATIC VOID BroadcastEvent(IN Handle event);
STATIC VOID BroadcastEvent(IN CONST String &eventName);
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<VOID()> callback);
STATIC VOID AddEventListener(IN CONST String &eventName, IN std::function<VOID()> callback);
STATIC VOID BroadcastEvent(IN Handle event);
STATIC VOID BroadcastEvent(IN CONST String &eventName);
// Renderer Functions
STATIC Handle GetGeometry_Quad();
STATIC Handle CreateGeometry(IN CONST Vector<GeometryVertex> &vertices,
IN CONST Vector<INT32> &indices);
STATIC VOID DestroyGeometry(IN Handle geometry);
STATIC VOID DrawGeometry(IN Handle handle);
STATIC IVec2 GetDisplayExtent();
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
STATIC Handle GetGeometry_Quad();
STATIC Handle CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices);
STATIC VOID DestroyGeometry(IN Handle geometry);
STATIC VOID DrawGeometry(IN Handle handle);
STATIC IVec2 GetDisplayExtent();
STATIC 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 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);
// 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 VOID DebugDraw_SetColor(IN Color color);
STATIC VOID DebugDraw_SetStrokeWidth(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);
// Resource Functions
STATIC Handle CreateSoundFromFile(IN CONST String &name, IN CONST String &path);
STATIC Handle CreateImageFromFile(IN CONST String &name, IN CONST String &path,
IN INT32 resizeToWidth = 0, IN INT32 resizeToHeight = 0);
STATIC Handle CreateImage(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width,
IN INT32 height);
STATIC Handle CreateSound(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle GetImage(IN CONST String &name);
STATIC Handle GetSound(IN CONST String &name);
STATIC VOID DestroyImage(IN Handle image);
STATIC VOID DestroySound(IN Handle sound);
STATIC IVec2 GetImageExtent(IN Handle image);
STATIC Handle ResizeImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC Handle ResizeImage(IN CONST String& name, IN INT32 newWidth, IN INT32 newHeight);
STATIC VOID RescaleAllImages(IN FLOAT32 factorX, IN FLOAT32 factorY);
STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth,
IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
STATIC Handle CreateSoundFromFile(IN CONST String &name, IN CONST String &path);
STATIC Handle CreateImageFromFile(IN CONST String &name, IN CONST String &path, IN INT32 resizeToWidth = 0,
IN INT32 resizeToHeight = 0);
STATIC Handle CreateImage(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
STATIC Handle CreateSound(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle GetImage(IN CONST String &name);
STATIC Handle GetSound(IN CONST String &name);
STATIC VOID DestroyImage(IN Handle image);
STATIC VOID DestroySound(IN Handle sound);
STATIC IVec2 GetImageExtent(IN Handle image);
STATIC Handle ResizeImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC Handle ResizeImage(IN CONST String &name, IN INT32 newWidth, IN INT32 newHeight);
STATIC VOID RescaleAllImages(IN FLOAT32 factorX, IN FLOAT32 factorY);
STATIC Handle CombineImages(IN CONST Vector<Handle> &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 CameraComponent *cameraComponent);
STATIC VOID SetTimeScale(IN FLOAT32 scale);
STATIC VOID SetActiveCamera(IN CameraComponent *cameraComponent);
STATIC CameraComponent *GetActiveCamera();
// Scene Functions
STATIC RefPtr<Scene> CreateSceneFromFile(IN CONST String &path);
STATIC Scene *GetActiveScene();
STATIC VOID ChangeActiveScene(IN RefPtr<Scene> scene);
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC INode *GetNodeFromActiveScene(IN CONST String &name);
STATIC VOID RemoveNodeFromActiveScene(IN CONST String &name);
STATIC RefPtr<Scene> CreateSceneFromFile(IN CONST String &path);
STATIC Scene *GetActiveScene();
STATIC VOID ChangeActiveScene(IN RefPtr<Scene> scene);
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC INode *GetNodeFromActiveScene(IN CONST String &name);
STATIC VOID RemoveNodeFromActiveScene(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 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);
// Utility Functions
STATIC Direction GetVectorPointingDirection(IN Vec2 v);
// Random Functions
STATIC FLOAT32 GetRandomFloat();
STATIC INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
STATIC FLOAT32 GetRandomFloat();
STATIC INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
// Time Functions
STATIC INT64 GetTickCount();
STATIC INT64 GetUnixSecond();
STATIC INT64 GetUnixMillisecond();
STATIC FLOAT32 GetFrameDeltaTime();
STATIC INT64 GetTickCount();
STATIC INT64 GetUnixSecond();
STATIC INT64 GetUnixMillisecond();
STATIC FLOAT32 GetFrameDeltaTime();
// Engine Functions
STATIC BOOL IsDebugMode();
STATIC String GetUniqueResourceName();
STATIC BOOL IsDebugMode();
STATIC String GetUniqueResourceName();
};
} // namespace ia::iae

View File

@ -18,32 +18,30 @@
#include <IAEngine/Engine.hpp>
using namespace ia;
using namespace ia::iae;
struct GameRequestedConfig
{
INT32 ScreenWidth{};
INT32 ScreenHeight{};
};
C_DECL(GameRequestedConfig Game_GetConfigRequest());
C_DECL(VOID Game_OnInitialize());
C_DECL(VOID Game_OnTerminate());
C_DECL(VOID Game_OnDebugDraw());
C_DECL(VOID Game_OnFixedUpdate());
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime));
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight));
namespace ia::iae
{
INT32 Run(IN CONST String& name, IN CONST String& packageName, IN CONST String& developerName, IN CONST String& publisherName, IN IA_VERSION_TYPE version);
} // namespace ia::iae
struct GameRequestedConfig
{
INT32 ScreenWidth{};
INT32 ScreenHeight{};
};
struct GameFunctionTable
{
GameRequestedConfig (*GetConfigRequest)(){nullptr};
VOID (*OnInitialize)(){nullptr};
VOID (*OnTerminate)(){nullptr};
VOID (*OnDebugDraw)(){nullptr};
VOID (*OnFixedUpdate)(){nullptr};
VOID (*OnUpdate)(IN FLOAT32 deltaTime){nullptr};
VOID (*OnResize)(IN INT32 newWidth, IN INT32 newHeight){nullptr};
PCCHAR (*GetName)(){nullptr};
UINT64 (*GetVersion)(){nullptr};
PCCHAR (*GetPackageName)(){nullptr};
PCCHAR (*GetDeveloperName)(){nullptr};
PCCHAR (*GetPublisherName)(){nullptr};
};
INT32 Run(IN GameFunctionTable gameFunctionTable);
} // namespace ia::iae
#if defined(__ANDROID__)
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) int SDL_main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
#else
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) int main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
#endif

View File

@ -17,6 +17,7 @@
#pragma once
#include <IAEngine/Nodes/SpriteNode.hpp>
#include <IAEngine/Components/PhysicsComponent.hpp>
namespace ia::iae
{

View File

@ -17,6 +17,7 @@
#pragma once
#include <IAEngine/Nodes/TextureNode.hpp>
#include <IAEngine/Components/PhysicsComponent.hpp>
namespace ia::iae
{

View File

@ -22,12 +22,14 @@ namespace ia::iae
{
class UI
{
public:
STATIC VOID AddFontFromFile(IN CONST String& path);
STATIC VOID SetHTML(IN CONST String& source);
public:
STATIC VOID AddFontFromFile(IN CONST String &path);
public:
STATIC VOID SetHTML(IN CONST String &source);
STATIC VOID AddClickEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
@ -35,6 +37,6 @@ namespace ia::iae
STATIC VOID Draw();
STATIC VOID OnSDLEvent(IN PVOID event);
STATIC VOID OnScreenResize(IN INT32 newWidth, IN INT32 newHeight);
};
}
STATIC VOID OnScreenResize(IN INT32 newWidth, IN INT32 newHeight);
};
} // namespace ia::iae

2
Vendor/IACore vendored