Skip to content

Instantly share code, notes, and snippets.

@arozwalak
Forked from born2frag/dragongame.js
Last active March 9, 2017 22:05
Show Gist options
  • Save arozwalak/8002880 to your computer and use it in GitHub Desktop.
Save arozwalak/8002880 to your computer and use it in GitHub Desktop.
Javascript: Dragon game
var slaying = true;
var youHit = Math.floor(Math.random()*2);
var damageThisRound = Math.floor(Math.random()*2);
var totalDamage = 0;
while(slaying)
{
if(youHit)
{
console.log("Nice - you've just hit black dragon");
totalDamage += damageThisRound;
if(totalDamage>=4)
{
console.log("HOLY SHIT - YOU JUST KILL A DRAGON")
slaying = false;
}
else
{
youHit = Math.floor(Math.random() * 2);
}
}
else
{
console.log("You missed the dragon - that means you dead")
}
slaying = false;
}
console.log(youHit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment