CAN YOU HELP A DAMSEL IN DISTRESS PLEASE???? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

CAN YOU HELP A DAMSEL IN DISTRESS PLEASE????

rainbowii7rainbowii7 Posts: 1Member
Calling all programmers for helllllllllllllllppppp!!! i am currently doing a uni degree and our lecturers have set us the task of making a game in JavaScript.

i chose to do a hangman game and have completed the actual game. I have recently been in hospital as I am disabled and so have not been in the lessons where my lecturers have been teaching us how to create scoring and incorporating different difficulty levels into the game.

it is now the holiday and my assignment is due in when we go back after the spring break. i have created my game however i was wondering if you would be able to help me and perhaps advise me how i may go about adding scoring and levels to my game.

This would be greatly appreciated if you were able to do so. Please email back as soon as possible, your help would make a huge difference. From Jude


here is the main code so far:
This is the main code which is in the left frame


HANGMAN GAME GUESSES

var words = new Array(); // HOLDS ALL THE WORDS
var numberOfWords = 31; // TOTAL NUMBER OF WORDS (UPDATE WHEN ADDING NEW)
// INDEX EACH WORD
words[0] = "COMPUTER";
words[1] = "MONITOR";
words[2] = "LAMINATOR";
words[3] = "SCANNER";
words[4] = "KEYBOARD";
words[5] = "PRINTER";
words[6] = "WEBCAM";
words[7] = "SPEAKERS";
words[8] = "FAX";
words[9] = "MODEM";
words[10] = "MICROPHONE";

words[11] = "FIREWORKS";
words[12] = "ILLUSTRATOR";
words[13] = "PREMIERE";
words[14] = "PHOTOSHOP";
words[15] = "SOUNDFORGE";
words[16] = "DIRECTOR";
words[17] = "DREAMWEAVER";
words[18] = "FLASH";
words[19] = "FREEHAND";
words[20] = "LIGHTWAVE";

words[21] = "JAVASCRIPT";
words[22] = "JAVA";
words[23] = "PHP";
words[24] = "HTML";
words[25] = "LINUX";
words[26] = "XHTML";
words[27] = "DHTML";
words[28] = "EIFFEL";
words[29] = "PASCAL";
words[30] = "DELPHINE";









var guessesSoFar = ""; // LETTERS GUESSED SO FAR
var misses = 0; // WRONG GUESSES SO FAR (SIX WILL HANG THE MAN)
var theWord = ""; // THE WORD THE PLAYER IS TRYING TO GUESS
var wordLength = 0; // THE LENGTH OF THE WORD
var newGame = "False"; // TRUE IF THE PLAYER HAS PRESSED THE NEW GAME BUTTON
var guessedWord = ""; // USED WHEN PLAYER TRIES TO GUESS THE WHOLE WORD AT ONCE

var letters = new Array(); // HOLDS EACH LETTER OF THE WORD
var status = new Array(); // EACH LETTER IS EITHER UNKNOWN OR FOUND

// RAND CREATES A RANDOM NUMBER FROM ZERO TO (N - 1)
function rand(n) {
var now = new Date();
var seed = now.getTime() % 0xffffffff;
seed = (0x015a435 * seed) % 0x7fffffff;
return (seed >> 16) % n;
}

// PICKWORD PICKS A WORD, AT RANDOM, FROM THE LIST OF WORDS
// PICKWORD ALSO RESETS THE GAME, I.E. SETTING THE STATUS OF ALL LETTERS TO UNKNOWN
function pickWord () {
newGame = "True";
theWord = words[rand(numberOfWords)];
wordLength = theWord.length;
misses = 0;
guessesSoFar = "";
for (var i = 0; i < wordLength; i++) {
letters[i] = theWord.charAt(i);
status[i] = "unknown";
}
parent.right1.document.theMan.src="gallows.gif";
printWord();
}

// PRINTS THE WORD TO THE TOP FRAME (HIDING ANY LETTERS THAT HAVE NOT BEEN GUESSED)
function printWord() {
guessedWord = "";
parent.top1.document.write("

");
for (i = 0; i < wordLength; i++) {
if (status[i] == "unknown") {
parent.top1.document.write("_ ")
} else {
guessedWord = guessedWord + letters[i];
parent.top1.document.write(letters[i] + " ")
}
}
parent.top1.document.write("

");
parent.top1.document.write("Guesses so far: " + guessesSoFar + "");
parent.top1.document.write("Misses so far: " + misses + "");
if (guessedWord == theWord) {
parent.top1.document.write("YOU WIN!!!");
parent.right1.document.theMan.src="EXCELLENT.gif";
newGame = "False"
}
if (misses > 5) { parent.top1.document.write("YOU LOSE!!!") }
parent.top1.document.write("
");
parent.top1.document.close();
}

// WHEN THE PLAYER CLICKS ON A LETTER BUTTON, THIS FUNCTION IS RUN.
// IT CHECKS THE PLAYER'S CHOICE AGAINST THE LIST OF ALL LETTERS IN
// THE WORD. IF THE GUESS IS WRONG, THE HANGMAN IMAGE MUST BE CHANGED.
function guessLetter(guess) {
if (newGame == "False") {
alert("Click NEW GAME to start playing!");
} else {
var gotOne = "False";
for (var i = 0; i < wordLength; i++) {
if (letters[i] == guess) {
status[i] = "found";
gotOne = "True";
}
}
guessesSoFar = guessesSoFar + guess + " ";
if (gotOne == "False") {
misses = misses + 1
if (misses == 1) { parent.right1.document.theMan.src="head.gif" }
if (misses == 2) { parent.right1.document.theMan.src="body.gif" }
if (misses == 3) { parent.right1.document.theMan.src="leftarm.gif" }
if (misses == 4) { parent.right1.document.theMan.src="rightarm.gif" }
if (misses == 5) { parent.right1.document.theMan.src="leftleg.gif" }
if (misses > 5) {
parent.right1.document.theMan.src="hanged.gif";
newGame = "False"
}
}
printWord();
}
}

// IF THE PLAYER TRIES TO GUESS THE WHOLE WORD, THIS FUNCTION TESTS THE GUESS AGAINST
// THE ACTUAL WORD.
function guessWord (){
theGuess = document.guesses.wholeWord.value;
theGuess = theGuess.toUpperCase();
if (theGuess == theWord) {
parent.top1.document.write("

");
parent.top1.document.write("Guesses so far: " + guessesSoFar + "");
parent.top1.document.write("Misses so far: " + misses + "");
parent.top1.document.write("YOU WIN!!!

");
parent.right1.document.theMan.src="EXCELLENT.gif"
parent.top1.document.write("
");
parent.top1.document.close();
newGame = "False"
} else {
alert("You have guessed incorrectly. Please try again! It is your duty to save Mr Incredible!");
}
}




Click a letter to guess it. To guess a whole word, type it in the box provided, then click
OK.
































Whole Word





image
image
image
image
image
image
image










Sign In or Register to comment.