本文整理汇总了C++中CollisionDetector::clearVector方法的典型用法代码示例。如果您正苦于以下问题:C++ CollisionDetector::clearVector方法的具体用法?C++ CollisionDetector::clearVector怎么用?C++ CollisionDetector::clearVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollisionDetector
的用法示例。
在下文中一共展示了CollisionDetector::clearVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void GameEngine::run()
{
spriteVec.push_back(levelVec.at(currentLevel)->getBackground());
spriteVec.push_back(player);
bool goOn = true;
long laps = 0;
while (goOn) {
Uint32 nextTick = SDL_GetTicks() + ticks;
SDL_RenderClear(win->getRen());
if (initialLoop) {
textInput();
initialLoop = false;
}
SDL_Event eve2;
for (size_t i = 0; i < spriteVec.size(); i++) {
spriteVec.at(i)->draw();
cd.checkCollisions(spriteVec.at(i));
}
removeSprites();
cd.clearVector();
for (size_t i = 0; i < textBoxVec.size(); i++) {
textBoxVec.at(i)->draw();
}
if (pointCounter != nullptr) {
pointCounter->draw();
}
SDL_RenderPresent(win->getRen());
if (player == nullptr) {
playerDied();
}
while (SDL_PollEvent(&eve2)) {
switch (eve2.type) {
case SDL_QUIT: goOn = false;
break;
case SDL_KEYDOWN:
if (functionMap.count(eve2.key.keysym.sym) != 0) {
functionMap[eve2.key.keysym.sym]();
}
for (size_t i = 0; i < memberFuncVec.size(); i++) {
memberFuncVec.at(i)->perform(eve2.key.keysym.sym);
}
for (size_t i = 0; i < spriteVec.size(); i++) {
spriteVec.at(i)->draw(eve2);
}
break;
case SDL_KEYUP:
for (size_t i = 0; i < spriteVec.size(); i++) {
spriteVec.at(i)->draw(eve2);
}
break;
}
}
laps++;
levelVec.at(currentLevel)->spawnWave(this, laps);
deleteSpawns(laps);
//This is triggered when the level is over:
if (laps > levelVec.at(currentLevel)->getEndFrame()) {
SDL_RenderClear(win->getRen());
for (size_t i = 0; i < spriteVec.size(); i++) {
if (spriteVec.at(i)->getIsPlayer() == false) {
spriteVec.at(i)->destroy(); //Prepare every sprite for removal except the player
}
}
removeSprites();
spriteVec.clear();
deleteAllSpawns();
SDL_RenderClear(win->getRen());
levelSwap(); //Needs to be set by the game programmer
currentLevel++;
return this->run();
}
if (SDL_GetTicks() < nextTick) {
SDL_Delay(nextTick - SDL_GetTicks());
}
}
}