This commit is contained in:
Isuru Samarathunga
2025-10-31 15:06:23 +05:30
parent b8b9f6aa82
commit 9ff1d10d00
85 changed files with 1127 additions and 522 deletions

View File

@ -19,8 +19,6 @@
namespace ia::iae
{
STATIC Vector<Handle> TileTextures;
TileMapComponent::TileMapComponent(IN Node2D *node) : TextureComponent(node)
{
}
@ -45,30 +43,38 @@ namespace ia::iae
TextureComponent::FixedUpdate();
}
VOID TileMapComponent::BeginGridSetup(IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX,
IN INT32 tileCountY)
VOID TileMapComponent::Setup(IN InitializerList<TileEntryDesc> tileDescs, IN INT32 tileWidth, IN INT32 tileHeight,
IN INT32 tileCountX, IN INT32 tileCountY)
{
Vector<Handle> textures;
m_tileWidth = tileWidth;
m_tileHeight = tileHeight;
m_tileCountX = tileCountX;
m_tileCountY = tileCountY;
TileTextures.resize(m_tileCountX * m_tileCountY);
}
VOID TileMapComponent::SetupGridTile(IN INT32 index, IN Handle texture)
{
TileTextures[index] = texture;
}
m_tileEntries.reset();
m_tileEntries.reserve(tileDescs.size());
for (const auto &td : tileDescs)
{
const auto tileSet = (TileSet*)Engine::GetTileSet(td.TileSetName);
textures.pushBack(tileSet->GetTileTexture(td.TileIndex));
m_tileEntries.pushBack(TileEntry{.IsWalkable = td.IsWalkable});
}
VOID TileMapComponent::SetupGridTile(IN INT32 x, IN INT32 y, IN Handle texture)
{
TileTextures[x + y * m_tileCountX] = texture;
}
VOID TileMapComponent::EndGridSetup()
{
m_mapTexture = Engine::CombineImages(TileTextures, m_tileWidth, m_tileHeight, m_tileCountX, m_tileCountY);
if(m_mapTexture != INVALID_HANDLE)
Engine::DestroyImage(m_mapTexture);
m_mapTexture = Engine::CombineImages(textures, m_tileWidth, m_tileHeight, m_tileCountX, m_tileCountY);
SetTexture(m_mapTexture);
TileTextures.reset();
}
BOOL TileMapComponent::CanWalkX(IN Vec2 pixelPosition, IN FLOAT32 d)
{
return true;
}
BOOL TileMapComponent::CanWalkY(IN Vec2 pixelPosition, IN FLOAT32 d)
{
return true;
}
} // namespace ia::iae

View File

@ -74,7 +74,9 @@ namespace ia::iae
Vec2 Engine::CalculatePercentPosition(IN Vec2 percent)
{
return Vec2{Renderer::s_activeSceneDesignViewport.x/100.0f, Renderer::s_activeSceneDesignViewport.y/100.0f} * percent;
return Vec2{Renderer::s_activeSceneDesignViewport.x / 100.0f,
Renderer::s_activeSceneDesignViewport.y / 100.0f} *
percent;
}
Direction Engine::GetVectorPointingDirection(IN Vec2 v)
@ -121,6 +123,12 @@ namespace ia::iae
return CreateSound(name, data.data(), data.size());
}
Handle Engine::CreateTileSetFromFile(IN CONST String &name, IN CONST String &path, IN INT32 tileWidth,
IN INT32 tileHeight)
{
return CreateTileSet(name, CreateImageFromFile(name, path), tileWidth, tileHeight);
}
Handle Engine::RescaleImage(IN CONST String &name, IN Vec2 factor)
{
return ResourceManager::RescaleImage(GetImage(name), factor);

View File

@ -86,7 +86,7 @@ namespace ia::iae
IVec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
IVec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
static_cast<UINT32>(face->glyph->advance.x) >> 6,
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, face->glyph->bitmap.width, face->glyph->bitmap.rows, GLYPH_PIXEL_DATA.data()),
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, face->glyph->bitmap.width, face->glyph->bitmap.rows, face->glyph->bitmap.width, GLYPH_PIXEL_DATA.data()),
};
}

View File

