can we make console game with javascript code example
Example: javascript rpg tutorial
tChar.fight = function(enemy){
//assumes enemy is also based on Char
hitPerc = (this.hitPerc - enemy.defMod) / 100;
if (Math.random() < hitPerc){
damage = 0;
for (i = 0; i < this.damage; i++){
damage += parseInt(Math.random() * 6);
} // end for
damage -= enemy.armor;
enemy.hp -= damage;
if (enemy.hp <= 0){
alert(enemy.name + " is dead!")
document.location.href = ";
} // end 'enemy dead' if
} // end "hit" if
} // end fight