terça-feira, 24 de junho de 2014

Programa em Javascript

Já que eu ainda não sei o que fazer aqui exatamente, vou postar o primeiro jogo que eu fiz em javascript com o CodeAcademy.

var slaying = true;
var youHit = Math.random();
var damageThisRound = Math.floor(Math.random() * 5 + 1);
var totalDamage = 0;

while (slaying) {
  if (youHit) {
      console.log("You hit!");
      totalDamage += damageThisRound;
          if (totalDamage >= 4) {
              console.log("You win!");
              slaying = false;
          } else {
              youHit = Math.floor(Math.random() * 2);
          }
  } else {
      console.log("You lose!");
      slaying = false;
  }
}


0 comentários:

Postar um comentário