Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h2>Szachy</h2>
- <p id="text"></p>
- <p id="cyfry", style="position:absolute; left:0px ; top:88px"></p>
- <p id="chess"></p>
- <p id="text2"></p>
- <script>
- function game()
- {
- rysujSzachownice();
- document.getElementById("chess").innerHTML = " ";
- }
- // var update = setInterval(game,2000);
- //var update2 = setInterval(reset,2500);
- var szachownica = [
- ["czarnaWie", "czarnySko", "czarnyGon", "czarnyHet", "czarnyKro", "czarnyGon", "czarnySko", "czarnaWie"],
- ["czarnyPio", "czarnyPio", "czarnyPio", "czarnyPio", "czarnyPio", "czarnyPio", "czarnyPio", "czarnyPio"],
- ["_________", "_________", "_________", "_________", "_________", "_________", "_________", "_________"],
- ["_________", "_________", "_________", "_________", "_________", "_________", "_________", "_________"],
- ["_________", "_________", "_________", "_________", "_________", "_________", "_________", "_________"],
- ["_________", "_________", "_________", "_________", "_________", "_________", "_________", "_________"],
- ["bialyPion", "bialyPion", "bialyPion", "bialyPion", "bialyPion", "bialyPion", "bialyPion", "bialyPion"],
- ["bialaWiez", "bialySkoc", "bialyGoni", "bialyHetm", "bialyKrol", "bialyGoni", "bialySkoc", "bialaWiez"]];
- var text = "";
- //dziala, wszystkie miejsca mozna brac oddzielnie:
- //var text3 = szachownica[0][5];
- //document.getElementById("text3").innerHTML = text3;
- function rysujSzachownice()
- {
- for(var i=0; i<szachownica.length; i++)
- {
- text += szachownica[i] + "<pre>";
- }
- document.getElementById("chess").innerHTML = text;
- }
- function rysujSzachownice1()
- {
- for(var i=0; i<szachownica.length; i++)
- {
- text += szachownica[i] + "<pre>";
- }
- document.getElementById("chess").innerHTML = text;
- }
- function reset()
- {
- //document.getElementById("chess").innerHTML= " ";
- }
- document.getElementById("chess").style.fontFamily = "monospace";
- document.getElementById("cyfry").style.fontFamily = "monospace";
- //rysujSzachownice();
- var litery = '\xa0\xa0\xa0\xa0\xa0\xa0' + " a " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " b " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " c " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " d " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " e " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " f " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " g " + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + " h ";
- var liczby = " ";
- for(var i=9; i>1; i--)
- {
- liczby += (i-1) +"<pre>"
- }
- document.getElementById("text").innerHTML = litery ;
- document.getElementById("text2").innerHTML = litery;
- document.getElementById("cyfry").innerHTML = liczby;
- function ruszFigure()
- {
- var a = document.getElementById('ruch1a').value;
- var b = document.getElementById('ruch1b').value;
- var c = document.getElementById('ruch1c').value;
- var d = document.getElementById('ruch1d').value;
- var temp = szachownica[a][b];
- //ruch czarnego pionka:
- if(szachownica[a][b] == "czarnyPio")
- {
- if(szachownica[c][d] == "_________" && ( c == ( parseInt(a)+parseInt(1) ) && d == b) )
- {
- szachownica[c][d] = temp;
- szachownica[a][b] = "_________";
- } 1
- if( szachownica[c][d] != "_________"
- && ( c == ( parseInt(a)+parseInt(1) ) && d == ( parseInt(b)-parseInt(1) ) ) )
- {
- szachownica[c][d] = temp;
- szachownica[a][b] = "_________"
- }
- if( szachownica[c][d] != "_________"
- && ( c == ( parseInt(a)+parseInt(1) ) && d == ( parseInt(b)+parseInt(1) ) ) )
- {
- szachownica[c][d] = temp;
- szachownica[a][b] = "_________"
- }
- }
- // {
- // document.write("nie wybrales figury");
- // }
- }
- function pomocnicza()
- {
- var a = document.getElementById('ruch2c').value;
- var b = document.getElementById('ruch2d').value;
- if(a==0 || b==0)
- {
- document.write("blad");
- }
- else
- {
- document.write(a + "<br>");
- document.write( parseInt(a) + parseInt(1));
- //document.write("na pozycji [a][b]: ");
- //document.write(szachownica[a][b] + "<br>");
- //document.write("na pozycji [a+1][b]: ");
- //document.write(szachownica[a+1][b]);
- }
- }
- </script>
- <div id = "ruch">
- Ruch od:
- <input type="text" id="ruch1a" value=""/>
- <input type="text" id="ruch1b" value=""/>
- Ruch do:
- <input type="text" id="ruch1c" value=""/>
- <input type="text" id="ruch1d" value=""/>
- <button onclick="ruszFigure()">Wykonaj ruch</button>
- </div>
- <br>
- <div id = "ruch2">
- <input type="text" id="ruch2c" value=""/>
- <input type="text" id="ruch2d" value=""/>
- <button onclick="pomocnicza()">Try it</button>
- </div>
- <br>
- <div id = "check">
- <button onclick="rysujSzachownice1()">Szachownica</button>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement