-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
160 lines (142 loc) · 5.23 KB
/
script.js
File metadata and controls
160 lines (142 loc) · 5.23 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
/* BLUEPRINT-JS-START */
// 🚀 Auto-generado para python: 4/29/2026, 12:29:10 PM
'use strict';
console.log('✅ 10 funciones y 0 clases detectadas');
// Funciones interactivas
function demo_distanceto() {
console.log('▶️ Ejecutando: distanceto()');
alert('Función distanceto() ejecutada');
}
function demo_MUSIC_SETUP() {
console.log('▶️ Ejecutando: MUSIC_SETUP()');
alert('Función MUSIC_SETUP() ejecutada');
}
function demo_load_svg() {
console.log('▶️ Ejecutando: load_svg()');
alert('Función load_svg() ejecutada');
}
function demo_player() {
console.log('▶️ Ejecutando: player()');
alert('Función player() ejecutada');
}
function demo_constrain() {
console.log('▶️ Ejecutando: constrain()');
alert('Función constrain() ejecutada');
}
function demo_respawnEnemy() {
console.log('▶️ Ejecutando: respawnEnemy()');
alert('Función respawnEnemy() ejecutada');
}
function demo_enemy() {
console.log('▶️ Ejecutando: enemy()');
alert('Función enemy() ejecutada');
}
function demo_playerLaser() {
console.log('▶️ Ejecutando: playerLaser()');
alert('Función playerLaser() ejecutada');
}
function demo_draw_text() {
console.log('▶️ Ejecutando: draw_text()');
alert('Función draw_text() ejecutada');
}
function demo_draw_text() {
console.log('▶️ Ejecutando: draw_text()');
alert('Función draw_text() ejecutada');
}
// 🎮 Motor de Juego Pro (BluePrint Engine)
const Game = {
canvas: null, ctx: null, lastTime: 0, score: 0, active: true,
init() {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
document.querySelector('.container').appendChild(this.canvas);
this.resize();
window.addEventListener('resize', () => this.resize());
console.log('🎮 Motor iniciado. Preparando ciclo de juego...');
this.loop(0);
},
resize() {
this.canvas.width = 600; this.canvas.height = 400;
},
update(dt) {
if (!this.active) return;
// Lógica de juego aquí
},
render() {
const { ctx, canvas } = this;
ctx.fillStyle = '#1a1a2e'; ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#00f7ff'; ctx.font = '20px Arial';
ctx.fillText('Score: ' + this.score, 20, 30);
},
loop(time) {
const dt = time - this.lastTime; this.lastTime = time;
this.update(dt); this.render();
requestAnimationFrame((t) => this.loop(t));
},
saveScore() {
if (window.MockServer) {
MockServer.save('highscores', { score: this.score, date: new Date().toLocaleDateString() });
}
}
};
document.addEventListener('DOMContentLoaded', () => Game.init());
// 🧬 Servidor Universal de Datos (Multi-Use)
window.MockServer = {
save(collection, data) {
const items = JSON.parse(localStorage.getItem(collection) || '[]');
items.push({ ...data, id_uuid: Math.random().toString(36).substr(2, 9) });
localStorage.setItem(collection, JSON.stringify(items));
console.log('📁 Guardado en ['+collection+']:', data);
if (window.AdminConsole) AdminConsole.refresh();
},
get(collection) {
return JSON.parse(localStorage.getItem(collection) || '[]');
},
delete(collection, id) {
const items = this.get(collection).filter(i => i.id_uuid !== id);
localStorage.setItem(collection, JSON.stringify(items));
if (window.AdminConsole) AdminConsole.refresh();
},
clear(collection) {
localStorage.removeItem(collection);
if (window.AdminConsole) AdminConsole.refresh();
}
};
// 🛠️ Consola de Administración Visual
window.AdminConsole = {
isOpen: false,
init() {
const btn = document.createElement('div');
btn.id = 'admin-btn'; btn.innerHTML = '🛠️';
btn.onclick = () => this.toggle();
document.body.appendChild(btn);
const panel = document.createElement('div');
panel.id = 'admin-panel';
panel.innerHTML = '<h3>🛠️ Admin Console</h3><div id="admin-content"></div><button onclick="AdminConsole.toggle()">Cerrar</button>';
document.body.appendChild(panel);
this.refresh();
},
toggle() {
this.isOpen = !this.isOpen;
document.getElementById('admin-panel').style.display = this.isOpen ? 'block' : 'none';
},
refresh() {
const content = document.getElementById('admin-content');
if (!content) return;
let html = '';
const collections = ['orders', 'highscores', 'logs', 'users'];
collections.forEach(c => {
const data = MockServer.get(c);
if (data.length > 0) {
html += '<h4>'+c.toUpperCase()+' ('+data.length+')</h4><table>';
data.slice(-5).forEach(i => {
html += '<tr><td>'+JSON.stringify(i).substr(0,40)+'...</td><td><button onclick="MockServer.delete(\''+c+'\', \''+i.id_uuid+'\')">🗑️</button></td></tr>';
});
html += '</table>';
}
});
content.innerHTML = html || '<p>Esperando datos...</p>';
}
};
document.addEventListener('DOMContentLoaded', () => AdminConsole.init());
/* BLUEPRINT-JS-END */