C++ (Qt) std::vector<QOpenGLTexture*> m_textures; ... frame = image.copy( 257, 112, 15, 15 ); m_textures.push_back( new QOpenGLTexture( frame ) ); frame = image.copy( 272, 112, 16, 16 ); m_textures.push_back( new QOpenGLTexture( frame ) ); frame = image.copy( 287, 111, 18, 18 ); m_textures.push_back( new QOpenGLTexture( frame ) );
C++ (Qt) for ( auto iterOfProjectile = m_projectiles.begin(); iterOfProjectile != m_projectiles.end(); ++iterOfProjectile ) { .... m_projectiles.erase( iterOfProjectile ); addProjectileExplosion( x0, y0 );
C++ (Qt) typedef std::map<int, Projectile*> TMap; TMap::iterator iterOfProjectile = m_projectiles.begin(); // for ( auto iterOfProjectile = m_projectiles.begin(); iterOfProjectile != m_projectiles.end(); ++iterOfProjectile ) while (iterOfProjectile != m_projectiles.end()) { Projectile *projectile = iterOfProjectile->second; float x0 = projectile->x0(); float y0 = projectile->y0(); bool doDel = false; switch ( projectile->direction() ) { case Projectile::Up: projectile->setY0( projectile->y0() - step ); doDel = projectile->y0() <= 0.0f; break; case Projectile::Left: projectile->setX0( projectile->x0() - step ); doDel = projectile->x0() < 0.0f; break; case Projectile::Down: projectile->setY0( projectile->y0() + step ); doDel = projectile->y0() >= ( m_canvasHeight - projectile->height() ); break; case Projectile::Right: projectile->setX0( projectile->x0() + step ); doDel = projectile->x0() > ( m_canvasWidth - projectile->width() ); break; } if (doDel ) { delete projectile; m_projectiles.erase( iterOfProjectile++ ); addProjectileExplosion( x0, y0 ); } else iterOfProjectile++; }
C++ (Qt)auto iterOfProjectile = m_projectiles.begin();
C++ (Qt)typedef std::map<int, Projectile*> TMap;TMap::iterator iterOfProjectile = m_projectiles.begin();
C++ (Qt)void SoundOfShot::run(){ m_sound.play(); while ( m_sound.isPlaying() );}
C++ (Qt)SoundOfShot *sound = new SoundOfShot;sound->setAutoDelete( true );QThreadPool::globalInstance()->start( sound );
C++ (Qt)QThreadPool::globalInstance()->setMaxThreadCount( 15 );