本文整理汇总了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)
{
示例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)
{