Add fix snake
This commit is contained in:
parent
71c214561a
commit
af18120527
53
js/snake.js
53
js/snake.js
@ -1,5 +1,7 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var canvas = $("#myCanvas")[0];
|
var canvas = $("#myCanvas")[0];
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = canvas.getContext("2d");
|
||||||
var w = $("#myCanvas").width();
|
var w = $("#myCanvas").width();
|
||||||
@ -20,6 +22,13 @@ $(document).ready(function () {
|
|||||||
function stop(gameloop){
|
function stop(gameloop){
|
||||||
clearInterval(gameloop);
|
clearInterval(gameloop);
|
||||||
}
|
}
|
||||||
|
function getQuestionCouter(){
|
||||||
|
var questionCouter = localStorage.getItem("question_couter");
|
||||||
|
return questionCouter;
|
||||||
|
}
|
||||||
|
function setQuestionCouter(questionCouter){
|
||||||
|
localStorage.setItem("question_couter", questionCouter);
|
||||||
|
}
|
||||||
|
|
||||||
function getSessionScore(){
|
function getSessionScore(){
|
||||||
var sessionScore = localStorage.getItem("session_score");
|
var sessionScore = localStorage.getItem("session_score");
|
||||||
@ -55,6 +64,11 @@ $(document).ready(function () {
|
|||||||
localStorage.setItem("new_question",form);
|
localStorage.setItem("new_question",form);
|
||||||
$(this).closest('form').find("input[type=text]").val("");
|
$(this).closest('form').find("input[type=text]").val("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#option1').click(function(){
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$('#add_question').click(function(){
|
$('#add_question').click(function(){
|
||||||
var isHidden = localStorage.getItem('isHidden');
|
var isHidden = localStorage.getItem('isHidden');
|
||||||
@ -90,25 +104,31 @@ $(document).ready(function () {
|
|||||||
paint_cell(snake.x, snake.y, "green");
|
paint_cell(snake.x, snake.y, "green");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showGameOver() {
|
function showQuestionTask() {
|
||||||
|
|
||||||
var current = $('#current').text();
|
var current = $('#current').text();
|
||||||
$('#final').text(current);
|
$('#final').text(current);
|
||||||
$('#popup').fadeIn();
|
$('#popup').fadeIn();
|
||||||
$('#yes').click(function () {
|
$('.yes').click(function () {
|
||||||
if ($('#yes').is(':checked')) {
|
if ($('#yes').is(':checked')) {
|
||||||
$('#correct').fadeIn('slow');
|
$('#correct').fadeIn('slow');
|
||||||
$('#session').text(getSessionScore());
|
|
||||||
$('#no').attr('disabled','disabled').delay(1000);;
|
$('#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')){
|
if($('#no').is(':checked')){
|
||||||
$('#incorrect').fadeIn('slow');
|
$('#incorrect').fadeIn('slow');
|
||||||
$('#yes').attr('disabled','disabled').delay(1000);;
|
$('#yes').attr('disabled','disabled').delay(1000);;
|
||||||
$('#no').prop('checked', false);
|
$('#no').prop('checked', true);
|
||||||
localStorage.removeItem('session_score');
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -147,8 +167,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function check_borders() {
|
function check_borders() {
|
||||||
if (snake.x < 0 || snake.x > (w - cw) / cw || snake.y < 0 || snake.y > (h - cw) / cw) {
|
if (snake.x < 0 || snake.x > (w - cw) / cw || snake.y < 0 || snake.y > (h - cw) / cw) {
|
||||||
stop(gameloop);
|
console.log("sprawdzimy")
|
||||||
showGameOver();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,18 +180,22 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function check_food() {
|
function check_food() {
|
||||||
if (food.x == snake.x && food.y == snake.y) {
|
if (food.x == snake.x && food.y == snake.y) {
|
||||||
var current = parseInt($('#current').text());
|
// var current = parseInt($('#current').text());
|
||||||
current += 1;
|
// current += 1;
|
||||||
$('#current').text(current);
|
// $('#current').text(current);
|
||||||
checkScore(current);
|
// checkScore(current);
|
||||||
|
stop(gameloop);
|
||||||
|
showQuestionTask();
|
||||||
placeFood();
|
placeFood();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gameloop = start();
|
|
||||||
|
|
||||||
|
|
||||||
|
gameloop = start();
|
||||||
|
|
||||||
placeFood();
|
placeFood();
|
||||||
paint_cell(food.x, food.y, "grey");
|
paint_cell(food.x, food.y, "grey");
|
||||||
placeSnake();
|
placeSnake();
|
||||||
@ -197,7 +220,7 @@ $(document).ready(function () {
|
|||||||
} else if (key == "40") {
|
} else if (key == "40") {
|
||||||
snake.y += 1;
|
snake.y += 1;
|
||||||
d = "DOWN";
|
d = "DOWN";
|
||||||
} else if(key == "33"){
|
} else if(key == "32"){
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ body {
|
|||||||
background-color: grey;
|
background-color: grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#current, #highest, #session {
|
#current, #highest, #session, #question_couter {
|
||||||
font-size : 25px;
|
font-size : 25px;
|
||||||
color: black;
|
color: black;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -68,4 +68,4 @@ a {
|
|||||||
|
|
||||||
span {
|
span {
|
||||||
color : #FFFFFF;
|
color : #FFFFFF;
|
||||||
}
|
}
|
@ -21,8 +21,8 @@
|
|||||||
Odpowiedz na pytanie!
|
Odpowiedz na pytanie!
|
||||||
<br>
|
<br>
|
||||||
<p>Czy lubisz jablka?</p>
|
<p>Czy lubisz jablka?</p>
|
||||||
<input id="yes" type="radio" value="yes" name="yes_no">Tak<br>
|
<input class="yes" type="radio" value="option1" name="yes_no">odpowiedz1<br>
|
||||||
<input id="no" type="radio" value="no" name="yes_no">No<br>
|
<input class="no" type="radio" value="option2" name="yes_no">odpowiedz2<br>
|
||||||
<a type="submit" value="submit">
|
<a type="submit" value="submit">
|
||||||
<span id="correct">To jest dobra odpowiedz,<br> mozesz grac dalej!</span><br>
|
<span id="correct">To jest dobra odpowiedz,<br> mozesz grac dalej!</span><br>
|
||||||
<!-- <button id="continue_game">Ruszaj dalej!</button> -->
|
<!-- <button id="continue_game">Ruszaj dalej!</button> -->
|
||||||
@ -37,9 +37,7 @@
|
|||||||
Your browser does not support the canvas feature
|
Your browser does not support the canvas feature
|
||||||
</canvas>
|
</canvas>
|
||||||
<div id="score">
|
<div id="score">
|
||||||
<div>Current Score:<span id="current">0</span>
|
<div>Session Score:<span id="session">0</span>/<span id="question_couter">0</span>
|
||||||
</div>
|
|
||||||
<div>Session Score:<span id="session">0</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
18
wytyczne.txt
18
wytyczne.txt
@ -1,5 +1,19 @@
|
|||||||
- obsluga bledu, gdzie nie ma gry,
|
- obsluga bledu, gdzie nie ma gry,
|
||||||
- zjadam muche mam pytanie, jak odpowiem to dostane punkt, jak wpadne w sciane strata punktu,(poprawic mechanike snejka,
|
|
||||||
- wyglad(głowna i strona snejka),
|
- wyglad(głowna i strona snejka),
|
||||||
- pacman(jak zjada to jest pytanie),
|
- pacman(jak zjada to jest pytanie),
|
||||||
- baza danych juz nie,
|
- 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