Skip to content

Commit

Permalink
New extra levels, remoteDB query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
n3me5is-git authored Sep 6, 2024
1 parent 27ec5a0 commit c8bd836
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
Binary file added background-level-catcountry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added background-level-christmas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified background-level-superhero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added background-music-catcountry.mp3
Binary file not shown.
Binary file added background-music-christmas.mp3
Binary file not shown.
57 changes: 55 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ background_canvas.width = canvas.width;
RDBprojectId = "parrotsfeast-jvt3";
RDBcollectionId = "scores";
RDBapiKey = "fe574739-1bc8-43b2-93ea-79f92c3e15a5";
remoteDB = true; // codehooks.io
remoteDB = true; // codehooks.io - Può essere modificato con ?remoteDB=true/false

// Impostazioni di gioco inglobate direttamente nel codice
const default_settings = {
Expand Down Expand Up @@ -244,6 +244,26 @@ const levels = {
}
}
},
14: {
background: 'background-level-catcountry.png',
music: 'background-music-catcountry.mp3',
extraLevelCode: 'E4',
settings: {
seed: {
difficulty: 6
}
}
},
15: {
background: 'background-level-christmas.png',
music: 'background-music-christmas.mp3',
extraLevelCode: 'E5',
settings: {
seed: {
difficulty: 6
}
}
},
};

const base_game_end_level = 10; // Tutti i livelli dopo il 10 sono Extra
Expand Down Expand Up @@ -2244,7 +2264,7 @@ function initGame() {
ctx.font = 'bold 18px Bosk, Georgia, sans-serif';
ctx.fillText(`LV. ${game.selectedLevel}`, 353, 313);
} else {
ctx.font = 'bold 14px Bosk, Georgia, sans-serif';
ctx.font = 'bold 15px Bosk, Georgia, sans-serif';
ctx.fillText(`EL. ${levels[game.selectedLevel].extraLevelCode}`, 353, 310);
}

Expand Down Expand Up @@ -2617,6 +2637,36 @@ function initGame() {
}


// Funzione per ottenere il valore del query parameter
function getQueryParameter(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}


// Funzione per leggere, aggiornare e memorizzare remoteDB
function initializeRemoteDB() {
// Leggi il query parameter 'remoteDB' dall'URL
const remoteDBParam = getQueryParameter('remoteDB');
if (remoteDBParam !== null) {
// Se presente nell'URL, usa il valore del query parameter
remoteDB = remoteDBParam === 'true'; // Converte il valore in booleano
// Memorizza nel localStorage per usi futuri
localStorage.setItem('remoteDB', remoteDB);
} else {
// Se non presente, verifica nel localStorage
const storedRemoteDB = localStorage.getItem('remoteDB');
if (storedRemoteDB !== null) {
// Usa il valore memorizzato nel localStorage
remoteDB = storedRemoteDB === 'true';
}
// Altrimenti mantieni il valore di default
}
console.log('RemoteDB:', remoteDB);
}



function checkOrientationAndActivateFullscreen() {
if (orientationCheckDone) return true; // Se il check è già stato fatto, esce dalla funzione
orientationCheckDone = true; // Imposta il flag per evitare che la funzione venga eseguita di nuovo
Expand Down Expand Up @@ -2684,6 +2734,9 @@ function initGame() {
}


// Chiama la funzione per inizializzare remoteDB al caricamento della pagina
initializeRemoteDB();

dbLoadDataExt(gameKey);

loadLocalSavedNickname();
Expand Down
8 changes: 6 additions & 2 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var CACHE_VERSION = 4;
var CACHE_VERSION = 5;
var CURRENT_CACHES = {
prefetch: 'parrots-feast-cache-v' + CACHE_VERSION,
ondemand: 'parrots-feast-cache-ondemand-v' + CACHE_VERSION
Expand Down Expand Up @@ -62,6 +62,8 @@ const urlsToPrefetch = [
'background-level-jurassic.png',
'background-level-artic.png',
'background-level-superhero.png',
'background-level-catcountry.png',
'background-level-christmas.png',
'background-music-arabia.mp3',
'background-music-armageddon.mp3',
'background-music-cityrio.mp3',
Expand All @@ -74,7 +76,9 @@ const urlsToPrefetch = [
'background-music-space.mp3',
'background-music-jurassic.mp3',
'background-music-artic.mp3',
'background-music-superhero.mp3'
'background-music-superhero.mp3',
'background-music-catcountry.mp3',
'background-music-christmas.mp3'
];

self.addEventListener('install', function(event) {
Expand Down

0 comments on commit c8bd836

Please sign in to comment.