@ -64,10 +64,11 @@ namespace ia::iae
}
SDL_GPUTexture *GPUResourceManager::CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width,
IN INT32 height, IN PCUINT8 rgbaData,
IN INT32 height, IN INT32 stride, IN PCUINT8 rgbaData,
IN SDL_GPUTextureFormat format, IN BOOL generateMipmaps)
{
const auto mipLevels = 1;//generateMipmaps ? ia_max((UINT32)(floor(log2(ia_max(width, height))) + 1), (UINT32)1) : (UINT32)1;
const auto mipLevels =
1; // generateMipmaps ? ia_max((UINT32)(floor(log2(ia_max(width, height))) + 1), (UINT32)1) : (UINT32)1;
STATIC Vector<UINT8> TMP_COLOR_BUFFER;
@ -87,15 +88,33 @@ namespace ia::iae
}
if (rgbaData)
{
TMP_COLOR_BUFFER.reset();
TMP_COLOR_BUFFER.resize(width * height * 4);
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
if (stride == width)
{
const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f;
TMP_COLOR_BUFFER[i * 4 + 0] = static_cast<UINT8>(rgbaData[i * 4 + 0] * a);
TMP_COLOR_BUFFER[i * 4 + 1] = static_cast<UINT8>(rgbaData[i * 4 + 1] * a);
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * a);
TMP_COLOR_BUFFER[i * 4 + 3] = rgbaData[i * 4 + 3];
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
{
const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f;
TMP_COLOR_BUFFER[i * 4 + 0] = static_cast<UINT8>(rgbaData[i * 4 + 0] * a);
TMP_COLOR_BUFFER[i * 4 + 1] = static_cast<UINT8>(rgbaData[i * 4 + 1] * a);
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * a);
TMP_COLOR_BUFFER[i * 4 + 3] = rgbaData[i * 4 + 3];
}
}
else
{
for(INT32 y = 0; y < height; y++)
{
for(INT32 x = 0; x < width; x++)
{
const auto p = &rgbaData[(x + y * stride) * 4];
const auto a = static_cast<FLOAT32>(p[3]) / 255.0f;
TMP_COLOR_BUFFER[(x + y * width) * 4 + 0] = static_cast<UINT8>(p[0] * a);
TMP_COLOR_BUFFER[(x + y * width) * 4 + 1] = static_cast<UINT8>(p[1] * a);
TMP_COLOR_BUFFER[(x + y * width) * 4 + 2] = static_cast<UINT8>(p[2] * a);
TMP_COLOR_BUFFER[(x + y * width) * 4 + 3] = p[3];
}
}
}
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,

View File

@ -30,6 +30,7 @@ namespace ia::iae
{
Map<String, Handle> ResourceManager::s_images;
Map<String, Handle> ResourceManager::s_sounds;
Map<String, RefPtr<TileSet>> ResourceManager::s_tileSets;
Vector<ResourceManager::ImageResource> ResourceManager::s_imageHandles;
VOID ResourceManager::Initialize()
@ -59,11 +60,12 @@ namespace ia::iae
return result;
}
Handle ResourceManager::CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
Handle ResourceManager::CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height,
IN INT32 stride)
{
const auto texture =
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, width,
height, rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
const auto texture = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, width, height,
(stride == -1) ? width : stride, rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
s_imageHandles.pushBack(ImageResource{.OriginalWidth = width,
.OriginalHeight = height,
.OriginalPixelData = new UINT8[width * height * 4],
@ -154,8 +156,8 @@ namespace ia::iae
s_imageHandles[image].OriginalHeight, s_imageHandles[image].OriginalWidth * 4,
nullptr, newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA);
const auto texture = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, newWidth, newHeight, newPixelData,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, newWidth, newHeight, newWidth,
newPixelData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
GPUResourceManager::DestroyTexture(s_imageHandles[image].Handle);
s_imageHandles[image].Handle = texture;
s_imageHandles[image].Width = newWidth;
@ -198,6 +200,44 @@ namespace ia::iae
for (auto &t : s_images)
t->Value = RescaleImage(t->Value, factor);
}
Handle ResourceManager::CreateTileSet(IN CONST String &name, IN Handle image, IN INT32 tileWidth,
IN INT32 tileHeight)
{
Vector<Handle> tileImages;
const auto extent = GetImageExtent(image);
for (INT32 y = 0; y < extent.y; y += tileHeight)
{
for (INT32 x = 0; x < extent.x; x += tileWidth)
{
const auto w = s_imageHandles[image].OriginalWidth;
tileImages.pushBack(CreateImage(BuildString(name, "_Tile", x, y),
&s_imageHandles[image].OriginalPixelData[(x + y * w) * 4], tileWidth,
tileHeight, w));
}
}
return CreateTileSet(name, tileImages, tileWidth, tileHeight);
}
Handle ResourceManager::CreateTileSet(IN CONST String &name, IN CONST Vector<Handle> &images, IN INT32 tileWidth,
IN INT32 tileHeight)
{
auto result = MakeRefPtr<TileSet>(images, tileWidth, tileHeight);
s_tileSets[name] = result;
return (Handle) (result.get());
}
Handle ResourceManager::GetTileSet(IN CONST String &name)
{
return (Handle) (s_tileSets[name].get());
}
VOID ResourceManager::DestroyTileSet(IN CONST String &name)
{
s_tileSets[name].reset();
}
} // namespace ia::iae
namespace ia::iae
@ -262,4 +302,25 @@ namespace ia::iae
{
return ResourceManager::CombineImages(images, unitWidth, unitHeight, unitCountX, unitCountY);
}
Handle Engine::CreateTileSet(IN CONST String &name, IN Handle image, IN INT32 tileWidth, IN INT32 tileHeight)
{
return ResourceManager::CreateTileSet(name, image, tileWidth, tileHeight);
}
Handle Engine::CreateTileSet(IN CONST String &name, IN CONST Vector<Handle> &images, IN INT32 tileWidth,
IN INT32 tileHeight)
{
return ResourceManager::CreateTileSet(name, images, tileWidth, tileHeight);
}
Handle Engine::GetTileSet(IN CONST String &name)
{
return ResourceManager::GetTileSet(name);
}
VOID Engine::DestroyTileSet(IN CONST String &name)
{
ResourceManager::DestroyTileSet(name);
}
} // namespace ia::iae

