-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.js
74 lines (52 loc) · 1.35 KB
/
text.js
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
63
64
65
66
67
68
69
70
71
72
73
74
var value=50
var positionLeft=50
var positionTop=10
var count=0
var speedx=-0.5
var speedy=-0.5
var score=0
var e=0
$('#LEFT').click(function(){
$('#PIN').css('left',(value-3)+'%');
value=value-3;
});
$('#RIGHT').click(function(){
$('#PIN').css('left',(value+3)+'%');
value=value+3;
});
var storeTimeInterval=setInterval(function(){
if(positionLeft<=10)
{
speedx=-speedx;
$('#Ball').css('background-color','blue');
}
if(positionLeft>=90)
{
speedx=-speedx;
$('#Ball').css('background-color','green');
}
if(positionTop<=0)
{
speedy=-speedy;
$('#Ball').css('background-color','yellow');
}
if(positionTop==77){
alert("You lose");
alert("Your score: "+score);
clearInterval(storeTimeInterval);
}
if(positionTop==75&&positionLeft>=value-3&&positionLeft<=value+3){
if(positionLeft<=value){
e=value-positionLeft;
}
else{e=positionLeft-value;}
speedy=-speedy;
speedx=speedx+(e/3)*speedx;
$('#Ball').css('background-color','red');
score++;
}
$('#Ball').css('left',(positionLeft+speedx)+'%');
$('#Ball').css('top',(positionTop+speedy)+'%');
positionLeft=positionLeft+speedx;
positionTop=positionTop+speedy;
},50);