所以我有一个任务,我必须得到错误绘制到屏幕(没问题),然后从屏幕底部绘制的bugbag射击(也没问题)。然而,我的问题是,当代码循环时,由于某种原因速度加快,我试图解决问题的所有事情都证明是徒劳的。我要么让它减慢一天(但没有循环通过摄入量)或没有任何变化。这是循环所在的代码片段,如果需要,我可以提供更多,但我很肯定问题源于此方法。
Point2D creatureThrow(Creature& myCreature, BugBag& theBag)
{
//Added for creature
Point2D creatureLocation = Point2D(CREATURE_DRAW_LEFT, 0);
int startingBugCount = theBag.getBugCount();
//std::vector<Bug> deadBugs(startingBugCount);
//Create bug
Bug* bug = new Bug();
// Display all the bugs
for (int bugNumber = 1; bugNumber <= startingBugCount; bugNumber++)
{
bug->moveTo(0, -90);
for (int step = 0; step < BUG_STEP_SIZE; step++) // 20 is the number of steps
{
gdsWindow.clear();
for (int j=0; j < bugNumber; j++) //move bugs
{
//bug->draw();
bug->moveBy(0, 8);
}
myCreature.draw();
theBag.draw();
bug->draw();
Sleep(FRAME_SLEEP);
}
}
return creatureLocation;
}