Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2012, 01:40 PM   PM User | #1
ioinic
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ioinic is an unknown quantity at this point
Returning Turn

Code:
<!DOCTYPE html PUBLIC >
<html 
<head>
<title>Circle and Squares</title>
<SCRIPT LANGUAGE="JavaScript">
var compgo=0;
var hit=0;
var t1=0;
var t2=0;
var box=new Array(161);
for(i=0;i<box.length;i++)
{
box[i]=0;
}
var occ=new Array(161);
for(i=0;i<occ.length;i++)
{
 occ[i]=0;
}
function dots_ini()
{
for(i=1;i<65;i++)
{
with(document.f)
{
n=eval('x'+i);
{
with(n)checked=0;
         }
      }
   }
}
function convert(t)
{
if(t1==0)t1=eval(t);else t2=eval(t);
if(t2!=0)
{
t=eval(t2-t1);
if(t==8||t==-8||t==1||t==-1)
{
t=eval(t1+t2);
switch(t)
{
case  3: case 10: case 12: case 14: case 16: go(t-3);break;
case 18: case 20: case 22: case 24: case 31: go(t-3);break;
case 5: go(t-4);break;
case 7: go(t-5);break;
case 9: go(t-6);break;
case 11: go(t-7);break;
case 13: go(t-8);break;
case 15: go(t-9);break;
case 19: case 26: case 28: case 30: case 32: go(t+3);break;
case 34: case 36: case 38: case 40: case 47: go(t+3);break;
case 21: go(t+2);break;
case 23: go(t+1);break;
case 25: go(t);break;
case 27: go(t-1);break;
case 29: go(t-2);break;
case 35: case 42: case 44: case 46: case 48: go(t+9);break;
case 50: case 52: case 54: case 56: case 63: go(t+9);break;
case 37: go(t+8);break;
case 39: go(t+7);break;
case 41: go(t+6);break;
case 43: go(t+5);break;
case 45: go(t+4);break;
case 51: case 58: case 60: case 62: case 64: go(t+15);break;
case 66: case 68: case 70: case 72: case 79: go(t+15);break;
case 53: go(t+14);break;
case 55: go(t+13);break;
case 57: go(t+12);break;
case 59: go(t+11);break;
case 61: go(t+10);break;
case 67: case 74: case 76: case 78: case 80: go(t+21);break;
case 82: case 84: case 86: case 88: case 95: go(t+21);break;
case 69: go(t+20);break;
case 71: go(t+19);break;
case 73: go(t+18);break;
case 75: go(t+17);break;
case 77: go(t+16);break;
case 83: case 90: case 92: case 94: case 96: go(t+27);break;
case 98: case 100: case 102: case 104: case 111: go(t+27);break;
case 85: go(t+26);break;
case 87: go(t+25);break;
case 89: go(t+24);break;
case 91: go(t+23);break;
case 93: go(t+22);break;
case  99: case 106: case 108: case 110: case 112: go(t+33);break;
case 114: case 116: case 118: case 120: case 127: go(t+33);break;
case 101:go(t+32);break;
case 103:go(t+31);break;
case 105:go(t+30);break;
case 107:go(t+29);break;
case 109:go(t+28);break;
case 115:go(t+39);break;
case 117:go(t+38);break;
case 119:go(t+37);break;
case 121:go(t+36);break;
case 123:go(t+35);break;
case 125:go(t+34);break;
case 127:go(t+33);break;
}
with(document.f)
{
t1=eval('x'+t1);with(t1)checked=0;
t2=eval('x'+t2);with(t2)checked=0;
}
t1=0;
t2=0;
if(compgo==1)reply();
}
else
{
with(document.f)
{
t1=eval('x'+t1);with(t1)checked=0;
t2=eval('x'+t2);with(t2)checked=0;
}
t1=0;t2=0;
      }
   }
}
function go(t)
{
if(occ[t]!=1)
{
occ[t]=1;
var target = eval("document.f.i"+t);
if(compgo==1) target.src="blue.gif"; else target.src="red.gif";
switch(t)
{
case 0: ad(8,1);break;
case 1: ad(10,1);break;
case 2: ad(12,1);break;
case 3: ad(14,1);break;
case 4: ad(16,1);break;
case 5: ad(18,1);break;
case 6: ad(20,1);break;
case 7: ad(8,2);break;
case 9: ad(8,4);ad(10,2);break;
case 11: ad(10,4);ad(12,2);break;
case 13: ad(12,4);ad(14,2);break;
case 15: ad(14,4);ad(16,2);break;
case 17: ad(16,4);ad(18,2);break;
case 19: ad(18,4);ad(20,2);break;
case 21: ad(20,4);break;
case 22: ad(8,8);ad(30,1);break;
case 23: ad(10,8);ad(32,1);break;
case 24: ad(12,8);ad(34,1);break;
case 25: ad(14,8);ad(36,1);break;
case 26: ad(16,8);ad(38,1);break;
case 27: ad(18,8);ad(40,1);break;
case 28: ad(20,8);ad(42,1);break;
case 29: ad(30,2);break;
case 31: ad(30,4);ad(32,2);break;
case 33: ad(32,4);ad(34,2);break;
case 35: ad(34,4);ad(36,2);break;
case 37: ad(36,4);ad(38,2);break;
case 39: ad(38,4);ad(40,2);break;
case 41: ad(40,4);ad(42,2);break;
case 43: ad(42,4);break;
case 44: ad(30,8);ad(52,1);break;
case 45: ad(32,8);ad(54,1);break;
case 46: ad(34,8);ad(56,1);break;
case 47: ad(36,8);ad(58,1);break;
case 48: ad(38,8);ad(60,1);break;
case 49: ad(40,8);ad(62,1);break;
case 50: ad(42,8);ad(64,1);break;
case 51: ad(52,2);break;
case 53: ad(52,4);ad(54,2);break;
case 55: ad(54,4);ad(56,2);break;
case 57: ad(56,4);ad(58,2);break;
case 59: ad(58,4);ad(60,2);break;
case 61: ad(60,4);ad(62,2);break;
case 63: ad(62,4);ad(64,2);break;
case 65: ad(64,4);break;
case 66: ad(52,8);ad(74,1);break;
case 67: ad(54,8);ad(76,1);break;
case 68: ad(56,8);ad(78,1);break;
case 69: ad(58,8);ad(80,1);break;
case 70: ad(60,8);ad(82,1);break;
case 71: ad(62,8);ad(84,1);break;
case 72: ad(64,8);ad(86,1);break;
case 73: ad(74,2);break;
case 75: ad(74,4);ad(76,2);break;
case 77: ad(76,4);ad(78,2);break;
case 79: ad(78,4);ad(80,2);break;
case 81: ad(80,4);ad(82,2);break;
case 83: ad(82,4);ad(84,2);break;
case 85: ad(84,4);ad(86,2);break;
case 87: ad(86,4);break;
case 88: ad(74,8);ad(96,1);break;
case 89: ad(76,8);ad(98,1);break;
case 90: ad(78,8);ad(100,1);break;
case 91: ad(80,8);ad(102,1);break;
case 92: ad(82,8);ad(104,1);break;
case 93: ad(84,8);ad(106,1);break;
case 94: ad(86,8);ad(108,1);break;
case 95: ad(96,2);break;
case 97: ad(96,4);ad(98,2);break;
case 99: ad(98,4);ad(100,2);break;
case 101: ad(100,4);ad(102,2);break;
case 103: ad(102,4);ad(104,2);break;
case 105: ad(104,4);ad(106,2);break;
case 107: ad(106,4);ad(108,2);break;
case 109: ad(108,4);break;
case 110: ad(96,8);ad(118,1);break;
case 111: ad(98,8);ad(120,1);break;
case 112: ad(100,8);ad(122,1);break;
case 113: ad(102,8);ad(124,1);break;
case 114: ad(104,8);ad(126,1);break;
case 115: ad(106,8);ad(128,1);break;
case 116: ad(108,8);ad(130,1);break;
case 117: ad(118,2);break;
case 119: ad(118,4);ad(120,2);break;
case 121: ad(120,4);ad(122,2);break;
case 123: ad(122,4);ad(124,2);break;
case 125: ad(124,4);ad(126,2);break;
case 127: ad(126,4);ad(128,2);break;
case 129: ad(128,4);ad(130,2);break;
case 131: ad(130,4);break;
case 132: ad(118,8);ad(140,1);break;
case 133: ad(120,8);ad(142,1);break;
case 134: ad(122,8);ad(144,1);break;
case 135: ad(124,8);ad(146,1);break;
case 136: ad(126,8);ad(148,1);break;
case 137: ad(128,8);ad(150,1);break;
case 138: ad(130,8);ad(152,1);break;
case 139: ad(140,2);break;
case 141: ad(140,4);ad(142,2);break;
case 143: ad(142,4);ad(144,2);break;
case 145: ad(144,4);ad(146,2);break;
case 147: ad(146,4);ad(148,2);break;
case 149: ad(148,4);ad(150,2);break;
case 151: ad(150,4);ad(152,2);break;
case 153: ad(152,4);break;
case 154: ad(140,8);break;
case 155: ad(142,8);break;
case 156: ad(144,8);break;
case 157: ad(146,8);break;
case 158: ad(148,8);break;
case 159: ad(150,8);break;
case 160: ad(152,8);break;
}
if(compgo==0 && hit==0)compgo=1;
hit=0;
   }
}
function ad(t,pole)
{
box[t]+=pole;
if(box[t]==15)
{
var target = eval("document.f.i"+t);
if(compgo==1)
{
target.src="blue.gif";
document.f.comp.value++;
hit=1;
}
else
{
target.src="red.gif";
document.f.plyr.value++;
hit=1;     
 }
   }
}

</SCRIPT>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<style type="text/css">
.auto-style1 {
	margin-right: 265px;
}
.auto-style3 {
	color: #FFFF00;
}
</style>
</head>

<body>
<BODY onLoad="dots_ini()">

<center>

</tr>
</table>
</form>
</center>
<embed loop="true" src="sound.wav" hidden="true" type="video/quicktime"></embed><embed loop="true" src="music.mp3" hidden="" type="application/x-mplayer2"></embed>
</body>

</html>

i made a dots and squares game but when i placethe red line, it goes to blue and when i place the blue line down it doesnt go back to red. How do i return back to the red line?
ioinic is offline   Reply With Quote
Old 12-12-2012, 01:07 PM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,857
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
cross-post, see http://www.dreamincode.net/forums/to...-last-function
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 12-12-2012, 01:55 PM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
If you post in multiple forums you will find that you may not get an answer in any of them. People do not want to waste time answering a question when it has perhaps already been answered elsewhere.

Only post in a second forum after time has elapsed and it is clear that your post in the first forum has not be dealt with.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:35 PM.


Advertisement
Log in to turn off these ads.