Programming Manual
How your game application works with HyEngine. All new projects are generated with this basic structure.
classDiagram
HyEngine <|-- YourGame
class HyEngine{
-HyInit initStruct
...
+HyEngine(HyInit)
~HyEngine()
+RunGame() int32
#virtual OnUpdate() bool
}
class YourGame{
-HyCamera2d * pCamera
-MainMenu mainMenu
-ILevel * pCurrentLevel
-LevelOne LevelOne
...
+YourGame(HyInit)
~YourGame()
#override OnUpdate() bool
}
main.cpp
-
Initializes a
HyInitstructure -
Instantiate
YourGameclass, which derives fromHyEngine -
Invoke
YourGame::RunGame()to start the main game loop
Use YourGame class constructor to initialize your game.
Override OnUpdate() to implement your game's main logic, such as updating the current level or handling menu navigation. OnUpdate() is invoked within Harmony's main game loop whenever a frame of game logic needs to happen.
Simple programs might only need to declare a few scene nodes and can implement all logic directly in OnUpdate(). More complex games will likely want to create separate classes to encapsulate different game states or levels.
Most code objects derive from HyEntity2d
The member variables declared in your main game class can encapsulate the flow or main aspects of the program. These are usually custom classes derived from HyEntity2d. (1)
HyEntity2dis a special scene node that can contain other scene nodes like sprites, text, and audio. It also serves as a way to logically group and update objects within the game world.
classDiagram HyEntity2d <|-- MainMenu HyEntity2d <|-- ILevel ILevel <|-- LevelOne class HyEntity2d{ +HyEntity2d() ~HyEntity2d() #virtual OnUpdate() void } class MainMenu{ -HySprite2d background -HyText2d menuText ... +MainMenu() ~MainMenu() #override OnUpdate() void } class ILevel{ -MainCharacter * pMainCharacter -LevelStuff levelStuff ... +ILevel() ~ILevel() #override OnUpdate() void }
Engine Utilities
The HyEngine class (1) provides public static methods to easily access engine functionality and information.
HyEnginepublic static methods:class HyEngine { static HyEngine * sm_pInstance; ... public: HyEngine(const HyInit &initStruct); ~HyEngine(); ... static bool IsInitialized(); static const HyInit &InitValues(); static std::string DateTime(); static uint32 NumWindows(); static HyWindow &Window(uint32 uiWindowIndex = 0); static float DeltaTime(); static double DeltaTimeD(); static void LoadingStatus(uint32 &uiNumQueuedOut, uint32 &uiTotalOut); static void PauseGame(bool bPause); static HyInput &Input(); static HyAudioCore &Audio(); static HyDiagnostics &Diagnostics(); static HyShaderHandle DefaultShaderHandle(HyType eType); static std::string DataDir(); static HyTextureQuadHandle CreateTexture(std::string sFilePath, HyTextureInfo textureInfo); static HyAudioHandle CreateAudio(std::string sFilePath, bool bIsStreaming = false, int32 iInstanceLimit = 0, int32 iCategoryId = 0); };
-
ㅤCameras & Windows
How to manage your camera viewports and render windows. -
ㅤScene Management -> Item Nodes | Entities & Physics | User Interface
The building blocks to make the game. -
ㅤInput Handling
Utilize Input Maps and get player input from various devices. -
ㅤAudio System
Manage howHyAudio2daudio cues are played back, categories, and settings. -
ㅤDiagnostics & Debugging
Logging, performance profiling, and on-screen diagnostic overlays. -
ㅤShaders
Override built-in shaders on scene nodes to create impressive effects.pShader = HY_NEW HyShader(HYSHADERPROG_Primitive); pShader->SetSourceCode(szVERTEXSHADER_SRC, HYSHADER_Vertex); pShader->AddVertexAttribute("attrPos", HyShaderVariable::vec2); pShader->AddVertexAttribute("attrUV", HyShaderVariable::vec2); pShader->SetSourceCode(szFRAGMENTSHADER_SRC, HYSHADER_Fragment); pShader->Finalize(); ... m_PrimitiveBox.SetShader(pShader); -
ㅤDirect Asset Loading
Load raw images and audio files off disk using scene nodes.