diff --git a/index.html b/index.html index eb218ab..c11f909 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,6 @@ your experience.

- Coucou diff --git a/modules/levels.mjs b/modules/levels.mjs index 2c07fc7..0e8342b 100644 --- a/modules/levels.mjs +++ b/modules/levels.mjs @@ -2,5 +2,18 @@ import { Square } from '/modules/enums.mjs'; // Blueprint for the first level export const level1Blueprint = [[ Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall ], - [ Square.Wall, Square.Destination, Square.Box, Square.Floor, Square.Player, Square.Wall ], - [ Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall ]]; + [ Square.Wall, Square.Destination, Square.Box, Square.Floor, Square.Player, Square.Wall ], + [ Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall ]]; + +export const level2Blueprint = [ + [Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Floor, Square.Floor ], + [Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Wall, Square.Wall, Square.Wall], + [Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Wall], + [Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Box, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Floor, Square.Floor, Square.Wall], + [Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Player, Square.Floor, Square.Wall, Square.Wall, Square.Floor, Square.Floor, Square.Wall], + [Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Wall, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Wall, Square.Wall], + [Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Floor, Square.Wall, Square.Wall, Square.Box, Square.Floor, Square.Box, Square.Floor, Square.Floor ], + [Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Box, Square.Floor, Square.Box, Square.Floor, Square.Floor ], + [Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Wall, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Floor ], + [Square.Floor, Square.Floor, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall ], + ]; diff --git a/modules/playground.mjs b/modules/playground.mjs index d611a58..596affc 100644 --- a/modules/playground.mjs +++ b/modules/playground.mjs @@ -40,8 +40,8 @@ export const generatePlayground = (levelBlueprint, canvasWidth, canvasHeight) => default: break; } - foreground[indexRow].push(new ForegroundTile(square, indexColumn * tileWidth, indexRow * tileHeight, tileWidth, tileHeight)); background[indexRow].push(new BackgroundTile(square, indexColumn * tileWidth, indexRow * tileHeight, tileWidth, tileHeight)); + foreground[indexRow].push(new ForegroundTile(square, indexColumn * tileWidth, indexRow * tileHeight, tileWidth, tileHeight)); }); }); if (boxCount != destinationCount) { diff --git a/modules/ressources.mjs b/modules/ressources.mjs index 574e8ca..99999ca 100644 --- a/modules/ressources.mjs +++ b/modules/ressources.mjs @@ -1,7 +1,7 @@ export const images = { wall: '/res/wall.png', floor: '/res/floor.png', - player: '/res/mario.png', + player: '/res/player.png', box: '/res/box.png', destination: '/res/destination.png', empty: '/res/empty.png', diff --git a/modules/tiles.mjs b/modules/tiles.mjs index e871b13..598046d 100644 --- a/modules/tiles.mjs +++ b/modules/tiles.mjs @@ -29,6 +29,9 @@ class Tile { setImageSrc(src) { this.image.src = src; + this.image.addEventListener('load', () => { + this.imageReady = true; + }, false); } } diff --git a/res/box.png b/res/box.png new file mode 100644 index 0000000..ad1b164 Binary files /dev/null and b/res/box.png differ diff --git a/res/destination.png b/res/destination.png new file mode 100644 index 0000000..b36f081 Binary files /dev/null and b/res/destination.png differ diff --git a/res/empty.png b/res/empty.png new file mode 100644 index 0000000..6d629c2 Binary files /dev/null and b/res/empty.png differ diff --git a/res/floor.png b/res/floor.png new file mode 100644 index 0000000..bca82df Binary files /dev/null and b/res/floor.png differ diff --git a/res/player.png b/res/player.png new file mode 100644 index 0000000..5e3b101 Binary files /dev/null and b/res/player.png differ diff --git a/script.js b/script.js index 3c70494..dc4d29b 100644 --- a/script.js +++ b/script.js @@ -1,11 +1,11 @@ import { generatePlayground } from '/modules/playground.mjs' -import { level1Blueprint } from '/modules/levels.mjs' +import { level1Blueprint, level2Blueprint } from '/modules/levels.mjs' import { MoveDirection } from '/modules/enums.mjs' let canvas = document.getElementById('canvas'); let ctx = canvas.getContext('2d'); window.ctx = ctx -let playground = generatePlayground(level1Blueprint, canvas.width, canvas.height); +let playground = generatePlayground(level2Blueprint, canvas.width, canvas.height); window.addEventListener("keydown", (event) => { if (!event.defaultPrevented) { switch (event.key) {