View File

@ -0,0 +1,29 @@
// 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/TileSet.hpp>
namespace ia::iae
{
TileSet::TileSet(IN CONST Vector<Handle> &images, IN INT32 tileWidth, IN INT32 tileHeight)
: m_images(images), m_tileWidth(tileWidth), m_tileHeight(tileHeight)
{
}
TileSet::~TileSet()
{
}
} // namespace ia::iae

View File

@ -30,7 +30,7 @@ namespace ia::iae
STATIC SDL_GPUSampler *GetSampler_LinearClamp();
STATIC SDL_GPUSampler *GetSampler_LinearRepeat();
STATIC SDL_GPUTexture *CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width, IN INT32 height, IN PCUINT8 rgbaData = nullptr, IN SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, IN BOOL generateMipmaps = false);
STATIC SDL_GPUTexture *CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width, IN INT32 height, IN INT32 stride, IN PCUINT8 rgbaData = nullptr, IN SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, IN BOOL generateMipmaps = false);
STATIC SDL_GPUBuffer *CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data, IN UINT32 dataSize);
STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle);
STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle);

View File

@ -17,6 +17,7 @@
#pragma once
#include <IAEngine/Base.hpp>
#include <IAEngine/TileSet.hpp>
#include <SDL3/SDL.h>
@ -40,16 +41,21 @@ namespace ia::iae
STATIC VOID Terminate();
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 CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height, IN INT32 stride = -1);
STATIC Handle CreateSound(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle CreateTileSet(IN CONST String& name, IN Handle image, IN INT32 tileWidth, IN INT32 tileHeight);
STATIC Handle CreateTileSet(IN CONST String& name, IN CONST Vector<Handle> &images, IN INT32 tileWidth, IN INT32 tileHeight);
STATIC Handle GetImage(IN CONST String &name);
STATIC Handle GetSound(IN CONST String &name);
STATIC String GetImageName(IN Handle handle);
STATIC String GetSoundName(IN Handle handle);
STATIC Handle GetTileSet(IN CONST String &name);
STATIC VOID DestroyImage(IN Handle image);
STATIC VOID DestroySound(IN Handle sound);
STATIC VOID DestroyTileSet(IN CONST String& name);
STATIC IVec2 GetImageExtent(IN Handle image);
STATIC IVec2 GetImageOriginalExtent(IN Handle image);
STATIC VOID RescaleAllImages(IN Vec2 factor);
@ -66,6 +72,7 @@ namespace ia::iae
private:
STATIC Map<String, Handle> s_images;
STATIC Map<String, Handle> s_sounds;
STATIC Map<String, RefPtr<TileSet>> s_tileSets;
STATIC Vector<ImageResource> s_imageHandles;
};
} // namespace ia::iae

View File

@ -17,14 +17,31 @@
#pragma once
#include <IAEngine/Components/TextureComponent.hpp>
#include <IAEngine/TileSet.hpp>
namespace ia::iae
{
class TileMapComponent : public TextureComponent
{
public:
struct TileEntry
{
BOOL IsWalkable{};
};
struct TileEntryDesc
{
BOOL IsWalkable{};
INT32 TileIndex{};
String TileSetName{};
};
public:
TileMapComponent(IN Node2D *node);
BOOL CanWalkX(IN Vec2 pixelPosition, IN FLOAT32 d);
BOOL CanWalkY(IN Vec2 pixelPosition, IN FLOAT32 d);
public:
VIRTUAL VOID Draw();
VIRTUAL VOID DebugDraw();
@ -33,10 +50,48 @@ namespace ia::iae
VIRTUAL VOID FixedUpdate();
public:
VOID BeginGridSetup(IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX, IN INT32 tileCountY);
VOID SetupGridTile(IN INT32 index, IN Handle texture);
VOID SetupGridTile(IN INT32 x, IN INT32 y, IN Handle texture);
VOID EndGridSetup();
VOID Setup(IN InitializerList<TileEntryDesc> tileDescs,
IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX, IN INT32 tileCountY);
TileEntry &GetTileEntry(IN INT32 index)
{
return m_tileEntries[index];
}
TileEntry &GetTileEntry(IN INT32 x, IN INT32 y)
{
return m_tileEntries[x + y * m_tileCountX];
}
CONST TileEntry &GetTileEntry(IN INT32 index) CONST
{
return m_tileEntries[index];
}
CONST TileEntry &GetTileEntry(IN INT32 x, IN INT32 y) CONST
{
return m_tileEntries[x + y * m_tileCountX];
}
INT32 GetTileWidth() CONST
{
return m_tileWidth;
}
INT32 GetTileHeight() CONST
{
return m_tileHeight;
}
INT32 GetTileCountX() CONST
{
return m_tileCountX;
}
INT32 GetTileCountY() CONST
{
return m_tileCountY;
}
private:
INT32 m_tileWidth{};
@ -44,5 +99,6 @@ namespace ia::iae
INT32 m_tileCountX{};
INT32 m_tileCountY{};
Handle m_mapTexture{INVALID_HANDLE};
Vector<TileEntry> m_tileEntries;
};
} // namespace ia::iae

View File

