-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-wyzwanie_4.html
62 lines (54 loc) · 1.7 KB
/
10-wyzwanie_4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Wyzwania!!!</title>
</head>
<body>
<p>Wyzwanie 4, które polega na tyma aby napis poruszał się po obrębie kwadratu,<br/>przy każdym kliknięciu będzie przyśpieszał aż zdobędziesz 10 pkt</p>
<h1 id="naglowek">Wyzwanie 4</h1>
<p id="punkty"></p>
<script src="https://code.jquery.com/jquery-2.2.2.js"></script>
<script>
ruchNaglowkaLeft = 100;
ruchNaglowkaTop = 100;
punkty = 0;
predkosc = 10;
var wyzwanie2 = function () {
if (ruchNaglowkaLeft < 400 && ruchNaglowkaTop == 100) {
$("#naglowek").offset({ left: ruchNaglowkaLeft, top: ruchNaglowkaTop });
ruchNaglowkaLeft++;
}
else if (ruchNaglowkaLeft == 400 && ruchNaglowkaTop < 400) {
$("#naglowek").offset({ left: ruchNaglowkaLeft, top: ruchNaglowkaTop });
ruchNaglowkaTop++;
}
else if (ruchNaglowkaTop == 400 && ruchNaglowkaLeft > 100) {
$("#naglowek").offset({ left: ruchNaglowkaLeft, top: ruchNaglowkaTop });
ruchNaglowkaLeft--;
}
else if (ruchNaglowkaLeft == 100 && ruchNaglowkaTop > 100) {
$("#naglowek").offset({ left: ruchNaglowkaLeft, top: ruchNaglowkaTop });
ruchNaglowkaTop--;
}
}
var idNumerJeden = setInterval(wyzwanie2, predkosc);
$("#punkty").offset({ left: 100, top: 600});
var kliknij = function () {
++punkty;
--predkosc;
if (punkty < 10) {
clearInterval(idNumerJeden);
idNumerJeden = setInterval(wyzwanie2, predkosc);
$("#punkty").text("Zdobyłeś : " + punkty + " pkt");
}
else {
clearInterval(idNumerJeden);
$("#punkty").text("Zdobyłeś : 10 pkt");
$("#naglowek").text("WYGRAŁEŚ!!!");
}
}
$("#naglowek").click(kliknij);
</script>
</body>
</html>