diff --git a/functions/functions.js b/functions/functions.js index 45630f2..4374cec 100644 --- a/functions/functions.js +++ b/functions/functions.js @@ -92,6 +92,17 @@ function mapReload() { setup(); } +// Go to the menu function toMenu() { - window.location.href = "./menu.html"; + window.location.href = "./index.html"; +} + +// Go to the level player! +function initiateLevelPlay() { + window.location.href = "./play.html"; +} + +// Go to the custom landing page! +function customLevelLoad() { + console.log('Here relies the custom level loader!'); } \ No newline at end of file diff --git a/functions/levelHandler.js b/functions/levelHandler.js index dd5cfe9..5ddd46b 100644 --- a/functions/levelHandler.js +++ b/functions/levelHandler.js @@ -32,7 +32,7 @@ function preload() { mapOutline = loadStrings(`./assets/levels/level${levelId}.txt`); // Load the buttonStyles JSON file - buttonStyles = loadJSON('./assets/json/buttonStyles.json'); + buttonStyles = loadJSON('./assets/json/levelButtonStyles.json'); } function setup() { diff --git a/index.html b/index.html index b385ae6..1215f47 100644 --- a/index.html +++ b/index.html @@ -13,13 +13,8 @@ - - - - - - - + + \ No newline at end of file diff --git a/index.js b/index.js index ebc03c1..0d4110d 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,31 @@ -let head; +let backgroundImage, customLevelButton, levelListButton; function preload() { - head = loadImage('./assets/player/head.png'); - loadFont('./assets/fonts/Fredoka-Medium.ttf'); + // Load assets for render + backgroundImage = loadImage('./assets/images/menuBg.png'); + menuButtonStyles = loadJSON('./assets/json/menuButtonStyles.json'); + // Load buttons' fonts + loadFont('./assets/fonts/Fredoka-Bold.ttf'); } function setup() { createCanvas(500, 500); + customLevelButton = createButton('Custom Level'); + levelListButton = createButton('Play'); } function draw() { - background('#6f6f'); - image(head, 0, 0); + image(backgroundImage, 0, 0); - textFont('Fredoka-Medium'); - textSize(40); - fill('#000'); - const w = textWidth('Sokoban Worlds'); - text(w, 100, 300); - text('Sokoban Worlds', 80, 100); + // Apply styles to the menu buttons + applyStyles(levelListButton, menuButtonStyles); + applyStyles(customLevelButton, menuButtonStyles); + + // Position the buttons on the screen + levelListButton.position(width/2.4, height/1.93); + customLevelButton.position(width/3.6, height/1.5); + + // Add listeners for button actions + levelListButton.mousePressed(initiateLevelPlay); + customLevelButton.mousePressed(customLevelLoad); } \ No newline at end of file diff --git a/menu.html b/play.html similarity index 66% rename from menu.html rename to play.html index 63b88ad..b385ae6 100644 --- a/menu.html +++ b/play.html @@ -12,8 +12,14 @@ - + -

Welcome to the menu boys

+ + + + + + + \ No newline at end of file