1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-09-29 16:10:11 +02:00

game const

This commit is contained in:
Anthony Stirling 2024-02-18 09:21:30 +00:00
parent 51ad741744
commit 3a62d19979

View File

@ -26,14 +26,22 @@ function initializeGame() {
let highScore = localStorage.getItem("highScore") ? parseInt(localStorage.getItem("highScore")) : 0; let highScore = localStorage.getItem("highScore") ? parseInt(localStorage.getItem("highScore")) : 0;
updateHighScore(); updateHighScore();
const BASE_PDF_SPEED = 1;
const LEVEL_INCREASE_PDF_SPEED = 0.2;
const BASE_SPAWN_INTERVAL_MS = 1250; // milliseconds before a new enemy spawns
const LEVEL_INCREASE_FACTOR_MS = 25; // milliseconds to decrease the spawn interval per level
const MAX_SPAWN_RATE_REDUCTION_MS = 800; // Max milliseconds from the base spawn interval
const keysPressed = {}; const keysPressed = {};
const pdfs = []; const pdfs = [];
const projectiles = []; const projectiles = [];
let score = 0; let score = 0;
let level = 1; let level = 1;
let pdfSpeed = 0.5; let pdfSpeed = BASE_PDF_SPEED;
let gameOver = false; let gameOver = false;
function handleKeys() { function handleKeys() {
if (keysPressed["ArrowLeft"]) { if (keysPressed["ArrowLeft"]) {
playerX -= 10; playerX -= 10;
@ -188,7 +196,7 @@ function initializeGame() {
updateScore(); updateScore();
updateLives(); updateLives();
levelElement.textContent = "Level: " + level; levelElement.textContent = "Level: " + level;
pdfSpeed = 1; pdfSpeed = BASE_PDF_SPEED;
clearTimeout(spawnPdfTimeout); // Clear the existing spawnPdfTimeout clearTimeout(spawnPdfTimeout); // Clear the existing spawnPdfTimeout
setTimeout(updateGame, 1000 / 60); setTimeout(updateGame, 1000 / 60);
spawnPdfInterval(); spawnPdfInterval();
@ -204,7 +212,7 @@ function initializeGame() {
if (newLevel > level) { if (newLevel > level) {
level = newLevel; level = newLevel;
levelElement.textContent = "Level: " + level; levelElement.textContent = "Level: " + level;
pdfSpeed += 0.2; pdfSpeed += LEVEL_INCREASE_PDF_SPEED;
} }
} }
@ -227,9 +235,7 @@ function initializeGame() {
let spawnPdfTimeout; let spawnPdfTimeout;
const BASE_SPAWN_INTERVAL_MS = 1250; // milliseconds before a new enemy spawns
const LEVEL_INCREASE_FACTOR_MS = 0; // milliseconds to decrease the spawn interval per level
const MAX_SPAWN_RATE_REDUCTION_MS = 800; // Max milliseconds from the base spawn interval
function spawnPdfInterval() { function spawnPdfInterval() {
console.log("spawnPdfInterval"); console.log("spawnPdfInterval");