Untitled


SUBMITTED BY: Guest

DATE: Aug. 19, 2016, 1:47 a.m.

FORMAT: Text only

SIZE: 1.6 kB

HITS: 500

  1. /*
  2. "guessing.js" is a simple guess the number game created to illustrate
  3. the basics of gaming.
  4. Usage: this file is invoked from guessing.html
  5. Author: David Johnston
  6. Date: 2016
  7. Version: 1
  8. */
  9. // game constants --------------------------------------------------
  10. const TITLE = "Guessing Game";
  11. const MAXNUM = 30;
  12. const CLUELOWER = "It's lower than that.";
  13. const CLUEHIGER = "It's higher than that";
  14. const REPSUCCESS = "Yes! You got it!";
  15. const REPINIT = "Guess the correct number before the score reaches zero.";
  16. const NAIREPLY = "That doesn't appear to be an integer. Try again.";
  17. const R00 ="You second-hand mound of goofy rotting vegetation.";
  18. const R01 = "Ha! Ha! You're wrong";
  19. const R02 = "You pitiful mouthful of rotting lizard droppings.";
  20. const R03 = "You manky dollop of yeasty rotting vegetation.";
  21. const R04 = "Nope! Try again.";
  22. const R05 = "Sigh. You're not very good at this.";
  23. const ENTERKEY = 13; // the keycode for the enter key
  24. // game variables -------------------------------------------------------------
  25. var theNumber = Math.floor(Math.random() * MAXNUM);
  26. var guess = "0"; // will be *string* entered by player
  27. var score = MAXNUM; // score counts down from this number
  28. var replies = [R00, R01, R02, R03, R04, R05];
  29. var repliesIndex = 0;
  30. var comment = "This will be changed later in the code.";
  31. var gameIsOver = false;
  32. // get and setup the page title -----------------------------------------------
  33. var headingArea = document.getElementById("headingArea");
  34. headingArea.innerHTML = TITLE;

comments powered by Disqus