Exemplo n.º 1
0
void Game::update(){
  animateColors();
  if(ball.bounces > 3){
    ball.vx *= 1.2;
    ball.bounces = 0;
  }
  ball.move(duration);
  ballCollision();
  //Check for Points on each side made
  if(ball.x < 0 - abs(ball.vx)){ //Because vx is negative abs() needed here because if the Ball turns it would be a point for the enemy
    rightPoints++;
    ball.x = width /2;
    ball.y = height/2;
    ball.old_x = width/2;
    ball.old_y = height/2;
    ball.vx = -5;
    ball.vy = 0;
  }
  else if(ball.x > 31 + abs(ball.vx)){
    leftPoints++;
    ball.x = width /2;
    ball.y = height/2;
    ball.old_x = width/2;
    ball.old_y = height/2;
    ball.vx = 5;
    ball.vy = 0;
  }
}
Exemplo n.º 2
0
void BaseCreatureEntity::animate(float delay)
{
  if (hpDisplay > hp) hpDisplay--;
  else if (hpDisplay < hp) hpDisplay++;

  delay = animateStates(delay);
  animateColors(delay);
  animateRecoil(delay);
  animatePhysics(delay);

  z = y + height/2;
}