Compare commits

...

7 Commits

Author SHA1 Message Date
c71272ff13 Fixes 2025-10-31 21:47:59 +05:30
050027fcb0 Fixes 2025-10-31 17:16:01 +05:30
f9007403d9 Fixes 2025-10-31 15:08:23 +05:30
9ff1d10d00 TileSet 2025-10-31 15:06:23 +05:30
b8b9f6aa82 Sample: RPG: Init 2025-10-31 01:15:44 +05:30
0916385521 Sample: RPG: Init 2025-10-31 01:14:48 +05:30
0afd478761 Sample: RPG: Init 2025-10-31 01:14:19 +05:30
80 changed files with 554 additions and 76 deletions

16
.gitignore vendored
View File

@ -46,12 +46,14 @@
*.vsix *.vsix
.cache/ .cache/
.build/ ./build
.build-windows/ ./build-windows/
.build-linux/ ./build-linux/
.build-ios/ ./build-ios/
.build-mac/ ./build-mac/
.build-android-x64/ ./build-android-x64/
.build-android-armv8/ ./build-android-armv8/
imgui.ini imgui.ini
Playground/

6
.vscode/launch.json vendored
View File

@ -8,10 +8,10 @@
"name": "(Windows) Launch", "name": "(Windows) Launch",
"type": "cppvsdbg", "type": "cppvsdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/IAE.exe", "program": "${workspaceFolder}/build/bin/Debug/RPGSample.exe",
"args": ["new", "-name", "SpaceCase"], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}/Playground", "cwd": "${workspaceFolder}/Samples/RPG",
"environment": [], "environment": [],
"console": "externalTerminal", "console": "externalTerminal",
"preLaunchTask": "CMake: build" "preLaunchTask": "CMake: build"

View File

@ -90,6 +90,7 @@
"xloctime": "cpp", "xloctime": "cpp",
"xmemory": "cpp", "xmemory": "cpp",
"xstddef": "cpp", "xstddef": "cpp",
"xtree": "cpp" "xtree": "cpp",
"expected": "cpp"
} }
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View File

@ -25,4 +25,4 @@ add_subdirectory(Vendor/)
add_subdirectory(Engine/) add_subdirectory(Engine/)
add_subdirectory(CLI/) add_subdirectory(CLI/)
add_subdirectory(Samples/)

View File

@ -6,6 +6,7 @@ set(SRC_FILES
"Src/Imp/CPP/Random.cpp" "Src/Imp/CPP/Random.cpp"
"Src/Imp/CPP/Engine.cpp" "Src/Imp/CPP/Engine.cpp"
"Src/Imp/CPP/Physics.cpp" "Src/Imp/CPP/Physics.cpp"
"Src/Imp/CPP/TileSet.cpp"
"Src/Imp/CPP/InternalEngine.cpp" "Src/Imp/CPP/InternalEngine.cpp"
"Src/Imp/CPP/FontManager.cpp" "Src/Imp/CPP/FontManager.cpp"

View File

@ -19,8 +19,6 @@
namespace ia::iae namespace ia::iae
{ {
STATIC Vector<Handle> TileTextures;
TileMapComponent::TileMapComponent(IN Node2D *node) : TextureComponent(node) TileMapComponent::TileMapComponent(IN Node2D *node) : TextureComponent(node)
{ {
} }
@ -45,30 +43,45 @@ namespace ia::iae
TextureComponent::FixedUpdate(); TextureComponent::FixedUpdate();
} }
VOID TileMapComponent::BeginGridSetup(IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX, VOID TileMapComponent::Setup(IN CONST Vector<TileEntryDesc> &tileDescs, IN INT32 tileWidth, IN INT32 tileHeight,
IN INT32 tileCountY) IN INT32 tileCountX, IN INT32 tileCountY)
{ {
Vector<Handle> textures;
m_tileWidth = tileWidth; m_tileWidth = tileWidth;
m_tileHeight = tileHeight; m_tileHeight = tileHeight;
m_tileCountX = tileCountX; m_tileCountX = tileCountX;
m_tileCountY = tileCountY; m_tileCountY = tileCountY;
TileTextures.resize(m_tileCountX * m_tileCountY);
m_tileEntries.reset();
m_tileEntries.reserve(tileDescs.size());
for (const auto &td : tileDescs)
{
if (td.TileTexture != INVALID_HANDLE)
textures.pushBack(td.TileTexture);
else
{
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 index, IN Handle texture) if (m_mapTexture != INVALID_HANDLE)
{ Engine::DestroyImage(m_mapTexture);
TileTextures[index] = texture; m_mapTexture = Engine::CombineImages(textures, m_tileWidth, m_tileHeight, m_tileCountX, m_tileCountY);
}
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);
SetTexture(m_mapTexture); SetTexture(m_mapTexture);
TileTextures.reset(); }
BOOL TileMapComponent::CanWalkX(IN Vec2 pixelPosition, IN FLOAT32 d)
{
const auto p = pixelPosition.x + d;
return GetTileEntry((INT32)(p/m_tileWidth), (INT32)(pixelPosition.y/m_tileHeight)).IsWalkable;
}
BOOL TileMapComponent::CanWalkY(IN Vec2 pixelPosition, IN FLOAT32 d)
{
const auto p = pixelPosition.y + d;
return GetTileEntry((INT32)(pixelPosition.x/m_tileWidth), (INT32)(p/m_tileHeight)).IsWalkable;
} }
} // namespace ia::iae } // namespace ia::iae

