Introduction
Welcome to the documentation for the SUNENGINE application. This engine is designed to provide a comprehensive framework for game development, offering a wide range of features to facilitate the creation and management of GameObjects, scenes, and input handling. The engine is built with a modular design, allowing for easy extension and customization to suit various game development needs.
Features
- Game Loop: Provides a game loop for managing the flow of the game, including initialization, updating, drawing, and ending scenes.
- AZUL Graphics: Utilizes the AZUL graphics library for rendering 2D/3D models, textures, and shaders.
- Asset Management: Manages the loading and unloading of game assets, including textures, models, and fonts.
- Scene Management: Efficiently handles the initialization, updating, drawing, and unloading of scenes.
- GameObject Management: Provides a base class for game entities, allowing for easy registration and management of GameObjects.
- Input Handling: Manages keyboard and mouse input events, providing a robust system for user interaction.
- Collision Detection: Manages the registration and processing of collisions between GameObjects.
- Drawable and Updatable Management: Handles objects that need to be drawn or updated in the game loop.
- Sprites and SpriteFonts: Provides classes for managing 2D sprites and sprite fonts for rendering text.
- Alarm System: Allows for timed events and actions within the game loop.
- Camera Management: Manages the camera view for rendering scenes.
- Memory Tracking: Dynamic memory leak tracking to ensure efficient memory usage.
Installation
Step 1: Setting Up the Project
- Add "Framework.h" as a forced include file in your project settings.
- Define the following preprocessor definitions:
WINDOWS_TARGET_PLATFORM="$(TargetPlatformVersion)"
MEMORY_LOGS_DIR=R"($(SolutionDir))"
Step 2: Building the Engine
- Include the necessary headers in your source files.
- Link against the required libraries.
- Build the project using Visual Studio 2022.
Usage
Initialization
The engine is initialized and run through the WinMain
function:
int WINAPI
WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_
int)
{
SUNENGINEAttorney::InitDestroy::Destroy();
return 0;
}
static void Run()
Initializes the SUNENGINE instance.
Definition SUNENGINEAttorney.h:48
int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
Entry point for the application.
Definition main.cpp:19
LoadResources and Asset Management
The engine provides classes for managing the loading and unloading of game assets, including textures, models, and fonts.
static void Load(MapKey key, Texture *tex)
Loads an Image object from a Texture.
Definition ImageManager.h:70
static Model * Get(const std::string &key)
Retrieves a Model object by its key (private implementation).
Definition ModelManager.h:68
static void Load(const std::string &key, const Model::PreMadeModels model)
Loads a pre-made Model object (private implementation).
Definition ModelManager.h:76
static void SetNextScene(Scene *scene)
Sets the next scene to transition to.
Definition SceneManager.cpp:36
static void Load(const std::string &key, const std::string &path)
Loads a ShaderObject object from a file path.
Definition ShaderManager.h:80
Represents a font in the SUNENGINE.
Definition SpriteFont.h:19
static void Load(MapKey key, std::string path)
Loads a SpriteFont from a file.
Definition SpriteFontManager.h:40
static SpriteFont * Get(MapKey key)
Retrieves a SpriteFont by key.
Definition SpriteFontManager.h:33
static Texture * Get(const std::string &key)
Retrieves a Texture object by its key.
Definition TextureManager.h:63
static void Load(const std::string &key, const std::string &path)
Loads a Texture object from a file path.
Definition TextureManager.h:71
Scene Management
Scenes are managed by the Scene
class, which provides methods for initialization, updating, drawing, and ending the scene. GameObjects can be registered for updates, drawing, alarms, input, and collisions.
class MyScene :
public Scene
{
public:
{
}
{
}
};
Represents a scene in the engine.
Definition Scene.h:32
virtual void SceneEnd()=0
Ends the scene. Defined by the user.
virtual void Initialize()=0
Initializes the scene. Defined by the user.
static void SetCurrentScene(Scene *scene)
Sets the current scene.
Definition SceneManager.h:93
GameObject Management
GameObjects are the primary class for game entities that use the following components. They can be registered for updates, drawing, alarms, input, and collisions. The GameObject
class provides a base implementation for game entities.
{
public:
{
}
{
}
{
}
{
}
{
}
{
}
{
}
void KeyHeld(AZUL_KEY key)
override
{
}
{
}
{
}
void Collision(GameObject* other) override
{
}
};
void SubmitAlarmDeregistration(AlarmableManager::ALARM_ID id)
Submits the alarm deregistration for the GameObject.
Definition Alarmable.cpp:33
virtual void Alarm0()
Virtual method to be implemented by derived classes for alarm 0 when triggered.
Definition Alarmable.h:68
void SubmitAlarmRegistration(AlarmableManager::ALARM_ID id, float t)
Submits the alarm registration for the GameObject.
Definition Alarmable.cpp:25
void SubmitCollisionRegistration()
Submits the collision registration for the GameObject.
Definition Collidable.cpp:38
void SubmitCollisionDeregistration()
Submits the collision deregistration for the GameObject.
Definition Collidable.cpp:45
void SubmitDrawDeregistration()
Submits the draw deregistration for the GameObject.
Definition Drawable.cpp:27
void SubmitDrawRegistration()
Submits the draw registration for the GameObject.
Definition Drawable.cpp:20
virtual void Draw2D()
Virtual method to be implemented by derived classes for 2D draw functionality.
Definition Drawable.h:67
virtual void Draw()
Virtual method to be implemented by derived classes for draw functionality.
Definition Drawable.h:62
Base class for all GameObjects in the engine.
Definition GameObject.h:21
virtual void SceneExit()
Called when the GameObject exits the scene; used for registration management, called by user.
Definition GameObject.h:81
virtual void SceneEntry()=0
Called when the GameObject enters the scene; used for registration management, called by system on en...
void SubmitUpdateDeregistration()
Submits the update deregistration for the GameObject.
Definition Updatable.cpp:27
void SubmitUpdateRegistration()
Submits the update registration for the GameObject.
Definition Updatable.cpp:18
virtual void Update()
Virtual method to be implemented by derived classes for update functionality.
Definition Updatable.h:62
Input Handling
The Inputable
class provides a base implementation for handling keyboard input events. It manages registration and deregistration with the KeyboardEventManager
.
{
public:
{
}
{
}
void KeyHeld(AZUL_KEY key)
override
{
}
{
}
};
SubmitKeyRegistration(AZUL_KEY::KEY_A, EventType::KEY_HELD);
Collision Detection
The Collidable
class provides a base implementation for objects that need to participate in collision detection. It manages registration and deregistration with the CollisionManager
.
{
public:
{
}
};
SetCollisionSelf<AdvancedFrigate>();
SetCollisionSelf<Cottage>();
SetCollisionPair<AdvancedFrigate, Cottage>();
SetColliderModel(pGObj->getModel());
SetCollidableGroup<AdvancedFrigate>();
SubmitCollisionRegistration();
this->UpdateCollisionData(world);
Drawable Management
The Drawable
class provides a base implementation for objects that need to be drawn during the game loop. It manages registration and deregistration with the DrawableManager
.
{
public:
{
}
{
}
};
SubmitDrawRegistration();
Updatable Management
The Updatable
class provides a base implementation for objects that need to be updated during the game loop. It manages registration and deregistration with the UpdatableManager
.
{
public:
{
}
};
SubmitUpdateRegistration();
Sprites and SpriteFonts
The engine provides classes for managing 2D sprites and sprite fonts for rendering text.
Represents a sprite in the SUNENGINE.
Definition Sprites/SUNENGINESprite.h:16
void SetScaleFactor(float x, float y)
Sets the scale factor of the sprite.
Definition Sprites/SUNENGINESprite.cpp:50
void SetPosition(float x, float y)
Sets the position of the sprite.
Definition Sprites/SUNENGINESprite.cpp:34
Represents a string of sprites in the SUNENGINE.
Definition SpriteString.h:18
Alarm System
The engine provides an alarm system that allows for timed events and actions within the game loop.
{
public:
{
}
};
SubmitAlarmRegistration(AlarmableManager::ALARM_ID::ALARM_0, 5.0f);
Camera Management
The engine provides classes for managing the camera view for rendering scenes.
Camera* myCamera = new Camera(Camera::Type::PERSPECTIVE_3D);
myCamera->setOrientAndPosition(Vect(0.0f, 1.0f, 0.0f), Vect(0.0f, 0.0f, -1.0f), Vect(0.0f, 0.0f, 5.0f));