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


C++ OBJLIST::begin方法代码示例

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


在下文中一共展示了OBJLIST::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

	float dx = 0.5f;
	float dy = 0.2f;
	float dz = 0.0f;

    // Main loop
	dyrot = 0.0;
    running = GL_TRUE;
    frames = 0;
	unsigned int ticks = SDL_GetTicks();
    while( running )
		{
		// limit fps to 50 frames per second
		while((SDL_GetTicks() - ticks) < 20) ;
		ticks = SDL_GetTicks();

        // Get mouse position
		//SDL_PumpEvents();
		Uint8 mousebutton = SDL_GetMouseState( &x, &y );

        frames ++;

		// animate
		dz += 0.05f;
		pObject = Scene.GetObject(0, 0);		// sights
		pObject->rotation.z = dz;
		pObject->position.x = (float)((VIEW_WIDTH/2) - x) / 40.0f;
		pObject->position.y = (float)((VIEW_HEIGHT/2) - y) / 40.0f;

		// BEGIN BEHAVIOURS
		// Behaviours 1: Enemy objects (gliders)
		OBJLIST* objList = Scene.GetObjectList(ENEMY_LIST);
		OBJLIST::iterator objIter;
		for(objIter = objList->begin(); objIter != objList->end(); objIter++)
			{
			if(1 == objIter->modelNumber)
				{
				// this is a glider
				if(1 == objIter->behaviour)
					{
					objIter->SetRotation(0.0f, DEG2RAD(180), 0.0f);
					objIter->position.z -= 1.0f;
					if(objIter->position.z < 0.0f)
						objIter->position.z = 300.0f + rand() % 50;
					}
				}
			}

		// Behaviours 2: Bullets
		objList = Scene.GetObjectList(BULLET_LIST);
		for(objIter = objList->begin() ; objIter != objList->end(); objIter++)
			{
			if(3 == objIter->modelNumber)
				{
				if(1 == objIter->behaviour)	// active
					{
					objIter->position += objIter->velocity;
					// check if this bullet has hit any gliders
					OBJLIST* gliderList = Scene.GetObjectList(ENEMY_LIST);
					OBJLIST::iterator gliderIter;
					for(gliderIter = gliderList->begin() ; gliderIter != gliderList->end(); gliderIter++)
						{
						if(1 == gliderIter->behaviour)	// glider active
							{
							if(fabs(gliderIter->position.z - objIter->position.z) < 5.0f)
								{
开发者ID:james7780,项目名称:E3D,代码行数:67,代码来源:example4_sdl.cpp

示例2: main


//.........这里部分代码省略.........
		{
		// fps limiter
		while((glfwGetTime() - startTime) < 0.02) ;
		startTime = glfwGetTime();

        // Get time and mouse position
        t = glfwGetTime();
        glfwGetMousePos( &x, &y );

        // Calculate and display FPS (frames per second)
        if( (t-t0) > 1.0 || frames == 0 )
			{
            fps = (double)frames / (t-t0);
            sprintf( titlestr, 
				"E3DOO Win32OpenGL Example1 (%.1f FPS) %d objects", 
				fps, Scene.GetNumObjects());
            glfwSetWindowTitle( titlestr );
            t0 = t;
            frames = 0;
			}
        frames ++;

		// animate
		dz += 0.05f;
		pObject = Scene.GetObject(0, 0);		// sights
		pObject->rotation.z = dz;
		pObject->position.x = (float)((VIEW_WIDTH/2) - x) / 40.0f;
		pObject->position.y = (float)((VIEW_HEIGHT/2) - y) / 40.0f;

		// BEGIN BEHAVIOURS
		// Behaviours 1: Enemy objects (gliders)
		OBJLIST* objList = Scene.GetObjectList(ENEMY_LIST);
		OBJLIST::iterator objIter;
		for(objIter = objList->begin(); objIter != objList->end(); objIter++)
			{
			if(1 == objIter->modelNumber)
				{
				// this is a glider
				if(1 == objIter->behaviour)
					{
					objIter->SetRotation(0.0f, DEG2RAD(180), 0.0f);
					objIter->position.z -= 1.0f;
					if(objIter->position.z < 0.0f)
						objIter->position.z = 300.0f + rand() % 50;
					}
				}
			}

		// Behaviours 2: Bullets
		objList = Scene.GetObjectList(BULLET_LIST);
		for(objIter = objList->begin() ; objIter != objList->end(); objIter++)
			{
			if(3 == objIter->modelNumber)
				{
				if(1 == objIter->behaviour)	// active
					{
					objIter->position += objIter->velocity;
					// check if this bullet has hit any gliders
					OBJLIST* gliderList = Scene.GetObjectList(ENEMY_LIST);
					OBJLIST::iterator gliderIter;
					for(gliderIter = gliderList->begin() ; gliderIter != gliderList->end(); gliderIter++)
						{
						if(1 == gliderIter->behaviour)	// glider active
							{
							if(fabs(gliderIter->position.z - objIter->position.z) < 5.0f)
								{
开发者ID:james7780,项目名称:E3D,代码行数:67,代码来源:example4_glfw.cpp


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