本文整理汇总了C++中Laser::setSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Laser::setSpeed方法的具体用法?C++ Laser::setSpeed怎么用?C++ Laser::setSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laser
的用法示例。
在下文中一共展示了Laser::setSpeed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextMove
void Engine::nextMove(int turn, Pattern patt, Graphics* graph) {
// Big and ugly switch function, but much less work than using functors, for the same effect
// TODO: change the values that now are magic numbers so that the destruction of the ships in a stage triggers the beginning of another one
switch (patt) {
case MAIN_STAGE:
// FIRST ENEMY
if (turn == 0) {
Mix_PlayChannel(-1, graph->getPortIn(), 0);
}
if (turn < 20 ) {
// This is an excellent porting
graph->printOtherOnScreen(SHIP_PORTING, 60, 60, turn*18, static_cast<double>(turn)/20);
}
else if (turn == 20) {
spawnEnemy(40, 40, EN_FIGHTER, 1);
}
else if (turn > 20 && turn < 360) {
if (enemyFleet[0]) {
moveEnemyOnMap(0, 2, enemyFleet[0]);
}
}
else if (turn == 360 && enemyOnScreen) {
// Here I need not use enemy1 and so on because I'm cleaning everything
if (enemyFleet[0]->isAlive()) {
expiredEnemy0 = true;
}
cleanEnemyFleet();
Mix_PlayChannel(-1, graph->getPortOut(), 0);
}
else if (turn > 360 && turn < 380) {
if (expiredEnemy0) {
// Maybe turning the lasers a little in the direction of movement helps
graph->printOtherOnScreen(SHIP_PORTING, 740, 60, turn*18, static_cast<double>(380 - turn)/20);
}
}
else if (turn == 380) {
cleanEnemyFleet();
expiredEnemy0 = false;
}
if (turn >= 31 && turn % 15 == 1 && turn < 360) {
if (enemyFleet[0]->isAlive()) {
for (int i = -4; i <= 4; i++) {
Laser* tmp = enemyFleet[0]->shootLaser(i*pi/24 + (pi*1.5), LASER_ENEMY);
tmp->setSpeed(6);
lasersOnMap.push_back(tmp);
}
Mix_PlayChannel(-1, graph->getZap(), 0);
}
}
// SECOND ENEMY
if (turn == 400) {
Mix_PlayChannel(-1, graph->getPortIn(), 0);
}
if (turn > 400 && turn < 420 ) {
graph->printOtherOnScreen(SHIP_PORTING, 740, 60, (turn-400)*18, static_cast<double>(turn - 400)/20);
}
else if (turn == 420) {
spawnEnemy(720, 40, EN_FIGHTER, 1);
}
else if (turn > 420 && turn < 760) {
if (enemyFleet[0]) {
moveEnemyOnMap(pi, 2, enemyFleet[0]);
}
}
else if (turn == 760 && enemyOnScreen) {
if (enemyFleet[0]->isAlive()) {
expiredEnemy0 = true;
}
cleanEnemyFleet();
Mix_PlayChannel(-1, graph->getPortOut(), 0);
}
else if (turn > 760 && turn < 780) {
if (expiredEnemy0) {
graph->printOtherOnScreen(SHIP_PORTING, 60, 60, turn*18, static_cast<double>(780 - turn)/20);
}
}
else if (turn == 780) {
cleanEnemyFleet();
expiredEnemy0 = false;
}
if (turn >= 431 && turn % 15 == 1 && turn < 760) {
if (enemyFleet[0]->isAlive()) {
for (int i = -4; i <= 4; i++) {
Laser* tmp = enemyFleet[0]->shootLaser(i*pi/24 + (pi*1.5), LASER_ENEMY);
tmp->setSpeed(6);
lasersOnMap.push_back(tmp);
}
Mix_PlayChannel(-1, graph->getZap(), 0);
}
}
// THIRD AND FOURTH ENEMIES
// They move in sinusoids
if (turn == 800) {
Mix_PlayChannel(-1, graph->getPortIn(), 0);
}
if (turn > 800 && turn < 820 ) {
graph->printOtherOnScreen(SHIP_PORTING, 60, 100, (turn-800)*18, static_cast<double>(turn - 800)/20);
graph->printOtherOnScreen(SHIP_PORTING, 760, 100, (turn-800)*18, static_cast<double>(turn - 800)/20);
}
//.........这里部分代码省略.........
示例2: protagonistShootsSingleLaser
void Engine::protagonistShootsSingleLaser() {
Laser* tmp = protagonist->shootLaser(pi/2, LASER_ALLIED);
tmp->setSpeed(20);
lasersOnMap.push_back(tmp);
}