Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 15th, 2002, 10:39 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 18
Cool And again..

Okay, it's been done before, but what's the big shakes... this was done in the last 30 minutes...

<html>
<head>
<style type="text/css">
a {color:blue; text-decoration:none;}
a:hover {color:blue; text-decoration:none;}
</style>
<script type="text/javascript">
var letters = "abcdefghijklmnopqrstuvwxyz"
var topic = "Movies"
var choose = new Array('gone with the wind','the matrix','rush hour','start wars episode two','terminator two')
var chosen = new Array()
var mychoice = choose[Math.floor(Math.random() * choose.length)]
var chosenword = new Array()
var chosenword2 = new Array()
for (x = 0; x < mychoice.length; x++) {
chosenword[x] = mychoice.substr(x,1)
if (mychoice.substr(x,1) != " ") {
chosenword2[x] = "_"
} else {
chosenword2[x] = " "
}
}
var wrong = 0
var allowedwrong = 10
var isgame = true

function init() {
page = ""
document.getElementById("topic").innerHTML = topic
for (x = 0; x < letters.length; x++) {
if (x % 9 == 8) {
page += "<br>"
}
page += "<a href='javascript: chooseme(\"" + letters.substr(x,1) + "\")'>" + letters.substr(x,1) + "</a>&nbsp;&nbsp;&nbsp;"
}
document.getElementById("letterdisplay").innerHTML = page
page = ""
for (x = 0; x < chosenword2.length; x++) {
page += "&nbsp;&nbsp;" + chosenword2[x] + "&nbsp;&nbsp;"
}
page += "<br><br>You have " + (allowedwrong - wrong) + " attempts"
document.getElementById("display").innerHTML = page

}

function chooseme(value) {
if (isgame) {
isfound = false
chosen[chosen.length] = value
for (x = 0; x < chosen.length; x++) {
for (y = 0; y < chosenword.length; y++) {
if (chosenword[y] == value) {
chosenword2[y] = value
isfound = true
}
}
}
if (!isfound) {
wrong++
if (wrong == allowedwrong) {
revealbad()
} else {
removeme(value)
}
} else {
for (y = 0; y < chosenword2.length; y++) {
if (chosenword2[y] != "_") {
isanswer = true
} else {
isanswer = false
break
}
}
if (!isanswer) {
removeme(value)
} else {
revealgood()
}
}
}
}
function removeme(value) {
letters =letters.replace(value,"")
init()
}
function revealbad() {
isgame = false
page = "You're hanged, the answer was<br>"
for (x = 0; x < chosenword.length; x++) {
page += "&nbsp;&nbsp;" + chosenword[x] + "&nbsp;&nbsp;"
}
page += "<br><a href='hangman.html'>Play again</a>"
document.getElementById("display").innerHTML = page
}
function revealgood() {
isgame = false
page = "Well done, the answer was<br>"
for (x = 0; x < chosenword.length; x++) {
page += "&nbsp;&nbsp;" + chosenword[x] + "&nbsp;&nbsp;"
}
page += "<br><a href='hangman.html'>Play again</a>"
document.getElementById("display").innerHTML = page
}
</script>
</head>
<body onLoad='init()'>
<center>
<h2 id='topic'></h2>
<p id='letterdisplay' style='font-size:14pt;'>
</p><p>
<big>Please select a letter from the above list.</big>
</p>
<p id='display'>
</p>
</center>
</body>
</html>

Not Opera this time.
__________________
- Sorted!

www.ppfuk.com - Free Photo Sharing

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > And again..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway