473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

CAN ANYONE HELP A DAMSEL IN DISTRESS??????????

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
<html>
<head>
<title> HANGMAN GAME GUESSES </title>
<script language = "JavaScript">
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("<html><head></head><body><center><h1><font
face=Verdana color='#666666'>");
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("</h1></p>");
parent.top1.document.write("<b><h2><font face=Verdana
color='#666666'>Guesses so far: " + guessesSoFar + "</FONT><p>");
parent.top1.document.write("<font face=Verdana color='#666666'>Misses
so far: " + misses + "</h2></FONT><b>");
if (guessedWord == theWord) {
parent.top1.document.write("<p><h1><font face=Verdana
color='#666666'>YOU WIN!!!</FONT></h1>");
parent.right1.document.theMan.src="EXCELLENT.gif";
newGame = "False"
}
if (misses > 5) { parent.top1.document.write("<p><h1><font
face='Verdana'color='#666666'>YOU LOSE!!!</FONT></h1>") }
parent.top1.document.write("</center></body></html>");
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("<html><head></head><body><center><h1><font
face=Verdana color='#666666'>");
parent.top1.document.write("<b><h2>Guesses so far: " + guessesSoFar +
"<p>");
parent.top1.document.write("Misses so far: " + misses + "</h2><b>");
parent.top1.document.write("<p><h1>YOU WIN!!!</h1>");
parent.right1.document.theMan.src="EXCELLENT.gif"
parent.top1.document.write("</center></body></html>");
parent.top1.document.close();
newGame = "False"
} else {
alert("You have guessed incorrectly. Please try again! It is your
duty to save Mr Incredible!");
}
}
</script>

</head>
<body bgcolor = "CC6699" link = "black" vlink = "black" alink =
"black">
<b><font face="Verdana" color="#FFCCFF">Click a letter to guess it. To
guess a whole word, type it in the box provided, then click
OK.</font>
<form name = "guesses">
<center>
<input type = button value = "NEW GAME" onclick = "pickWord()"><p>
<input type = button value = " A " onclick = "guessLetter('A')">
<input type = button value = " B " onclick = "guessLetter('B')">
<input type = button value = " C " onclick = "guessLetter('C')">
<input type = button value = " D " onclick = "guessLetter('D')">
<input type = button value = " E " onclick = "guessLetter('E')">
<input type = button value = " F " onclick = "guessLetter('F')">
<input type = button value = " G " onclick = "guessLetter('G')">
<input type = button value = " H " onclick = "guessLetter('H')">
<input type = button value = " I " onclick = "guessLetter('I')">
<input type = button value = " J " onclick = "guessLetter('J')">
<input type = button value = " K " onclick = "guessLetter('K')">
<input type = button value = " L " onclick = "guessLetter('L')">
<input type = button value = " M " onclick = "guessLetter('M')">
<input type = button value = " N " onclick = "guessLetter('N')">
<input type = button value = " O " onclick = "guessLetter('O')">
<input type = button value = " P " onclick = "guessLetter('P')">
<input type = button value = " Q " onclick = "guessLetter('Q')">
<input type = button value = " R " onclick = "guessLetter('R')">
<input type = button value = " S " onclick = "guessLetter('S')">
<input type = button value = " T " onclick = "guessLetter('T')">
<input type = button value = " U " onclick = "guessLetter('U')">
<input type = button value = " V " onclick = "guessLetter('V')">
<input type = button value = " W " onclick = "guessLetter('W')">
<input type = button value = " X " onclick = "guessLetter('X')">
<input type = button value = " Y " onclick = "guessLetter('Y')">
<input type = button value = " Z " onclick = "guessLetter('Z')">
<p>
<font color="#FFCCFF" face="Verdana">
Whole Word </font> <input type = text name = "wholeWord">
<input type = button value = " OK " onclick = "guessWord()">
<input type = button value = "I GIVE UP" onclick =
"javascript:alert('The word is ' + theWord + '.')"><p>
<img src = "head.gif" width = 1 height = 1>
<img src = "body.gif" width = 1 height = 1>
<img src = "leftarm.gif" width = 1 height = 1>
<img src = "rightarm.gif" width = 1 height = 1>
<img src = "leftleg.gif" width = 1 height = 1>
<img src = "hanged.gif" width = 1 height = 1>
<img src = "EXCELLENT.gif" width = 1 height = 1>
<center>
</form>
</body>
</html>

Jul 23 '05 #1
1 1634

ra********@hotmail.com wrote:
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.


Talk to your lecturers, they would certainly give you an extension on
the due date of your assignment when you tell them that you have been
in hospital.

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
1
by: Harag | last post by:
Hi all Classic ASP, Textpad Local "test" WebServer. IIS5 Well my MS script debugger isn't running and I can't findout why. I'm sick of it failing on me so was looking for an alternative. I...
13
by: penguin732901 | last post by:
Checking back for discussions, there was a lot of talk about 2000 being slower than 97, but not so much lately. What is the latest opinion? Anyone care to set up a poll for how many NG members...
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
7
by: Skc | last post by:
Hullo Just like to check whether anyone has tried RentACoder. I intend to farm out a small job that must use C#, WinForms, ADO.Net for around US$400, but don't know whether RentACoder is...
8
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in...
1
by: Beatrice Rutger | last post by:
Hi, I wonder if any of you could come to the rescue of a damsel in distress ;-) I am looking for 2 very simple VC++ examples (projects/solutions) that does the ff: 1). Includes a Form and...
0
by: Gareth | last post by:
I cannot find a reference anywhere to anyone having done this successfully... can anyone enlighten me on how you get a SSL login page working with ASP.NET and forms authentication. I have...
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
5
by: tony | last post by:
I'm using PHP 5 on Win-98 command line (ie no web server involved) I'm processing a large csv file and when I loop through it I can process around 275 records per second. However at around...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.