Add fix snake
This commit is contained in:
parent
71c214561a
commit
af18120527
51
js/snake.js
51
js/snake.js
@ -1,5 +1,7 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
var canvas = $("#myCanvas")[0];
|
||||
var ctx = canvas.getContext("2d");
|
||||
var w = $("#myCanvas").width();
|
||||
@ -20,6 +22,13 @@ $(document).ready(function () {
|
||||
function stop(gameloop){
|
||||
clearInterval(gameloop);
|
||||
}
|
||||
function getQuestionCouter(){
|
||||
var questionCouter = localStorage.getItem("question_couter");
|
||||
return questionCouter;
|
||||
}
|
||||
function setQuestionCouter(questionCouter){
|
||||
localStorage.setItem("question_couter", questionCouter);
|
||||
}
|
||||
|
||||
function getSessionScore(){
|
||||
var sessionScore = localStorage.getItem("session_score");
|
||||
@ -56,6 +65,11 @@ $(document).ready(function () {
|
||||
$(this).closest('form').find("input[type=text]").val("");
|
||||
});
|
||||
|
||||
$('#option1').click(function(){
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#add_question').click(function(){
|
||||
var isHidden = localStorage.getItem('isHidden');
|
||||
if(isHidden === null){
|
||||
@ -90,25 +104,31 @@ $(document).ready(function () {
|
||||
paint_cell(snake.x, snake.y, "green");
|
||||
}
|
||||
|
||||
function showGameOver() {
|
||||
function showQuestionTask() {
|
||||
|
||||
var current = $('#current').text();
|
||||
$('#final').text(current);
|
||||
$('#popup').fadeIn();
|
||||
$('#yes').click(function () {
|
||||
$('.yes').click(function () {
|
||||
if ($('#yes').is(':checked')) {
|
||||
$('#correct').fadeIn('slow');
|
||||
$('#session').text(getSessionScore());
|
||||
$('#no').attr('disabled','disabled').delay(1000);;
|
||||
$('#yes').prop('checked', false);
|
||||
$('#yes').prop('checked', true);
|
||||
var sessionScore = getSessionScore();
|
||||
var questionCouter = getQuestionCouter();
|
||||
questionCouter++;
|
||||
sessionScore++;
|
||||
$('#question_couter').text(questionCouter);
|
||||
$('#session').text(sessionScore);
|
||||
setSessionScore(sessionScore);
|
||||
setQuestionCouter(questionCouter);
|
||||
}
|
||||
});
|
||||
$('#no').click(function(){
|
||||
$('.no').click(function(){
|
||||
if($('#no').is(':checked')){
|
||||
$('#incorrect').fadeIn('slow');
|
||||
$('#yes').attr('disabled','disabled').delay(1000);;
|
||||
$('#no').prop('checked', false);
|
||||
localStorage.removeItem('session_score');
|
||||
$('#no').prop('checked', true);
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -147,8 +167,7 @@ $(document).ready(function () {
|
||||
|
||||
function check_borders() {
|
||||
if (snake.x < 0 || snake.x > (w - cw) / cw || snake.y < 0 || snake.y > (h - cw) / cw) {
|
||||
stop(gameloop);
|
||||
showGameOver();
|
||||
console.log("sprawdzimy")
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,16 +180,20 @@ $(document).ready(function () {
|
||||
|
||||
function check_food() {
|
||||
if (food.x == snake.x && food.y == snake.y) {
|
||||
var current = parseInt($('#current').text());
|
||||
current += 1;
|
||||
$('#current').text(current);
|
||||
checkScore(current);
|
||||
// var current = parseInt($('#current').text());
|
||||
// current += 1;
|
||||
// $('#current').text(current);
|
||||
// checkScore(current);
|
||||
stop(gameloop);
|
||||
showQuestionTask();
|
||||
placeFood();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
gameloop = start();
|
||||
|
||||
placeFood();
|
||||
@ -197,7 +220,7 @@ $(document).ready(function () {
|
||||
} else if (key == "40") {
|
||||
snake.y += 1;
|
||||
d = "DOWN";
|
||||
} else if(key == "33"){
|
||||
} else if(key == "32"){
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ body {
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
#current, #highest, #session {
|
||||
#current, #highest, #session, #question_couter {
|
||||
font-size : 25px;
|
||||
color: black;
|
||||
text-align: center;
|
||||
|
@ -21,8 +21,8 @@
|
||||
Odpowiedz na pytanie!
|
||||
<br>
|
||||
<p>Czy lubisz jablka?</p>
|
||||
<input id="yes" type="radio" value="yes" name="yes_no">Tak<br>
|
||||
<input id="no" type="radio" value="no" name="yes_no">No<br>
|
||||
<input class="yes" type="radio" value="option1" name="yes_no">odpowiedz1<br>
|
||||
<input class="no" type="radio" value="option2" name="yes_no">odpowiedz2<br>
|
||||
<a type="submit" value="submit">
|
||||
<span id="correct">To jest dobra odpowiedz,<br> mozesz grac dalej!</span><br>
|
||||
<!-- <button id="continue_game">Ruszaj dalej!</button> -->
|
||||
@ -37,9 +37,7 @@
|
||||
Your browser does not support the canvas feature
|
||||
</canvas>
|
||||
<div id="score">
|
||||
<div>Current Score:<span id="current">0</span>
|
||||
</div>
|
||||
<div>Session Score:<span id="session">0</span>
|
||||
<div>Session Score:<span id="session">0</span>/<span id="question_couter">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
18
wytyczne.txt
18
wytyczne.txt
@ -1,5 +1,19 @@
|
||||
- obsluga bledu, gdzie nie ma gry,
|
||||
- zjadam muche mam pytanie, jak odpowiem to dostane punkt, jak wpadne w sciane strata punktu,(poprawic mechanike snejka,
|
||||
- obsluga bledu, gdzie nie ma gry,
|
||||
|
||||
- wyglad(głowna i strona snejka),
|
||||
- pacman(jak zjada to jest pytanie),
|
||||
- baza danych juz nie,
|
||||
|
||||
|
||||
|
||||
index.html:
|
||||
-popup z nickiem do gry,
|
||||
-zmienić icony (zamiast policji jakiś wąż, zamiast kina pacman),
|
||||
-wprawadzanie pytan z budynku(pop-up)
|
||||
-tablica wynik(opcjonlanie, pomyslec pozniej)
|
||||
-avatar(opcjonalnie),
|
||||
|
||||
snejk.html:
|
||||
|
||||
-przy wejsciu wyswietla sie pop-up z opisem gry(jak ona działa, klawiszami sterowania i przyciskiem start!),
|
||||
-zjadam muche mam pytanie, jak odpowiem to dostane punkt, jak wpadne w sciane strata punktu,(poprawic mechanike snejka,
|
Loading…
Reference in New Issue
Block a user