/* Description: "guessing.js" is a simple guess the number game made to illustrate the basics of game programming. Author: David Johnston Date: 2016 Version: 1 Usage: Invoked via guessing.html */ // game constants ------------------------------------------------------------- const TITLE = "Guessing Game"; const MAXNUM = 20; const CLUELOWER = "It's lower than that."; const CLUEHIGHER = "It's higher than that."; const REPSUCCESS = "Yes! You got it!"; const NAIREPLY = "That doesn't appear to be an integer. Try again."; const R00 = "Ha! Ha! You're wrong!"; const R01 = "Nope! Try again."; const R02 = "Sigh. You're not very good at this."; const R03 = "You god-awful shovel-full of fermenting garbage."; const R04 = "You nauseating bunch of illiterate rat cysts."; const R05 = "You insolent lump of unimpressive hogwash."; const ENTERKEY = 13; // the keycode for the enter key // game variables ------------------------------------------------------------- var theNumber = Math.floor(Math.random() * MAXNUM); var guess = "0"; // will be a *string* entered by player var score = MAXNUM; // score counts down from this number var headingArea = document.getElementById("headingArea"); headingArea.innerHTML = TITLE;