当前位置: 首页>>代码示例>>C++>>正文


C++ CIndieLib::Init方法代码示例

本文整理汇总了C++中CIndieLib::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CIndieLib::Init方法的具体用法?C++ CIndieLib::Init怎么用?C++ CIndieLib::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIndieLib的用法示例。


在下文中一共展示了CIndieLib::Init方法的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-------------

//.........这里部分代码省略.........
开发者ID:SerhiyYaschuk,项目名称:trapped-in-asylum,代码行数:101,代码来源:main.cpp

示例2: IndieLib

/*
==================
Main
==================
*/
int IndieLib()
{
	// ----- IndieLib intialization -----

	CIndieLib *mI = CIndieLib::Instance();
	if (!mI->Init ()) return 0;			

	// ----- Surface loading -----

	// 3d Dino loading
	IND_3dMesh mMeshDino;
	if (!mI->MeshManager->Add (&mMeshDino, "..\\resources\\trex dx\\dino videogame.x", "..\\resources\\trex dx")) return 0;

	// Font
	IND_Font mFontSmall;
	if (!mI->FontManager->Add (&mFontSmall, "..\\resources\\font_small.png", "..\\resources\\font_small.xml", IND_ALPHA, IND_32)) return 0;

	// ----- Font creation -----

	IND_Entity2d mTextSmallWhite;					
	mI->Entity2dManager->Add		(&mTextSmallWhite);			// Entity adding
	mTextSmallWhite.SetFont			(&mFontSmall);				// Set the font into the entity
	mTextSmallWhite.SetLineSpacing	(18);
	mTextSmallWhite.SetCharSpacing	(-8);
	mTextSmallWhite.SetPosition		(5, 5, 1);
	mTextSmallWhite.SetAlign		(IND_LEFT);

	// ----- Set the mesh into 3d entity -----

	// Creating 3d entity
	IND_Entity3d mDino;					
	mI->Entity3dManager->Add (&mDino);						// Entity adding
	mDino.Set3dMesh (&mMeshDino);							// Set the 3d mesh into the entity

	// ----- Cameras ------

	IND_Camera2d mCamera2d (mI->Window->GetWidth () / 2, mI->Window->GetHeight() / 2);
	IND_Camera3d mCamera3d (0.0f, 0.0f, -2.0f);
	mCamera3d.SetAspect ((float) mI->Window->GetWidth () / mI->Window->GetHeight());

	// ----- Light -----

	IND_Light mLight0;
	mI->LightManager->Add (&mLight0, IND_AMBIENT_LIGHT);
	mLight0.SetColor (1.0f, 1.0f, 1.0f, 1.0f);

	// Light 1 (Direction light)
	IND_Light mLight1;
	mI->LightManager->Add (&mLight1, IND_DIRECTIONAL_LIGHT);
	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 -----

//.........这里部分代码省略.........
开发者ID:CodiCamp,项目名称:C-game-course,代码行数:101,代码来源:Tutorial10.cpp


注:本文中的CIndieLib::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。