PDA

View Full Version : More help (this time more clear)



Fewmitz
03-30-2007, 02:17 AM
Ok, a while ago I made a thread, but I wasn't very clear in what I needed, so here's a new thread.

Basically, I'm trying to make a kind-of Simon Says Clone on javascript. Here's the code, the images are below it.
~~~~~~~~~~~~~~~~~
<html>
<head>
<style>
#i1{
position:absolute;
left:280;
top:300
}
#i2{
position:absolute;
left:100;
top:200}

#i3{
position:absolute;
left:460;
top:200}
#i4{
position:absolute;
left:280;
top:100}
#b1{
position:absolute;
left:315;
top:220}
#d1{
position:absolute;
left:350;
color:white}

</style>
<script>
skooba=false
var s = 0
var run
numzez=false
var compturn=true
var playerturn=false
iz=0
var a=0
var playerclick=new Array()
var compclick= new Array()
arrlength=1
var pirate
var z
var checkcorrect
var q
var howMany=1


function startSimon(){
if(compturn==true){
s++;
compclick.length=s
d1.innerHTML="Round:" + s
compturn=false
game()}
}
function game(){
numzez=parseInt(Math.random()*4)+1 //Problem:need this to run multiple times
if(arrlength<=compclick.length){
compclick[arrlength]="i"+numzez.value
for(q=0;q<=arrlength;q++){
setTimeout('eval("i" + numzez).src="WHITE.gif"',200)
setTimeout('eval("i" + numzez).src=numzez + ".gif"',600)
}
arrlength++

}

}







function check(equitable){
playerclick.length=compclick.length
if(howMany<=playerclick.length){
playerclick[howMany]=equitable
howMany++;
}
if(howMany>playerclick.length){
maybeRight()
return(true)}

}


function maybeRight(){
for(z=0;arrlength>z;z++){
if(playerclick[z]==compclick[z]){
checkcorrect=true
compturn=true}}
if(checkcorrect){
alert('win! Next Round')}
else{alert('You made it to Round ' + s + ' restart the page and try again')
}
}

</script>
</head>
<body bgColor="black">
<div id="d1">Click "Simon Declares"</div>
<input type="button" value="Simon Declares" id="b1" onclick="startSimon()">
<img id="i1" src="1.gif" onMouseDown="this.src='WHITE.gif'" onMouseUp="this.src='1.gif'" value="1" onclick='check(this.value)'>
<img id="i2" src="2.gif" onMouseDown="this.src='WHITE.gif'" onMouseUp="this.src='2.gif'" value="2" onclick='check(this.value)'>
<img id="i3" src="3.gif" onMouseDown="this.src='WHITE.gif'" onMouseUp="this.src='3.gif'" value="3" onclick='check(this.value)'>
<img id="i4" src="4.gif" onMouseDown="this.src='WHITE.gif'" onMouseUp="this.src='4.gif'" value="4" onclick='check(this.value)'>

</body>
</html>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And here are the pictures needed to...see ****.

http://i31.photobucket.com/albums/c367/Fewmitz/4.gif

http://i31.photobucket.com/albums/c367/Fewmitz/3.gif

http://i31.photobucket.com/albums/c367/Fewmitz/2.gif

http://i31.photobucket.com/albums/c367/Fewmitz/1.gif

"WHITE.gif" Is just a white rectangle, so I didn't bother to upload that one.
~~~~~~~~

Anyway, now the actual problem(s). Two things:

1- Only one light will flash, the equivalent of round one, I'm not sure how to make it do any number of "buttons"

2- It will register that the user has clicked a picture, but it never registers that you have clicked the right one. I can get it to say you're always right...or always wrong...

Any remedies? It's a nice chunk of code, so you might wanna post it into notepad if you wanna help >_>

P.S. I had it all nice and indented before I pasted it here, if you want me to upload the actual file somewhere, let me know.