View File

@ -74,7 +74,9 @@ namespace ia::iae
Vec2 Engine::CalculatePercentPosition(IN Vec2 percent) 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) Direction Engine::GetVectorPointingDirection(IN Vec2 v)
@ -121,6 +123,12 @@ namespace ia::iae
return CreateSound(name, data.data(), data.size()); 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) Handle Engine::RescaleImage(IN CONST String &name, IN Vec2 factor)
{ {
return ResourceManager::RescaleImage(GetImage(name), 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.width, face->glyph->bitmap.rows),
IVec2(face->glyph->bitmap_left, face->glyph->bitmap_top), IVec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
static_cast<UINT32>(face->glyph->advance.x) >> 6, 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, 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) 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; STATIC Vector<UINT8> TMP_COLOR_BUFFER;
@ -87,8 +88,10 @@ namespace ia::iae
} }
if (rgbaData) if (rgbaData)
{ {
TMP_COLOR_BUFFER.reset();
TMP_COLOR_BUFFER.resize(width * height * 4); TMP_COLOR_BUFFER.resize(width * height * 4);
if (stride == width)
{
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++) for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
{ {
const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f; const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f;
@ -97,6 +100,22 @@ namespace ia::iae
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * 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]; 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, SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
.size = (UINT32) width * (UINT32) height * 4}; .size = (UINT32) width * (UINT32) height * 4};

View File

@ -30,6 +30,7 @@ namespace ia::iae
{ {
Map<String, Handle> ResourceManager::s_images; Map<String, Handle> ResourceManager::s_images;
Map<String, Handle> ResourceManager::s_sounds; Map<String, Handle> ResourceManager::s_sounds;
Map<String, RefPtr<TileSet>> ResourceManager::s_tileSets;
Vector<ResourceManager::ImageResource> ResourceManager::s_imageHandles; Vector<ResourceManager::ImageResource> ResourceManager::s_imageHandles;
VOID ResourceManager::Initialize() VOID ResourceManager::Initialize()
@ -59,11 +60,12 @@ namespace ia::iae
return result; 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 = const auto texture = GPUResourceManager::CreateTexture(
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, width, SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, width, height,
height, rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true); (stride == -1) ? width : stride, rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
s_imageHandles.pushBack(ImageResource{.OriginalWidth = width, s_imageHandles.pushBack(ImageResource{.OriginalWidth = width,
.OriginalHeight = height, .OriginalHeight = height,
.OriginalPixelData = new UINT8[width * height * 4], .OriginalPixelData = new UINT8[width * height * 4],
@ -154,8 +156,8 @@ namespace ia::iae
s_imageHandles[image].OriginalHeight, s_imageHandles[image].OriginalWidth * 4, s_imageHandles[image].OriginalHeight, s_imageHandles[image].OriginalWidth * 4,
nullptr, newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA); nullptr, newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA);
const auto texture = GPUResourceManager::CreateTexture( const auto texture = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, newWidth, newHeight, newPixelData, SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, newWidth, newHeight, newWidth,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true); newPixelData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, true);
GPUResourceManager::DestroyTexture(s_imageHandles[image].Handle); GPUResourceManager::DestroyTexture(s_imageHandles[image].Handle);
s_imageHandles[image].Handle = texture; s_imageHandles[image].Handle = texture;
s_imageHandles[image].Width = newWidth; s_imageHandles[image].Width = newWidth;
@ -198,6 +200,44 @@ namespace ia::iae
for (auto &t : s_images) for (auto &t : s_images)
t->Value = RescaleImage(t->Value, factor); 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
namespace ia::iae namespace ia::iae
@ -262,4 +302,25 @@ namespace ia::iae
{ {
return ResourceManager::CombineImages(images, unitWidth, unitHeight, unitCountX, unitCountY); 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 } // 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_LinearClamp();
STATIC SDL_GPUSampler *GetSampler_LinearRepeat(); 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 SDL_GPUBuffer *CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data, IN UINT32 dataSize);
STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle); STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle);
STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle); STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle);

