други помогите. накаазали на работе за безделье. сказали написать шашки на javascript можно использовать jquery . есть какие идеи как это делается
так мне не ссылка надо. скопипастить я и сам могу. мне бы идей как реализовать. а если лезть в чужой код то получится плагиат. а мне это дали чтобы я в javascript разобрался
помогите найти ошибку. короче в функции change_turn меняется переменная valid_turn на противоположную но к 96 строке alert("valid_turn=1"+valid_turn); она снова = green; что такое ? HTML: <script type="text/javascript"> var color_shashki; var validni_hod; var enemy_color; var valid_turn ; var turn = true; //////////////////////////////// autoload $(function() { alert("proverka"); valid_turn = "green"; rows= $("tr"); $.each(rows,function(){ if ($(this).hasClass("row8") || $(this).hasClass("row7") || $(this).hasClass("row6")){ var s_fishkoi = $(this).children(); $.each(s_fishkoi,function(){ if( $(this).hasClass("striped")){ $(this).html("<img src="+"images/red.bmp"+" >"); } } );}}); $.each(rows,function(){ if ($(this).hasClass("row1") || $(this).hasClass("row2") || $(this).hasClass("row3")){ var s_fishkoi = $(this).children(); $.each(s_fishkoi,function(){ if( $(this).hasClass("striped")){ $(this).html("<img src="+"images/green.bmp"+">"); } } );}}); $("td").bind("click",check_chess); $("#turn").bind("click",change_turn); }); ////////////////////////////////////////////////////////// check_shess function check_chess() { shashka = $(this).find("img"); color = $(this).find("img").attr("src"); if (shashka.length > 0) { if (color == "images/green.bmp") {color_shashki = "green"; } if(color == "images/red.bmp") { color_shashki = "red"; } alert("color"+color_shashki); alert("valid_turn=1"+valid_turn); if (color_shashki != valid_turn){alert("hodit"+valid_turn);turn=false;} if (color_shashki == valid_turn){turn = true;} hod_shashka = true; start_line = $(this).attr("line"); start_number = $(this).attr("number"); } if (shashka.length == 0) { end_line = $(this).attr("line"); end_number = $(this).attr("number"); hod_pole =true; } if (hod_shashka == true && hod_pole ==true ){ hod_shashka=false; hod_pole=false; if (turn == false){alert("hodit+1"+valid_turn);} if (turn == true){ if (check_move(start_line,start_number,end_line,end_number,color_shashki)==false) { if ( atack(start_line,start_number,end_line,end_number,color_shashki)==false) {alert("ataki ne bilo");} }} } } //////////////////////////////////////////check_move function check_move(start_line,start_number,end_line,end_number,color_shashki) { if (color_shashki == "green") { check_line = end_line - start_line; if(check_line ==1 ){ line = true; } else{line = false} number = end_number - start_number; if(number ==1 || number==-1 ){number = true;} if ((line == true) && (number == true)){ hod = false; pole_start = $("td.striped[number="+start_number+"][line="+start_line+"]"); shashke_torba = $(pole_start).find("img"); $(shashke_torba).remove(); pole_end = $("td.striped[number="+end_number+"][line="+end_line+"]"); $(pole_end).html("<img src="+"images/green.bmp"+">"); validni_hod = true; hod = false; return true; } else {return false;} } if (color_shashki == "red"){ check_line = end_line - start_line; if(check_line ==-1 ){ line = "valid"; } else{line = "invalid"} number = end_number - start_number; if(number ==1 || number==-1 ){number = "valid";} else{number="invalid";} if ((line == "valid") && (number == "valid")){ hod = false; pole_start = $("td.striped[number="+start_number+"][line="+start_line+"]"); shashke_torba = $(pole_start).find("img"); $(shashke_torba).remove(); pole_end = $("td.striped[number="+end_number+"][line="+end_line+"]"); $(pole_end).html("<img src="+"images/red.bmp"+">"); validni_hod = true; hod = false; return true; } else {return false;} } } function atack (start_line,start_number,end_line,end_number,color_shashki) { check_line = end_line - start_line; if(check_line ==2 || check_line == -2 ){ line = true; } else{line = false} number = end_number - start_number; if(number ==2 || number==-2 ){number = true;} else{number=false;} if ((line == true) && (number == true)){ if(check_checker(end_line,end_number,start_line,start_number,color_shashki)==false){ return false; } } } function check_checker(end_line,end_number,start_line,start_number,color_shashki) { if (end_line > start_line){ line = end_line*1-1; } if (end_line < start_line) { line = end_line*1+1;} if (start_number > end_number){number = end_number*1+1;} if (start_number < end_number){number = end_number*1-1;} enemy_checker =$("td.striped[number="+number+"][line="+line+"]").find("img"); if( $(enemy_checker).length > 0){ enemy_color = $(enemy_checker).attr("src"); if (enemy_color == "images/green.bmp") {enemy_color = "green"; } if(enemy_color == "images/red.bmp") { enemy_color = "red"; } if (enemy_color != color_shashki) { $("td.striped[number="+number+"][line="+line+"]").find("img").remove(); $("td.striped[number="+start_number+"][line="+start_line+"]").find("img").remove(); pole_end = $("td.striped[number="+end_number+"][line="+end_line+"]"); $(pole_end).html("<img src="+"images/"+color_shashki+".bmp"+">"); return true; }} return false; } function change_turn (){ if (valid_turn == "green"){ alert(valid_turn); valid_turn = "red"; alert(valid_turn);} if(valid_turn == "red"){valid_turn = "green"; } }
прикол . так оно же сразу во второй if заходит и обратно ее меняет. Надо через switch делать. 2 zheneck - не уволят. просто только устроился и пока не хватает скила по javascript php вроде знаю и javascript не особо. а тут серьезные проэкты. так дали так сказать прокачатся чтобы больше заданий можно было на меня записывать.
подскажите почему не зацикливается цикл. Code: do { alert("otladka"); alert("i="+i); alert("j="+j); alert("end_line="+end_line); alert("end_number"+end_number); if (est_shashka == true){alert("break");break;} pole = $("td.striped[number="+j+"][line="+i+"]"); alert(pole); i--; j--; if (have_freind(pole,color_shashki) == false){est_shashka == true;alert("stoit shashka");} } while (i > end_line && j > end_number) и если написать Code: while (i < end_line && j > end_number){ if (est_shashka == true){break;} pole = $("td.striped[number="+j+"][line="+i+"]"); i++; j--; if (have_freind (pole,color_shashki) == false){est_shashka == true;} } тоже не зацикливается. Code: alert("i="+i); alert("j="+j); alert("end_line="+end_line); alert("end_number"+end_number); выдает нормальные значения. но функция have_freind() не вызывается. оно один раз выводит алерты и все. alert есть шашка не выводится
пипец я слепой. там написано if (have_friend() == false){est_shashka ==true} а надо est_shashka = true;
то maiko. ссылки нету. давно себе сайт хочу завести. но каждый раз меняются планы. сначала просто хотел html выучил html захотел cms на php написать. выучил php захотел на zend cms написать. вот сейчас учу англ чтобы доки по зенду читать. так что если интересно то только по почте