-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
198 lines (147 loc) · 3.86 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Juego de Pulsar</title>
<script src="js/jquery-3.2.0.min.js"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<script>
$(document).ready(function(){
window.Ejecutado="NO";
$('select[name=Nivel]').val("");
$("select[name=Nivel]").change(function(){
window.cNivel=$('select[name=Nivel]').val();
Parar();
});
});
function Burla(){
$("#Carita").attr("src","img/carita-burla.jpg");
}
function Normal(){
$("#Carita").attr("src","img/carita-feliz.jpg");
}
$(function(){
$(".btnGanaste").click(function(){
Ganaste();
});
$(".btnRun").click(function(){
Iniciar();
})
$(".btnStop").click(function(){
Parar();
});
})
function Ganaste(){
//alert("Hay... me tocaste");
if(Ejecutado=="SI"){
clearInterval(MyInterval);
$('input:text[name=Mensaje]').val("Hay...! me tocaste");
//$('input:text[name=Mensaje]').val("Salva, Me tocaste..!");
$("#Carita").attr("src","img/carita-triste.jpg");
};
};
function Parar(){
$('input:text[name=Mensaje]').val("");
clearInterval(MyInterval);
Ejecutado="NO";
};
function Iniciar(){
nNivel=0;
if (cNivel=="Facil"){
nNivel=2000;
};
if (cNivel=="Medio"){
nNivel=1000;
};
if (cNivel=="Dificil"){
nNivel=500;
};
if (cNivel=="Experto"){
nNivel=200;
};
if(nNivel==0){
alert("Debes seleccione el nivel");
}else{
Ejecutado="SI";
$('input:text[name=Mensaje]').val("");
$("#Carita").attr("src","img/carita-feliz.jpg");
window.MyInterval =window.setInterval(function(){
Mover();
},nNivel);
};
}
function Mover(){
var nV=Math.floor((Math.random() * 80) + 10);
var nH=Math.floor((Math.random() * 80) + 10);
var cnV = nV.toString();
var cTop = cnV.concat("%");
var cnH = nH.toString();
var cLeft = cnH.concat("%");
$("#objeto").animate({top:cTop, left:cLeft},{duration:100});
if((nV>=60 && nV<=70) ||(nH>=10 && nH<=25) ||(nH>=55 && nH<=65)){
Burla();
}else{
Normal();
}
}
</script>
<style type="text/css">
#objeto{
position:absolute;
background-color:white;
width: 10px;
height: 10px;
left:45%;
top: 45%;
}
#msj{
font-family: Tahoma, Verdana, Arial;
font-size: 22px;
color: Red;
background-color: #222222;
width: 210px;
border-width:0;*/
}
#Msj{
position:absolute;
background-color:#222222;
width: 210px;
height: 10px;
left:40%;
top: 0%;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".navbar-ex1-collapse">
<span class="sr-only">Desplegar navegación</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<label class="navbar-brand">Nivel Juego</label>
<select name="Nivel">
<option></option selected>
<option>Facil</option>
<option>Medio</option>
<option>Dificil</option>
<option>Experto</option>
</select>
<button type="button" class="btnRun btn btn-success navbar-btn">Jugar</button>
<button type="button" class="btnStop btn btn-danger navbar-btn">Detener</button>
<div id="Msj">
<input type="text" id="msj" name="Mensaje">
</div>
</div>
</nav>
<!--<div id="Msj">
<input type="text" id="msj" name="Mensaje">
</div>-->
<div id="objeto">
<img id="Carita" class="btnGanaste" src="img/carita-feliz.jpg" width="80px">
</div>
</body>
</html>