@ -24,9 +24,9 @@
#include <IAEngine/Components/CameraComponent.hpp>
#include <IAEngine/Components/SoundEmitterComponent.hpp>
#include <IAEngine/SceneManager.hpp>
#include <IAEngine/UI.hpp>
#include <IAEngine/Utils.hpp>
#include <IAEngine/SceneManager.hpp>
namespace ia::iae
{
@ -50,10 +50,14 @@ namespace ia::iae
STATIC IVec2 GetDisplayExtent();
STATIC FLOAT32 GetDisplayAspectRatio();
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
STATIC VOID DrawGeometry(IN Handle geometry, IN Handle texture, IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawQuad(IN Vec2 position, IN Handle texture, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawCircle(IN Vec2 position, IN Handle texture, IN FLOAT32 radius, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawText(IN CONST String& text, IN Vec2 position, IN FLOAT32 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawGeometry(IN Handle geometry, IN Handle texture, IN Vec2 position, IN Vec2 scale,
IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawQuad(IN Vec2 position, IN Handle texture, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer,
IN UINT16 sortIndex);
STATIC VOID DrawCircle(IN Vec2 position, IN Handle texture, IN FLOAT32 radius, IN FLOAT32 rotation,
IN UINT8 layer, IN UINT16 sortIndex);
STATIC VOID DrawText(IN CONST String &text, IN Vec2 position, IN FLOAT32 scale, IN FLOAT32 rotation,
IN UINT8 layer, IN UINT16 sortIndex);
STATIC Vec2 GetSceneDesignViewport();
STATIC VOID SetSceneDesignViewport(IN Vec2 value);
@ -92,6 +96,13 @@ namespace ia::iae
STATIC VOID RescaleAllImages(IN Vec2 factor);
STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY);
STATIC Handle CreateTileSetFromFile(IN CONST String &name, IN CONST String &path, IN INT32 tileWidth,
IN INT32 tileHeight);
STATIC Handle CreateTileSet(IN CONST String &name, IN Handle image, IN INT32 tileWidth, IN INT32 tileHeight);
STATIC Handle CreateTileSet(IN CONST String &name, IN CONST Vector<Handle> &images, IN INT32 tileWidth,
IN INT32 tileHeight);
STATIC Handle GetTileSet(IN CONST String &name);
STATIC VOID DestroyTileSet(IN CONST String &name);
// Game Functions
STATIC VOID SetTimeScale(IN FLOAT32 scale);
@ -100,7 +111,7 @@ namespace ia::iae
// Scene Functions
STATIC Scene *GetActiveScene();
STATIC VOID ChangeActiveScene(IN Scene* scene);
STATIC VOID ChangeActiveScene(IN Scene *scene);
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC INode *GetNodeFromActiveScene(IN CONST String &name);
STATIC VOID RemoveNodeFromActiveScene(IN CONST String &name);
@ -108,30 +119,30 @@ namespace ia::iae
// Input Functions
STATIC VOID Input_SwitchModeToText();
STATIC VOID Input_SwitchModeToAction();
STATIC VOID Input_SetupOnScreenGamePad();
STATIC VOID Input_SetupKeyboardGamePad(IN InputKey axisLeft, IN InputKey axisRight, IN InputKey axisDown,
IN InputKey axisUp, IN InputKey buttonA, IN InputKey buttonB,
IN InputKey buttonC, IN InputKey buttonD);
IN InputKey axisUp, IN InputKey buttonA, IN InputKey buttonB,
IN InputKey buttonC, IN InputKey buttonD);
STATIC VOID Input_EnableOnScreenGamePad();
STATIC VOID Input_DisableOnScreenGamePad();
STATIC BOOL Input_IsPointerDown();
STATIC Vec2 Input_GetPointerPosition();
STATIC BOOL Input_DidPointerClick(IN CONST Vec2& start, IN CONST Vec2& end);
STATIC BOOL Input_IsPointerDown(IN CONST Vec2& start, IN CONST Vec2& end);
STATIC BOOL Input_DidPointerClick(IN CONST Vec2& center, IN FLOAT32 radius);
STATIC BOOL Input_IsPointerDown(IN CONST Vec2& center, IN FLOAT32 radius);
STATIC BOOL Input_DidPointerClick(IN CONST Vec2 &start, IN CONST Vec2 &end);
STATIC BOOL Input_IsPointerDown(IN CONST Vec2 &start, IN CONST Vec2 &end);
STATIC BOOL Input_DidPointerClick(IN CONST Vec2 &center, IN FLOAT32 radius);
STATIC BOOL Input_IsPointerDown(IN CONST Vec2 &center, IN FLOAT32 radius);
STATIC BOOL Input_IsKeyDown(IN InputKey key);
STATIC BOOL Input_WasKeyPressed(IN InputKey key);
STATIC BOOL Input_WasKeyReleased(IN InputKey key);
STATIC BOOL Input_GetButtonA();
STATIC BOOL Input_GetButtonB();
STATIC BOOL Input_GetButtonC();
STATIC BOOL Input_GetButtonD();
STATIC BOOL Input_GetButtonA();
STATIC BOOL Input_GetButtonB();
STATIC BOOL Input_GetButtonC();
STATIC BOOL Input_GetButtonD();
STATIC INT16 Input_GetVerticalAxis();
STATIC INT16 Input_GetHorizontalAxis();
STATIC IVec2 Input_GetDirectionalInput();
@ -143,9 +154,9 @@ namespace ia::iae
STATIC VOID Input_SetHorizontalAxis(IN INT16 value);
// Utility Functions
STATIC String ReadTextAsset(IN CONST String& path);
STATIC String ReadTextAsset(IN CONST String &path);
STATIC Direction GetVectorPointingDirection(IN Vec2 v);
STATIC Vector<UINT8> ReadBinaryAsset(IN CONST String& path);
STATIC Vector<UINT8> ReadBinaryAsset(IN CONST String &path);
STATIC Vec2 CalculatePercentPosition(IN Vec2 percent);
// Random Functions

View File

@ -0,0 +1,50 @@
// 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/Base.hpp>
namespace ia::iae
{
class TileSet
{
public:
TileSet(IN CONST Vector<Handle> &images, IN INT32 tileWidth, IN INT32 tileHeight);
~TileSet();
public:
Handle GetTileTexture(IN INT32 index) CONST
{
return m_images[index];
}
INT32 GetTileWidth() CONST
{
return m_tileWidth;
}
INT32 GetTileHeight() CONST
{
return m_tileHeight;
}
private:
Vector<Handle> m_images;
CONST INT32 m_tileWidth;
CONST INT32 m_tileHeight;
};
} // namespace ia::iae