Untitled


SUBMITTED BY: Guest

DATE: Aug. 18, 2016, 11:36 p.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 580

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

comments powered by Disqus