View File

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

View File

@ -17,14 +17,32 @@
#pragma once #pragma once
#include <IAEngine/Components/TextureComponent.hpp> #include <IAEngine/Components/TextureComponent.hpp>
#include <IAEngine/TileSet.hpp>
namespace ia::iae namespace ia::iae
{ {
class TileMapComponent : public TextureComponent class TileMapComponent : public TextureComponent
{ {
public:
struct TileEntry
{
BOOL IsWalkable{};
};
struct TileEntryDesc
{
BOOL IsWalkable{};
INT32 TileIndex{};
String TileSetName{};
Handle TileTexture{INVALID_HANDLE};
};
public: public:
TileMapComponent(IN Node2D *node); TileMapComponent(IN Node2D *node);
BOOL CanWalkX(IN Vec2 pixelPosition, IN FLOAT32 d);
BOOL CanWalkY(IN Vec2 pixelPosition, IN FLOAT32 d);
public: public:
VIRTUAL VOID Draw(); VIRTUAL VOID Draw();
VIRTUAL VOID DebugDraw(); VIRTUAL VOID DebugDraw();
@ -33,10 +51,48 @@ namespace ia::iae
VIRTUAL VOID FixedUpdate(); VIRTUAL VOID FixedUpdate();
public: public:
VOID BeginGridSetup(IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX, IN INT32 tileCountY); VOID Setup(IN CONST Vector<TileEntryDesc>& tileDescs,
VOID SetupGridTile(IN INT32 index, IN Handle texture); IN INT32 tileWidth, IN INT32 tileHeight, IN INT32 tileCountX, IN INT32 tileCountY);
VOID SetupGridTile(IN INT32 x, IN INT32 y, IN Handle texture);
VOID EndGridSetup(); 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: private:
INT32 m_tileWidth{}; INT32 m_tileWidth{};
@ -44,5 +100,6 @@ namespace ia::iae
INT32 m_tileCountX{}; INT32 m_tileCountX{};
INT32 m_tileCountY{}; INT32 m_tileCountY{};
Handle m_mapTexture{INVALID_HANDLE}; Handle m_mapTexture{INVALID_HANDLE};
Vector<TileEntry> m_tileEntries;
}; };
} // namespace ia::iae } // namespace ia::iae

View File

@ -24,9 +24,9 @@
#include <IAEngine/Components/CameraComponent.hpp> #include <IAEngine/Components/CameraComponent.hpp>
#include <IAEngine/Components/SoundEmitterComponent.hpp> #include <IAEngine/Components/SoundEmitterComponent.hpp>
#include <IAEngine/SceneManager.hpp>
#include <IAEngine/UI.hpp> #include <IAEngine/UI.hpp>
#include <IAEngine/Utils.hpp> #include <IAEngine/Utils.hpp>
#include <IAEngine/SceneManager.hpp>
namespace ia::iae namespace ia::iae
{ {
@ -50,10 +50,14 @@ namespace ia::iae
STATIC IVec2 GetDisplayExtent(); STATIC IVec2 GetDisplayExtent();
STATIC FLOAT32 GetDisplayAspectRatio(); STATIC FLOAT32 GetDisplayAspectRatio();
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight); 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 DrawGeometry(IN Handle geometry, IN Handle texture, IN Vec2 position, IN Vec2 scale,
STATIC VOID DrawQuad(IN Vec2 position, IN Handle texture, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex); 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 DrawQuad(IN Vec2 position, IN Handle texture, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer,
STATIC VOID DrawText(IN CONST String& text, IN Vec2 position, IN FLOAT32 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex); 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 Vec2 GetSceneDesignViewport();
STATIC VOID SetSceneDesignViewport(IN Vec2 value); STATIC VOID SetSceneDesignViewport(IN Vec2 value);
@ -92,6 +96,13 @@ namespace ia::iae
STATIC VOID RescaleAllImages(IN Vec2 factor); STATIC VOID RescaleAllImages(IN Vec2 factor);
STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight, STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY); 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 // Game Functions
STATIC VOID SetTimeScale(IN FLOAT32 scale); STATIC VOID SetTimeScale(IN FLOAT32 scale);

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

View File

@ -1,2 +1,3 @@
add_subdirectory(SpaceInvaders/) #add_subdirectory(SpaceCase/)
add_subdirectory(RPG/)

View File

@ -0,0 +1,11 @@
set(SRC_FILES
"Src/imp/cpp/Game.cpp"
)
add_executable(RPGSample ${SRC_FILES})
target_compile_definitions(RPGSample PRIVATE "__BUILDING_IAENGINE_GAME=1")
target_include_directories(RPGSample PRIVATE "Src/imp/hpp")
target_link_libraries(RPGSample PUBLIC IAEngine)

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

View File

@ -0,0 +1,3 @@
This asset pack is taken from here https://kenmi-art.itch.io/cute-fantasy-rpg
This is the free version

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,10 @@
Hello! Thank you for downloading the Cute Fantasy asset pack.
This project will be getting updates over time. This version of the asset pack is not final and there will be few more additional sprites.
License - Free Version
- You can use these assets in non-commercial projects.
- You can modify the assets.
- You can not redistribute or resale, even if modified
If you like the asset pack leave a comment. It helps to support the asset pack and get more people to see it. Thanks!

View File

@ -0,0 +1,134 @@
// 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 <Game.hpp>
namespace ia::iae::rpg
{
RefPtr<TileMapNode> g_map;
}
namespace ia::iae::rpg
{
GameRequestedConfig *RequestEngineConfig()
{
STATIC GameRequestedConfig EngineConfig{
.DesignWidth = 800,
.DesignHeight = 600,
.WindowWidth = 800,
.WindowHeight = 600,
};
return &EngineConfig;
}
VOID OnInitialize()
{
Engine::Input_SetupOnScreenGamePad();
Engine::SetRenderState_YSortingEnabled(true);
Engine::Input_SetupKeyboardGamePad(InputKey::K_LEFT, InputKey::K_RIGHT, InputKey::K_DOWN, InputKey::K_UP,
InputKey::A, InputKey::B, InputKey::C, InputKey::D);
Engine::CreateTileSetFromFile("TSet1", "Resources/Sprites/Cute_Fantasy_Free/Tiles/Beach_Tile.png", 16, 16);
g_map = MakeRefPtr<TileMapNode>("Map");
g_map->GetTileMapComponent()->Setup({
TileMapComponent::TileEntryDesc{
.IsWalkable = true,
.TileIndex = 0,
.TileSetName = "TSet1",
},
TileMapComponent::TileEntryDesc{
.IsWalkable = true,
.TileIndex = 1,
.TileSetName = "TSet1",
},
TileMapComponent::TileEntryDesc{
.IsWalkable = true,
.TileIndex = 2,
.TileSetName = "TSet1",
},
TileMapComponent::TileEntryDesc{
.IsWalkable = true,
.TileIndex = 3,
.TileSetName = "TSet1",
}
}, 16, 16, 4, 1);
auto mainCamera = MakeRefPtr<CameraNode>(Engine::GetUniqueResourceName());
Engine::SetActiveCamera(mainCamera->GetCameraComponent());
Engine::GetActiveScene()->AddNode(mainCamera);
Engine::GetActiveScene()->AddNode(g_map);
}
VOID OnTerminate()
{
}
VOID OnDebugDraw()
{
}
VOID OnFixedUpdate()
{
}
VOID OnUpdate(IN FLOAT32 deltaTime)
{
}
VOID OnResize(IN INT32 newWidth, IN INT32 newHeight)
{
}
} // namespace ia::iae::rpg
C_DECL(GameRequestedConfig *Game_GetConfigRequest())
{
return rpg::RequestEngineConfig();
}
C_DECL(VOID Game_OnInitialize())
{
rpg::OnInitialize();
}
C_DECL(VOID Game_OnTerminate())
{
rpg::OnTerminate();
}
C_DECL(VOID Game_OnDebugDraw())
{
rpg::OnDebugDraw();
}
C_DECL(VOID Game_OnFixedUpdate())
{
rpg::OnFixedUpdate();
}
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime))
{
rpg::OnUpdate(deltaTime);
}
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight))
{
rpg::OnResize(newWidth, newHeight);
}
IAENGINE_RUN("RPG Sample", "com.iasoft.iae.rpgsample", "IASoft (PVT) LTD", "IASoft (PVT) LTD", 1, 0, 0);

View File

@ -0,0 +1,27 @@
// 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/Engine.hpp>
using namespace ia;
using namespace iae;
namespace ia::iae::rpg
{
}

View File

@ -0,0 +1,32 @@
// 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 <Base.hpp>
#include <IAEngine/EngineLibraryInterface.hpp>
namespace ia::iae::rpg
{
GameRequestedConfig* RequestEngineConfig();
VOID OnInitialize();
VOID OnTerminate();
VOID OnDebugDraw();
VOID OnFixedUpdate();
VOID OnUpdate(IN FLOAT32 deltaTime);
VOID OnResize(IN INT32 newWidth, IN INT32 newHeight);
}

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

2
Vendor/IACore vendored