-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsIndex.js
More file actions
321 lines (260 loc) · 11.2 KB
/
Copy pathjsIndex.js
File metadata and controls
321 lines (260 loc) · 11.2 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*window.alert('Puedes perder algo si no abres los ojos antes de que sea tarde');*/
//prompt("Puedes perder algo si no abres los ojos antes de que sea tarde. Ingrese una fecha ?/?/23");
//IMPORTE DE FUNCIONES
import { funcGene } from "./Scripts/functions.js";
//COLOCAR VIDEO ALEATORIO
setTimeout(funcGene.fondoAleatorio, 1);
//COLOCAR MUSICA ALEATORIO
/*document.addEventListener("DOMContentLoaded", () => {
console.log("funcionando"),
setTimeout(funcGene.musicAleatorie, 1000);
});
setTimeout(funcGene.musicAleatorie, 1000);*/
var cantidadCanciones = 19;
document.addEventListener("DOMContentLoaded", function () {
const audio = document.getElementById('audio');
let primeraReproduccion = true;
const botonReproducir = document.getElementById('reproducir');
const botonPausar = document.getElementById('pausar');
const botonCambiar = document.getElementById('cambiar');
let indice = Math.floor(Math.random() * cantidadCanciones);
function musicAleatorie() {
audio.src = `./Musica/${indice}.mp3`;
console.log("Música lista");
}
function reproducirAudioAleatorio() {
if (primeraReproduccion) {
musicAleatorie();
audio.play().catch(error => {
console.error('Error al reproducir audio:', error);
});
primeraReproduccion = false;
// Desvincula el event listener después de la primera reproducción
document.body.removeEventListener('click', reproducirAudioAleatorio);
}
}
function pausarCancion() {
audio.pause();
}
function reproducirCancion() {
audio.play();
}
function cambiarCancion() {
indice++;
if(indice > 19){
indice = 0;
}
audio.src = `./Musica/${indice}.mp3`;
}
botonPausar.addEventListener('click', pausarCancion);
botonReproducir.addEventListener('click', reproducirCancion);
botonCambiar.addEventListener('click', cambiarCancion);
// Vincula la función a cualquier clic en el body
//document.body.addEventListener('click', reproducirAudioAleatorio);
// window.alert('Tercer y penúltimo bucle listo. ¿El lunes habrá ganador?');
document.addEventListener('click', reproducirAudioAleatorio);
document.addEventListener('keydown', reproducirAudioAleatorio);
document.addEventListener('touchstart', reproducirAudioAleatorio);
document.addEventListener('mousemove', reproducirAudioAleatorio);
});
/*setTimeout(() => {
window.alert('Ya se subió la segunda parte.');
}, 1000);*/
const typed = new Typed('.typed', {
strings: ['INVITACIÓN <br> NAUGES DREAMS'],
typeSpeed: 75,
cursorChar: '|',
loop: false
});
const HayNove = new Typed('.aviso', {
strings: ['¿Qué va a pasar con esta página?'],
typeSpeed: 102,
cursorChar: '',
loop: true
});
/*let ocultNov = document.getElementById('novedades');
ocultNov.addEventListener('click', ocultarNovedades);*/
/*let ocultNoved = document.getElementById('ocultarnovedades');
ocultNoved.addEventListener('click', ocultarNovedades)*/
//FUNCIONES BOTONES OJOS
//BOTON UNO
var botonuno = document.getElementById('boton1');
botonuno.addEventListener('click', () => {
window.location.replace('https://youtu.be/z3TJPyHqadY?si=NBADVz1DGwX3ivL9');
});
//BOTON DOS
var botondos = document.getElementById('boton3');
botondos.addEventListener('click', () => {
window.open('https://www.youtube.com/watch?v=1Q76EGUcvRY&list=PLSGlwi2i3KJbPzGiiblXIxLW9zh6jiW8e&index=1&ab_channel=UniversidadCES');
});
//FUNCION ALTERNAR TEXTO
document.addEventListener("DOMContentLoaded", function () {
const boton = document.getElementById("boton2");
let alternar = true;
function cambiarContenidoBoton() {
// Utiliza el operador ternario para simplificar el código
boton.classList.add("transicion"); // Agrega la clase de transición
boton.innerHTML = alternar ? '<i class="fa-solid fa-circle-play"></i>' : 'Play';
// Utiliza setTimeout para eliminar la clase después de la transición
setTimeout(function () {
boton.classList.remove("transicion");
}, 300);
alternar = !alternar;
}
// Utiliza una función arrow en lugar de una función anónima
setInterval(cambiarContenidoBoton, 1500);
});
//FUNCION AVISO DEL JUEGO
function infoJuego() {
console.log("funciona");
/*let aviso = document.getElementById('novedades');
aviso.style.display = 'flex';
setTimeout(() => { aviso.style.display = 'none'; }, 5000);*/
var contend = document.getElementById('ocultarnovedades');
var novedades = document.createElement('div');
novedades.classList.add('hayNovedad');
novedades.setAttribute('id', 'inforjuego');
contend.appendChild(novedades);
avisoNov.removeEventListener('click', mostrarNovedades);
avisoJuego.removeEventListener('click', infoJuego);
setTimeout(() => {
pistas = new Typed('.hayNovedad', {
strings: [' · Ten en cuenta: <br>· Esto va a cambiar, es mejor que no vuelvas. <br>· Debes tratar de entender. <br>· Quiero confesar muchas cosas.'],
typeSpeed: 30,
cursorChar: '',
loop: false,
onComplete: () => {
setTimeout(() => {
var contend = document.getElementById('ocultarnovedades');
var novedades = document.getElementById('inforjuego');
contend.removeChild(novedades);
/* avisoJuego.addEventListener('click', infoJuego); */
}, 2000)
/* setTimeout(() => {
window.location.href = "./Bucle1.html";
}, 2500); */
setTimeout( () => {
// Crear el div flotante
var floatingDiv = document.createElement('div');
floatingDiv.classList.add('floating-buttons');
// Crear botón Easy
var buttonEasy = document.createElement('div');
buttonEasy.setAttribute('id', 'botonEasy');
buttonEasy.innerText = 'Easy';
buttonEasy.addEventListener('click', function () {
// Acciones para el botón Easy
window.location.replace('./Bucle1.html'); // Reemplaza con la URL o acción deseada
});
// Crear botón Hard
var buttonHard = document.createElement('div');
buttonHard.setAttribute('id', 'botonHard');
buttonHard.innerText = 'Hard';
buttonHard.addEventListener('click', function () {
// Acciones para el botón Hard
/* window.location.href = "./Hard.html"; // Reemplaza con la URL o acción deseada */
window.alert('El modo HARD estará disponible después y serán las confesiones.');
});
// Agregar botones al div flotante
floatingDiv.appendChild(buttonEasy);
floatingDiv.appendChild(buttonHard);
// Agregar el div flotante al cuerpo del documento
document.body.appendChild(floatingDiv);
// Agregar event listener para cerrar el div al hacer clic fuera de él
document.addEventListener('click', closeFloatingDiv);
// Agregar event listener al botón avisoJuego
avisoNov.addEventListener('click', mostrarNovedades);
avisoJuego.addEventListener('click', infoJuego);
}, 2300)
}
})
}, 500)
}
function closeFloatingDiv(event) {
var floatingDiv = document.querySelector('.floating-buttons');
if (floatingDiv && !floatingDiv.contains(event.target)) {
// Si se hizo clic fuera del div flotante, eliminarlo
floatingDiv.parentNode.removeChild(floatingDiv);
// Volver a añadir la función al botón avisoJuego
// Eliminar el event listener para cerrar el div
document.removeEventListener('click', closeFloatingDiv);
}
}
var avisoJuego = document.getElementById('boton2');
avisoJuego.addEventListener('click', infoJuego);
//FUNCIÓN MOSTRAR NOVEDADES
var pistas;
function mostrarNovedades() {
avisoJuego.removeEventListener('click', infoJuego);
console.log("funciona");
/*let aviso = document.getElementById('novedades');
aviso.style.display = 'flex';
setTimeout(() => { aviso.style.display = 'none'; }, 5000);*/
var contend = document.getElementById('ocultarnovedades');
var novedades = document.createElement('div');
novedades.classList.add('hayNovedad');
novedades.setAttribute('id', 'novedades');
contend.appendChild(novedades);
avisoNov.removeEventListener('click', mostrarNovedades);
setTimeout(() => {
pistas = new Typed('.hayNovedad', {
strings: [' · naugesdreams.netlify.app <br>· Fecha: No sé aún <br>· Los OJOS pueden hablar.'],
typeSpeed: 30,
cursorChar: '',
loop: false,
onComplete: () => {
setTimeout(() => {
var contend = document.getElementById('ocultarnovedades');
var novedades = document.getElementById('novedades');
contend.removeChild(novedades);
avisoNov.addEventListener('click', mostrarNovedades);
avisoJuego.addEventListener('click', infoJuego);
}, 2000)
}
})
}, 1000)
}
var avisoNov = document.getElementById('aviso');
avisoNov.addEventListener('click', mostrarNovedades);
//FUNCIÓN MOVER IMAGENES
function moverObjeto(objeto, velocidadX, velocidadY) {
const limiteX = window.innerWidth - objeto.clientWidth;
const limiteY = window.innerHeight - objeto.clientHeight;
function mover() {
let posX = parseInt(getComputedStyle(objeto).left);
let posY = parseInt(getComputedStyle(objeto).top);
let nuevaPosX = posX + velocidadX;
let nuevaPosY = posY + velocidadY;
// Verificar límites en el eje X
if (nuevaPosX < 0 || nuevaPosX > limiteX) {
velocidadX *= -1; // Cambiar dirección en el eje X
}
// Verificar límites en el eje Y
if (nuevaPosY < 0 || nuevaPosY > limiteY) {
velocidadY *= -1; // Cambiar dirección en el eje Y
}
objeto.style.left = nuevaPosX + 'px';
objeto.style.top = nuevaPosY + 'px';
}
function cambiarDireccion() {
velocidadX = Math.random() > 0.5 ? Math.abs(velocidadX) : -Math.abs(velocidadX); // Cambiar dirección en el eje X
velocidadY = Math.random() > 0.5 ? Math.abs(velocidadY) : -Math.abs(velocidadY); // Cambiar dirección en el eje Y
}
// Mover el objeto cada 30 milisegundos (ajusta según tus preferencias)
setInterval(mover, 15);
// Cambiar dirección aleatoriamente cada 3000 milisegundos (3 segundos)
setInterval(cambiarDireccion, 2500);
}
const imagenMovil = document.getElementById('boton1');
moverObjeto(imagenMovil, 2, 5);
const imagenMovil2 = document.getElementById('boton3');
moverObjeto(imagenMovil2, 2, 3);
//FUNCIONES OJO MOVIL
const ojoMovil = document.getElementById('ojo-pizarra');
moverObjeto(ojoMovil, 1, 2);
ojoMovil.addEventListener('click', funcGene.abrirLinkAleatorio);
const ojito = new Typed('.ojo-pizarra', {
strings: ['Los', 'ojos', 'quieren', 'que', 'abras', 'los', 'ojos', 'para', 'ganar', 'eso', 'que', 'quieres'],
typeSpeed: 50,
cursorChar: '|',
loop: true
});