-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
31 lines (25 loc) · 1.11 KB
/
init.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
//NOTE: everything jiska object onetime banana hai, wo inital load mai banadena aur window.XYZ mai rakh dena
window.addEventListener("load", async () => {
const SUPABASE_URL = "https://ddctemysdgslailkedsw.supabase.co";
const SUPABASE_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRkY3RlbXlzZGdzbGFpbGtlZHN3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTY5NjI4NzYsImV4cCI6MjAzMjUzODg3Nn0.eqTP9vbO-JnyF42oZuf4EMUwOXbTT9pgqRb2uH21X_U";
const _supabase = supabase.createClient(SUPABASE_URL, SUPABASE_KEY);
const {
data: { session },
} = await _supabase.auth.getSession();
if (session) {
const userId = session.user.id;
const overworld = new Overworld({
element: document.querySelector(".game-container"),
});
const pauseMenu = new PauseMenu({ overworld, supabase: _supabase, userId });
window.pauseMenu = pauseMenu;
pauseMenu.init();
const titleScreen = new TitleScreen({overworld : overworld, pauseMenu: pauseMenu});
titleScreen.createMenu();
}
else {
console.error("User is not authenticated.");
window.location.href = "index.html";
}
});