Quellcode
<SCRIPT type="text/javascript"> var rot = new Image;
rot.src = "rot.gif";
var gelb = new Image;
gelb.src = "gelb.gif";
var gruen = new Image;
gruen.src = "gruen.gif";
var orange = new Image;
orange.src = "orange.gif";
var braun = new Image;
braun.src = "braun.gif";
var blau = new Image;
blau.src = "blau.gif";
var weiss = new Image;
weiss.src = "weiss.gif";
var schwarz = new Image;
schwarz.src = "schwarz.gif";
var select = new Image;
select.src = "select.gif";
var leer = new Image;
leer.src = "transparent.gif"; var Kombination = new Array();
var tKombination_comp = new Array();
var tKombination_play = new Array(); var Spielfeld = new Array();
var Reihe,Spalte,tReihe,tSpalte; var aktuellesFeld = 11; var Zufall; var Zaehler,Zaehler2; var Runde = 1; var doppelt = 1; var Temp; var Ausgabe,Output; for (Zaehler = 0; Zaehler < 7; Zaehler++)
{
Spielfeld[Zaehler] = new Array("leer","leer","leer","leer");
} function Wechsel(welches,zuWelchem)
{
window.document.images[welches].src = zuWelchem.src;
} function newGame()
{ for (Zaehler = 0; Zaehler < 7; Zaehler++)
{
for (Zaehler2 = 0; Zaehler2 < 4; Zaehler2++)
{
Wechsel('R' + Zaehler + 'Z' + Zaehler2, leer);
Spielfeld[Zaehler][Zaehler2] = "leer";
}
for (Zaehler2 = 6; Zaehler2 < 10; Zaehler2++)
{
Wechsel('R' + Zaehler + 'Z' + Zaehler2, leer);
}
} window.document.getElementById('ergebnis').style.visibility = 'hidden'; Runde = 1;
window.document.getElementById('button0').style.visibility = 'visible';
window.document.getElementById('button1').style.visibility = 'hidden';
window.document.getElementById('button2').style.visibility = 'hidden';
window.document.getElementById('button3').style.visibility = 'hidden';
window.document.getElementById('button4').style.visibility = 'hidden';
window.document.getElementById('button5').style.visibility = 'hidden';
window.document.getElementById('button6').style.visibility = 'hidden'; Kombi_waehlen();
auswaehlen(11);
} function Farben()
{
Zufall = Math.random();
if (Zufall <= (1/6)) return "rot";
else if (Zufall <= (2/6)) return "orange";
else if (Zufall <= (3/6)) return "gelb";
else if (Zufall <= (4/6)) return "blau";
else if (Zufall <= (5/6)) return "braun";
else return "gruen";
} function Kombi_waehlen()
{ if (doppelt)
{
for (Zaehler = 0; Zaehler < 4; Zaehler++)
{
Kombination[Zaehler] = Farben();
}
} else
{
Kombination[0] = Farben();
while(1)
{
Kombination[1] = Farben();
if (Kombination[1] != Kombination[0]) break;
}
while(1)
{
Kombination[2] = Farben();
if ((Kombination[2] != Kombination[0]) &&
(Kombination[2] != Kombination[1])) break;
}
while(1)
{
Kombination[3] = Farben();
if ((Kombination[3] != Kombination[0]) &&
(Kombination[3] != Kombination[1]) &&
(Kombination[3] != Kombination[2])) break;
}
}
} function auswaehlen(Feld)
{
Reihe = Math.floor(Feld / 10) - 1; if (Reihe == Runde - 1)
{ tReihe = Math.floor(aktuellesFeld / 10) - 1;
tSpalte = aktuellesFeld % 10 - 1;
if (Spielfeld[tReihe][tSpalte] == "leer") Wechsel('R' + tReihe + 'Z' + tSpalte,leer); Spalte = (Feld % 10) - 1;
Wechsel('R' + Reihe + 'Z' + Spalte,select);
aktuellesFeld = Feld;
Spielfeld[Reihe][Spalte] = "leer";
}
} function einstecken(Farbe)
{
Reihe = Math.floor(aktuellesFeld / 10) - 1;
Spalte = (aktuellesFeld % 10) - 1;
Wechsel('R' + Reihe + 'Z' + Spalte,eval(Farbe));
Spielfeld[Reihe][Spalte] = Farbe;
} function checken(knopf)
{ if ((Spielfeld[knopf][0] != "leer") && (Spielfeld[knopf][1] != "leer") &&
(Spielfeld[knopf][2] != "leer") && (Spielfeld[knopf][3] != "leer"))
{ window.document.getElementById('button' + knopf).style.visibility = 'hidden';
Ausgabe = 1111;
for (Zaehler = 0; Zaehler < 4; Zaehler++)
{
tKombination_comp[Zaehler] = Kombination[Zaehler];
tKombination_play[Zaehler] = Spielfeld[knopf][Zaehler];
} Output = 6;
for (Zaehler = 0; Zaehler < 4; Zaehler++)
{
if (tKombination_play[Zaehler] == Kombination[Zaehler])
{
Ausgabe += (2 * Math.pow(10,Zaehler));
Wechsel('R' + knopf + 'Z' + Output,schwarz);
Output++;
tKombination_comp[Zaehler] = "leer";
tKombination_play[Zaehler] = "leer";
}
} for (Zaehler = 0; Zaehler < 4; Zaehler++)
{
if (tKombination_play[Zaehler] != "leer")
{
for (Zaehler2 = 0; Zaehler2 < 4; Zaehler2++)
{
if (tKombination_play[Zaehler] == tKombination_comp[Zaehler2])
{
Ausgabe += Math.pow(10,Zaehler);
Wechsel('R' + knopf + 'Z' + Output,weiss);
Output++;
tKombination_play[Zaehler] = "leer";
tKombination_comp[Zaehler2] = "leer";
break;
}
}
}
} if (Ausgabe == 3333) Ergebnis(); else if (knopf < 6)
{
window.document.getElementById('button' + (knopf + 1)).style.visibility = 'visible';
Runde++;
auswaehlen(eval(Runde + '1'));
}
else Ergebnis();
}
} function Ergebnis()
{
window.document.getElementById('ergebnis').style.visibility = 'visible';
for (Zaehler = 0; Zaehler < 4; Zaehler++)
{
Wechsel('E' + Zaehler,eval(Kombination[Zaehler]));
}
Runde = 10;
}
</SCRIPT> <TABLE>
<TR>
<TD>
<INPUT id="button6" type="button" value="OK" onClick="checken(6)">
</TD>
</TR>
<TR>
<TD>
<INPUT id="button5" type="button" value="OK" onClick="checken(5)">
</TD>
</TR>
<TR>
<TD>
<INPUT id="button4" type="button" value="OK" onClick="checken(4)">
</TD>
</TR>
<TR>
<TD>
<INPUT id="button3" type="button" value="OK" onClick="checken(3)">
</TD>
</TR>
<TR>
<TD>
<INPUT id="button2" type="button" value="OK" onClick="checken(2)">
</TD>
</TR>
<TR>
<TD>
<INPUT id="button1" type="button" value="OK" onClick="checken(1)">
</TD>
</TR>
<TR>
<TD>
<INPUT id=button"0" type="button" value="OK" onClick="checken(0)" style="visibility:visible">
</TD>
</TR>
</TABLE> <TABLE>
<TR>
<TD>
<IMG src="transparent.gif" name=R6Z8 alt="">
<IMG src="transparent.gif" name=R6Z9 alt="">
<BR>
<IMG src="transparent.gif" name=R6Z6 alt="">
<IMG src="transparent.gif" name=R6Z7 alt="">
</TD>
</TR>
<TR>
<TD>
<IMG src="transparent.gif" name=R5Z8 alt="">
<IMG src="transparent.gif" name=R5Z9 alt="">
<BR>
<IMG src="transparent.gif" name=R5Z6 alt="">
<IMG src="transparent.gif" name=R5Z7 alt="">
</TD>
</TR>
.
.
.
<TR>
<TD>
<IMG src="transparent.gif" name=R0Z8 alt="">
<IMG src="transparent.gif" name=R0Z9 alt="">
<BR>
<IMG src="transparent.gif" name=R0Z6 alt="">
<IMG src="transparent.gif" name=R0Z7 alt="">
</TD>
</TR>
</TABLE> <TABLE>
<TR>
<TD>
<IMG src="transparent.gif" name=R6Z0 alt="" onclick="auswaehlen(71)">
<IMG src="transparent.gif" name=R6Z1 alt="" onclick="auswaehlen(72)">
<IMG src="transparent.gif" name=R6Z2 alt="" onclick="auswaehlen(73)">
<IMG src="transparent.gif" name=R6Z3 alt="" onclick="auswaehlen(74)">
</TD>
</TR>
<TR>
<TD>
<IMG src="transparent.gif" name=R5Z0 alt="" onclick="auswaehlen(61)">
<IMG src="transparent.gif" name=R5Z1 alt="" onclick="auswaehlen(62)">
<IMG src="transparent.gif" name=R5Z2 alt="" onclick="auswaehlen(63)">
<IMG src="transparent.gif" name=R5Z3 alt="" onclick="auswaehlen(64)">
</TD>
</TR>
.
.
.
<TR>
<TD>
<IMG src="transparent.gif" name=R0Z0 alt="" onclick="auswaehlen(11)">
<IMG src="transparent.gif" name=R0Z1 alt="" onclick="auswaehlen(12)">
<IMG src="transparent.gif" name=R0Z2 alt="" onclick="auswaehlen(13)">
<IMG src="transparent.gif" name=R0Z3 alt="" onclick="auswaehlen(14)">
</TD>
</TR>
</TABLE> <TABLE id="ergebnis" style="visibility:hidden">
<TR>
<TD>
<IMG src="transparent.gif" name=E0 alt="">
<IMG src="transparent.gif" name=E1 alt="">
<IMG src="transparent.gif" name=E2 alt="">
<IMG src="transparent.gif" name=E3 alt="">
</TD>
</TR>
</TABLE> <FORM name="out" action="">
<INPUT type="button" onClick="newGame()" value="New Game"> <INPUT type="radio" checked onClick="doppelt = 1; newGame()" name="schalter"> yes/ja<BR>
<INPUT type="radio" onClick="doppelt = 0; newGame()" name="schalter"> no/nein</FORM> <A href="javascript:einstecken('rot')">
<IMG src="rot.gif" alt="" border="0">
</A>
<A href="javascript:einstecken('gelb')">
<IMG src="gelb.gif" alt="" border="0">
</A>
<A href="javascript:einstecken('gruen')">
<IMG src="gruen.gif" alt="" border="0">
</A>
<A href="javascript:einstecken('orange')">
<IMG src="orange.gif" alt="" border="0">
</A>
<A href="javascript:einstecken('braun')">
<IMG src="braun.gif" alt="" border="0">
</A>
<A href="javascript:einstecken('blau')">
<IMG src="blau.gif" alt="" border="0">
</A> <SCRIPT type="text/javascript">
Kombi_waehlen();
auswaehlen(11);
</SCRIPT> |