Fox,Вот этот код инициализации нашего движка(AFTER DIE GAMES)
MagicWolf,Он даже тебе непокажется простым.
Код:
#include "CF_Includes.h"
#define CREATERECT( rc, x, y, w, h )RECT rc; {rc.left = x;rc.top = x;rc.right = x + w;rc.bottom = x + w; }
CCF_Engine::CCF_Engine(HINSTANCE instance)
{
this->m_instance = instance;
this->m_window = new CCF_Window( instance );
this->m_input = new CCF_Input( instance );
this->m_camera = new CCF_Camera();
this->m_drawRenderer = new CCF_DrawRenderer();
this->m_soundRenderer = new CCF_SoundRenderer();
//this->CCF_Sound* Fmod = new CCF_Sound;
}
CCF_Engine::~CCF_Engine(void)
{
}
void CCF_Engine::Run()
{
this->m_window->Initialize();
this->m_window->Show();
this->m_input->Initialize(m_window->GetHandle());
this->m_drawRenderer->Initialize(m_window->GetHandle());
this->m_soundRenderer->Initialize(m_window->GetHandle());
this->m_input->GetMouseState();
CCF_Sound* sound = new CCF_Sound;
CCF_Particles* par = new CCF_Particles();
CCF_AnimMesh* mesh = new CCF_AnimMesh();
CCF_SkyBox* skyBox = new CCF_SkyBox();
LPWSTR files[] = {
L"sky\\Left.bmp",
L"sky\\Right.bmp",
L"sky\\Top.bmp",
L"sky\\Bottom.bmp",
L"sky\\Front.bmp",
L"sky\\Back.bmp",
};
BOOL res = skyBox->Initialize( m_drawRenderer->GetDivece(), files, 100.0f );
mesh->Initialize( m_drawRenderer->GetDivece(), L"tiny.x" );
par->Initialize( m_drawRenderer->GetDivece(), L"2.bmp" );
/*sound->MusicLoad("sounds/demo.mod");
sound->MusicPlay();*/
sound->SoundLoad("sounds/Atack.mp3");
sound->SoundPlay();
while( !m_window->IsDestroy() )
{
this->m_input->Update();
this->m_drawRenderer->Begin();
this->m_drawRenderer->SetCamera( m_camera );
//m_camera->TurnLeft( m_input->GetMouseState().lX/10 );
this->m_camera->TurnRight( m_input->GetMouseState()->lX/50.0 );
this->m_camera->TiltFront( m_input->GetMouseState()->lY/50.0 );
skyBox->Render( m_camera );
mesh->Update();
mesh->Draw();
par->Update( 0.5 );
par->Render();
if( m_input->IsKeyDown( DIK_W ))
{
// m_camera->GoBack( 1 );
m_camera->GoFront( 1.0 );
}
if( m_input->IsKeyDown( DIK_S ))
{
m_camera->GoFront( -1.0 );
}
if( m_input->IsKeyDown( DIK_A ))
{
//m_camera->TurnLeft( 0.1 );
m_camera->GoLeft( 1.0 );
}
if( m_input->IsKeyDown( DIK_D ))
{
// m_camera->TurnRight( 0.1 );
m_camera->GoRight( 1.0 );
}
CREATERECT( rc1, 0, 0, 100, 100 )
CREATERECT( rc2, 100, 0, 100, 100 )
this->m_drawRenderer->GetFont()->Draw( rc1, D3DCOLOR_ARGB( 255,255, 0, 0 ), L"sadasd" );
this->m_drawRenderer->GetFont()->Draw( rc2, D3DCOLOR_ARGB( 255,0, 255, 0 ), L"sadasd" );
this->m_drawRenderer->End();
}
}
