-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainAdvanced.js
More file actions
31 lines (27 loc) · 1.26 KB
/
mainAdvanced.js
File metadata and controls
31 lines (27 loc) · 1.26 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
import { Engine, LevelHandler } from "./Root/Engine.js";
import { Screen } from "./Window/Screen.js";
import { Input } from "./Input/Input.js";
import { AssetManager } from "./Root/AssetManager.js";
import { AdvancedDemoLevel } from "./DemoAdvanced/AdvancedDemoLevel.js";
try {
new Input();
const screen = new Screen("gameCanvas", 800, 600);
// 1. Instancia o Preloader
const assets = new AssetManager();
// 2. Coloca os recursos na fila (usando caminhos fake, como você pediu)
// assets.QueueImage("heroi_run", "DemoAdvanced/Assets/Run.png");
// assets.QueueImage("heroi_idle", "DemoAdvanced/Assets/Idle.png");
assets.QueueImage("hero", "DemoAdvanced/Assets/Hero.png");
assets.QueueImage("tiro_laser", "DemoAdvanced/Assets/Laser.png");
assets.QueueImage("background", "DemoAdvanced/Assets/background.jpg");
// 3. Aguarda o download de tudo ANTES de iniciar a Engine
assets.LoadAll().then(() => {
LevelHandler.addLevel(new AdvancedDemoLevel(screen));
Engine.OnStart();
console.log("GameForgeJS: Todos os assets carregados e Engine iniciada!");
}).catch(err => {
console.error("Erro fatal ao carregar os assets:", err);
});
} catch(exception) {
console.error(`Exception: ${exception}`);
}