Files
IAEngine/Samples/SpaceInvaders/Src/Imp/CPP/Game.cpp
Isuru Samarathunga 1f9d5426b8 Engine API Enhancements
2025-10-08 00:45:02 +05:30

86 lines
2.5 KiB
C++

// 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>
RefPtr<Node2D> backgroundNode;
RefPtr<CameraNode> mainCamera;
C_DECL(IA_DLL_EXPORT VOID Game_OnInitialize())
{
Engine::ResizeDisplay(600, 600);
const auto displayExtent = Engine::GetDisplayExtent();
Engine::CreateImageFromFile("Background", "Resources/Sprites/bg.png", displayExtent.x, displayExtent.y);
Engine::CreateImageFromFile("Stars-A", "Resources/Sprites/Stars-A.png", displayExtent.x, displayExtent.y);
Engine::CreateImageFromFile("Stars-B", "Resources/Sprites/Stars-B.png", displayExtent.x, displayExtent.y);
mainCamera = MakeRefPtr<CameraNode>("MainCamera");
Engine::SetActiveCamera(mainCamera->GetCameraComponent());
backgroundNode = MakeRefPtr<Node2D>("BG");
backgroundNode->AddComponent<TextureComponent>()->SetTexture(Engine::GetImage("Stars-A"));
//backgroundNode->AddComponent<TextureComponent>()->SetTexture(g_spriteBGStarsA);
//backgroundNode->GetTextureComponent()->SetTexture(g_spriteBG);
Engine::AddNodeToActiveScene(backgroundNode);
}
C_DECL(IA_DLL_EXPORT VOID Game_OnTerminate())
{
}
C_DECL(IA_DLL_EXPORT VOID Game_OnDebugDraw())
{
}
C_DECL(IA_DLL_EXPORT VOID Game_OnFixedUpdate())
{
}
C_DECL(IA_DLL_EXPORT VOID Game_OnUpdate(IN FLOAT32 deltaTime))
{
}
C_DECL(IA_DLL_EXPORT VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight))
{
}
C_DECL(IA_DLL_EXPORT PCCHAR Game_GetName())
{
return "Space Invaders";
}
C_DECL(IA_DLL_EXPORT UINT64 Game_GetVersion())
{
return IA_MAKE_VERSION(1, 0, 0);
}
C_DECL(IA_DLL_EXPORT PCCHAR Game_GetPackageName())
{
return "com.iasoft.iaenginesamples.spaceinvaders";
}
C_DECL(IA_DLL_EXPORT PCCHAR Game_GetDeveloperName())
{
return "IASoft (PVT) LTD";
}
C_DECL(IA_DLL_EXPORT PCCHAR Game_GetPublisherName())
{
return "IASoft (PVT) LTD";
}