本文整理汇总了C++中CIndieLib::End方法的典型用法代码示例。如果您正苦于以下问题:C++ CIndieLib::End方法的具体用法?C++ CIndieLib::End怎么用?C++ CIndieLib::End使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIndieLib
的用法示例。
在下文中一共展示了CIndieLib::End方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IndieLib
int IndieLib() {
//-------------------Constants------------------
enum emode {menu, create, config};
const char FPS = 60;
const float dcam = 0.05f;
const char prompt[] = ">\t";
//----------------Logic variables---------------
bool show_b_areas = true;
emode mode = create;
emode prev_mode = create;
float dm = 0;
//--------------------Engine--------------------
CIndieLib *prog = CIndieLib::Instance();
if (!prog->Init()) return 1;
prog->Window->SetTitle("Level Editor 1.1-alpha");
//prog->Window->Cursor(true);
// Render timer
IND_Timer render_timer;
int ticks = 0;
int last_frame = 0;
render_timer.Start();
// Camera
float cam_x = (float) prog->Window->GetWidth() / 2;
float cam_y = (float) prog->Window->GetHeight() / 2;
IND_Camera2d cam((int) cam_x, (int) cam_y);
IND_Camera2d bcam((int) cam_x, (int) cam_y);
//-------------------Resources------------------
IND_Font t_font;
IND_Entity2d menu_e;
try {
if (!prog->FontManager->Add(&t_font, "..\\res\\font_small.png", "..\\res\\font_small.xml", IND_ALPHA, IND_32))
throw res_error();
if (!prog->Entity2dManager->Add(4, &menu_e)) throw res_error();
}
catch (res_error) {
prog->End();
return 2;
}
//-----------Menu and additional info-----------
cmd_line cmd_menu;
char cmd_str[520];
char buf[10];
strcpy(cmd_str, prompt);
menu_e.SetFont(&t_font);
menu_e.SetAlign(IND_LEFT);
menu_e.SetCharSpacing(-8);
menu_e.SetLineSpacing(18);
menu_e.SetText(cmd_str);
menu_e.SetPosition(5, (float) (prog->Window->GetHeight() - 25), 0);
menu_e.SetShow(false);
// Information
info tile_info;
prog->Entity2dManager->Add(4, &tile_info.get_entity());
tile_info.set_font(t_font);
info lvl_info;
bool update_info = true;
prog->Entity2dManager->Add(4, &lvl_info.get_entity());
lvl_info.set_font(t_font);
lvl_info.set_position(prog->Render->GetViewPortX() + 5, prog->Render->GetViewPortY() + 5, 0);
lvl_info.add_text(unnamed_lt_file);
//------------------Tiles manager---------------
lt_manager ltm;
try {
if (!ltm.load_textures("..\\textures")) throw tm_init_fail();
}
catch (tm_init_fail) {
prog->End();
return 3;
}
//-------------Cofiguration manager-------------
//.........这里部分代码省略.........
示例2: IndieLib
//.........这里部分代码省略.........
mLight1.SetColor (1.0f, 1.0f, 1.0f, 1.0f);
mLight1.SetDirection (0.0f, -0.3f, 0.5f);
mLight1.SetRange (1000.0f);
// Light 2 (Point light)
IND_Light mLight2;
mI->LightManager->Add (&mLight2, IND_POINT_LIGHT);
mLight2.SetPosition (3, 3, 3);
mLight2.SetColor (0.4f, 1.0f, 0.4f, 1.0f);
mLight2.SetRange (200);
mLight2.SetAttenuation (0.5f);
// Light 3 (Spot light)
IND_Light mLight3;
mI->LightManager->Add (&mLight3, IND_SPOT_LIGHT);
mLight3.SetPosition (5, 5, 5);
mLight3.SetColor (1.0f, 1.0f, 1.0f, 1.0f);
mLight3.SetDirection (0.0f, -0.3f, 0.5f);
mLight3.SetRange (1000);
mLight3.SetAttenuation (0.2f);
mLight3.SetFalloff (1.0f);
mLight3.SetPhi (8.0f);
mLight3.SetTheta (7);
// ----- Main Loop -----
mI->LightManager->Disable(&mLight2);
mI->LightManager->Disable(&mLight3);
float mAngle = 0;
char mText [2048]; mText [0] = 0;
int mSpeed = 25;
float mDelta;
while (!mI->Input->OnKeyPress (IND_ESCAPE) && !mI->Input->Quit())
{
// ----- Input update ----
mI->Input->Update ();
// ----- Text -----
strcpy (mText, "Press 1, 2 or 3 in order to toggle between different lights\n");
mTextSmallWhite.SetText (mText);
// ----- Input -----
mDelta = mI->Render->GetFrameTime() / 1000.0f;
// Activate only light 1
if (mI->Input->IsKeyPressed (IND_1))
{
mI->LightManager->Disable(&mLight2);
mI->LightManager->Disable(&mLight3);
mI->LightManager->Enable(&mLight1);
}
// Activate only light 2
if (mI->Input->IsKeyPressed (IND_2))
{
mI->LightManager->Disable(&mLight1);
mI->LightManager->Disable(&mLight3);
mI->LightManager->Enable(&mLight2);
}
// Activate only light 3
if (mI->Input->IsKeyPressed (IND_3))
{
mI->LightManager->Disable(&mLight1);
mI->LightManager->Disable(&mLight2);
mI->LightManager->Enable(&mLight3);
}
// ----- Updating entities attributes -----
mAngle += mDelta * mSpeed;
mDino.SetAngleXYZ (0, mAngle, 0);
// ----- Render -----
mI->Render->ClearViewPort (60, 60, 60);
mI->Render->BeginScene ();
mI->Render->SetViewPort3d (0, 0, mI->Window->GetWidth (), mI->Window->GetHeight());
mI->Render->SetCamera3d (&mCamera3d);
mI->LightManager->Update ();
mI->Entity3dManager->RenderEntities3d ();
mI->Render->SetViewPort2d (0, 0, mI->Window->GetWidth (), mI->Window->GetHeight ());
mI->Render->SetCamera2d (&mCamera2d);
mI->Entity2dManager->RenderEntities2d ();
mI->Render->EndScene ();
}
// ----- Free -----
mI->End ();
return 0;
}