#1. Engine System
+ WinMain - EngineSystem
+ EngineCore
+ EngineError
+ MainNode (현재 글)
#2. FrameWork
+ Grahpics
+ Image - SpriteData
+ Layer
+ Input
+ Game
+ Manager
+ Game Interface
+ Utility
#3. Testing Module
+ 2D Image Test
+ 2D Animation Test
+ Game UI Test
-----------------------------------------------------------------------
이번 글에서는 각 매니저나 게임 구동에 필요한 것들이 동작 될, 루트라 볼 수 있는
MainNode에 대해서 설명하겠습니다.
MainNode Class는 EngineSystem Class와 Game Class 에서의 중간다리 역할이라 할 수 있습니다.
헤더를 먼저 살펴보겠습니다.
#ifndef _MAINNODE_H // Prevent multiple definitions if this | |
#define _MAINNODE_H // file is included in more than one place | |
class MainNode; | |
namespace mainNodeNS | |
{ | |
//const float maxFrameLimit = 60.0f; //Not Using This Code | |
} | |
class MainNode | |
{ | |
private: | |
bool initializedMgr = false; | |
public: | |
MainNode(); | |
~MainNode(); | |
HRESULT initialize(); | |
void release(); | |
void update(); | |
void render(); | |
LRESULT messageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); | |
}; | |
#endif |
헤더에서는 주요하게 볼 부분은 MainNode의 함수 구성이
initialize()
release()
update()
render()
로 나뉘어져 있다는 사실 입니다.
그리고 Engine의 프로시져로 받아오는 내용을 처리할 핸들러가 있습니다.
이어서 .cpp 를 보겠습니다.
cpp 는 헤더에 선언해두었던 각각의 함수 수행부가 구현되어 있습니다.
#include "stdafx.h" | |
#include "mainNode.h" | |
#include "scene_Main.h" | |
#include "scene_Test.h" | |
#include "scene_Maptool.h" | |
MainNode::MainNode() : initializedMgr(FALSE) | |
{ | |
} | |
MainNode::~MainNode() | |
{ | |
} | |
HRESULT MainNode::initialize() | |
{ | |
//Need Not Hwnd Managers initialize | |
//FILEMANAGER->initialize(); | |
//TIMEMANAGER->initialize(); | |
LAYERMANAGER->initialize(); | |
//Need Hwnd Managers initialize | |
IMAGEMANAGER->initialize(g_Graphics); | |
// Create the game, sets up message handler | |
//game = new scene_Main; | |
SCENEMANAGER->addScene("Main", new Scene_Main); | |
SCENEMANAGER->addScene("Test", new Scene_Test); | |
SCENEMANAGER->addScene("Maptool", new Scene_Maptool); | |
SCENEMANAGER->initialize(); | |
return S_OK; | |
} | |
void MainNode::release() | |
{ | |
SCENEMANAGER->release(); | |
//TIMEMANAGER->release(); | |
IMAGEMANAGER->release(); | |
FILEMANAGER->release(); | |
LAYERMANAGER->release(); | |
} | |
void MainNode::update() | |
{ | |
//TIMEMANAGER->UpdateTime(mainNodeNS::maxFrameLimit); | |
SCENEMANAGER->update(); | |
} | |
void MainNode::render() | |
{ | |
SCENEMANAGER->render(); | |
} | |
LRESULT MainNode::messageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
{ | |
if (SCENEMANAGER->getCurrentScene() == NULL) | |
{ | |
return DefWindowProc(hwnd, msg, wParam, lParam); | |
} | |
return SCENEMANAGER->getCurrentScene()->messageHandler(hwnd, msg, wParam, lParam); //SceneManager Proc | |
} |
먼저 intiailize()에서는 게임에서 사용 하는 각각의 Manager들을 초기화 합니다.
코드상에 TIMEMANAGER와 FILEMANAGER가 주석처리 된 이유는
현재 사용하지 않기 때문이고, FILEMANAGER의 경우 EngineStart( ) 구역으로 빠져있습니다.
release() 는 매니저들에 대한 내용을 해지하는 것을 수행합니다.
두 번째로 update() 에서 SceneManager를 업데이트하여 현재 게임의 내용을 업데이트합니다.
이것이 수행되고 나면 SceneManager -> render()를 수행하여
그리기 작업을 수행하게 됩니다.
마지막에 있는 MessageHandler는 EngineRun()에서 전달되는 프로시져에서의 메세지 처리 핸들러 입니다.
키 입력에 대한 처리를 여기서 위와 같이 하게 됩니다.
'MyProject > SephyEngine' 카테고리의 다른 글
June_Engine #2_Graphics.cpp (1) (0) | 2017.04.15 |
---|---|
June_Engine #2_Graphics.h (0) | 2017.04.07 |
June_Engine #1_EngineError.h (0) | 2017.04.07 |
June_Engine #1_EngineCore.cpp (2) (0) | 2017.04.07 |
June_Engine #1_EngineCore.h (1) (0) | 2017.04.06 |