Exemplo n.º 1
0
void Map::Draw()
{
	_d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, COLOR_GREY, 1.0f, 0);
	drawRightMenu();	
	drawMap();
	drawEagle();
	BulletManager::getInstance()->Draw();
	drawIce();
	drawPlayer();
	drawEnemy();
	drawTrees();
	drawPowerUp();
	EffectManager::getInstance(0)->Draw();
	if (_player->getLife() < 0 || _eagle->getEagleStatus() == EAGLE_STATUS::DEAD)
	{
		_text->drawText("GAME\nOVER", _posGameOverText, COLOR_RED, 30, DT_CENTER, 0, 2);
	}
}
Exemplo n.º 2
0
void drawScene() {
  glPushMatrix();

  //Set the animation control variables.
  if (!paused) frame++;
  int ticks = frame % 1440;
  if (frame % 1440 == 0) {
    ticks = 0;

    //Reset animation object positions and rotations.
    planePriorX = 0, planePriorY = 0, planePriorZ = 0;
    planePostX = 0, planePostY = 0, planePostZ = 0;
    planeRotX = 0, planeRotY = 0, planeRotZ = 0;

    eaglePriorX = -0.5, eaglePriorY = 0.03, eaglePriorZ = -0.1;
    eaglePostX = 0, eaglePostY = 0, eaglePostZ = 0;
    eagleRotX = 0, eagleRotY = 0, eagleRotZ = 0;
  }

  //Apply scene transformations.
  glRotatef(30, 0, 1, 0);
  glTranslatef(0, 0, -1500 * frame * SCALE_FACTOR);

  //Make sure angles are in bounds.
  bounds(planeRotX); bounds(planeRotY); bounds(planeRotZ);
  bounds(eagleRotX); bounds(eagleRotY); bounds(eagleRotZ);

  if (!paused) {
    //Airplane transformation events.
    //Constant swaying.
    planeRotZ -= 0.5 * cos(ticks * 2 * PI / 180);
    planePostY -= 0.01 * cos(ticks * PI / 180);

    //Spin upside-down.
    if (ticks >= 180 && ticks < 360) planeRotZ -= PI * 0.5 * sin(ticks * PI / 180);

    //Spin back round.
    if (ticks >= 360 && ticks < 540) planeRotZ += PI * 0.5 * sin(ticks * PI / 180);

    //Dive.
    if (ticks >= 720 && ticks < 900) {
      planeRotX -= 0.25 * PI * sin(ticks * 2 * PI / 180);
      planePriorY -= 0.005 * PI * sin(ticks * PI / 180);
      planePriorZ -= 0.01 * PI * sin(ticks * 0.5 * PI / 180);
    }

    //Loop-the-loop
    if (ticks >= 900 && ticks < 1220) {
      planeRotX += 1;
      planePriorY += 0.015 * PI * sin((ticks - 180) * PI / 180);
      planePriorZ -= 0.015 * PI * cos((ticks - 180) * PI / 180);
    }

    //Reset position.
    if (ticks >= 1220 && ticks < 1440) {
      // These values were found by minimising errors using binary division.
      planeRotX -= 0.1262345 * PI * sin(ticks * PI / 180);
      planePriorY -= 0.002379563 * PI * sin(ticks * 0.5 * PI / 180);
      planePriorZ -= 0.003826425 * PI * sin(ticks * 0.5 * PI / 180);
    }

    //Eagle transformation events.
    //Set default position.
    eaglePriorX = -1;
    eaglePriorZ = 0.4;

    //Set start position over left wing.
    if (ticks >= 0 && ticks < 180) {
      eaglePriorX = -0.5;
      eaglePriorY = 0.03;
      eaglePriorZ = -0.1;
    }

    //Move a little with the wing.
    if (ticks >= 0 && ticks < 90) {
      eagleRotZ -= cos(ticks * 2 * PI / 180);
      eaglePostY -= 0.009 * sin(ticks * 2 * PI / 180);
    }

    //Move back, up and left.
    if (ticks >= 90 && ticks < 180) {
      eaglePriorX -= (float)0.5 / 90 * (ticks - 90);
      eaglePriorZ += (float)0.5 / 90 * (ticks - 90);
      eaglePostY += 0.009 * sin((ticks - 90) * 2 * PI / 180);
    }

    //Swaying.
    if (ticks >= 90 && ticks < 1350) {
      eagleRotZ -= 0.6 * cos((ticks + 90) * PI / 180);
      eaglePostY -= 0.01 * cos((ticks + 90) * 2 * PI / 180);
    }

    //Avoid plane collision.
    if (ticks >= 360 && ticks < 540) eagleRotZ += 0.25 * PI * sin(ticks * 2 * PI / 180);

    //Glide from side to side.
    if (ticks >= 720 && ticks < 1080) eaglePriorX += 0.4 * PI * sin(ticks * 0.5 * PI / 180);

    //Move back to start position.
    if (ticks >= 1350 && ticks < 1440) {
      eaglePriorX += (float)0.5 / 90 * (ticks - 1350);
      eaglePriorZ -= (float)0.5 / 90 * (ticks - 1350);
    }

    //Avoid plane collision.
    if (ticks >= 1400 && ticks < 1420) eaglePriorY += 0.01;
    if (ticks >= 1420 && ticks < 1440) eaglePriorY -= 0.01;
  }

  //Apply the transformations then draw the airplane.
  glPushMatrix();
  glTranslatef(planePriorX, planePriorY, planePriorZ);
  glRotatef(planeRotX, 1, 0, 0);
  glRotatef(planeRotY, 0, 1, 0);
  glRotatef(planeRotZ, 0, 0, 1);
  glTranslatef(planePostX, planePostY, planePostZ);
  drawAirplane();
  glPopMatrix();

  //Apply the transformations then draw the eagle.
  glPushMatrix();
  glTranslatef(eaglePriorX, eaglePriorY, eaglePriorZ);
  glRotatef(eagleRotX, 1, 0, 0);
  glRotatef(eagleRotY, 0, 1, 0);
  glRotatef(eagleRotZ, 0, 0, 1);
  glTranslatef(eaglePostX, eaglePostY, eaglePostZ);
  drawEagle();
  glPopMatrix();
  glPopMatrix();
}