From d54d8f333d5c5b76cfb69f98113d11c841302236 Mon Sep 17 00:00:00 2001 From: nbillard Date: Mon, 5 Dec 2022 15:29:26 +0100 Subject: [PATCH] changement de textures --- index.html | 1 - modules/levels.mjs | 17 +++++++++++++++-- modules/playground.mjs | 2 +- modules/ressources.mjs | 2 +- modules/tiles.mjs | 3 +++ res/box.png | Bin 0 -> 799 bytes res/destination.png | Bin 0 -> 6606 bytes res/empty.png | Bin 0 -> 570 bytes res/floor.png | Bin 0 -> 760 bytes res/player.png | Bin 0 -> 725 bytes script.js | 4 ++-- 11 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 res/box.png create mode 100644 res/destination.png create mode 100644 res/empty.png create mode 100644 res/floor.png create mode 100644 res/player.png 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 0000000000000000000000000000000000000000..ad1b164790098f1b432186bbb37060f97cb3e3bb GIT binary patch literal 799 zcmV+)1K|9LP)EX>4Tx04R}tkv&MmP!xqvQ^is$4t5Z6$WWc^qD35Q6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~=;Wm6A|>9J6k5c1;qgAsyXWxUeSpxaG0o~r0-A1{ z*>p^gBQq)(LxlU^gX)Iz15=1Cypo$u7#A(+_v5=+nl#hSZ^-JVZ$W;X+ z#{%lmAiI9>KlnXct2903B}Gy||BK^%i~|F^K)dNU-^Y&AJ^_Nyz?I(h*IU5sC+W?u z7CQolwt<9_pswV@2hrDVT;Z2Y^fkCUHP2shb|okq-cHbKEw! zFe3#300}az*tnQ+VE~gj0LF!8L&i2SX``c@%{lT7MfQ6?@!Bk%0=pJ)V?vH1e2esNWJao dAE@BJoHuKBgybw`b{+r#002ovPDHLkV1l%NS6Ki6 literal 0 HcmV?d00001 diff --git a/res/destination.png b/res/destination.png new file mode 100644 index 0000000000000000000000000000000000000000..b36f081daacbe4890e380341e9f90918c562111b GIT binary patch literal 6606 zcmeHKc{r5q_a79c)Eg?1jFG(5?87V>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pHO8ZTGGnrNl>Z`}5@`q_=61i67v8}`3vUy#}8+8HiY kW}$kRkT<+Icw|~((m}zsuG;h@*j*tMLvw=?J-5jJ0XGz)RsaA1 literal 0 HcmV?d00001 diff --git a/res/empty.png b/res/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..6d629c2d5277d00c9d1d617b6da040b1c8562c58 GIT binary patch literal 570 zcmV-A0>%A_P)EX>4Tx04R}tkv&MmP!xqvQ^is$4t5Z6$WWc^qD35Q6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~=;Wm6A|>9J6k5c1;qgAsyXWxUeSpxaG0o~r0-A1{ z*>p^gBQq)(LxlU^gX)Iz15=1Cypo$u7#A(+_v5=+nl#hSZ^-JVZ$W;X+ z#{%lmAiI9>KlnXct2903B}Gy||BK^%i~|F^K)dNU-^Y&AJ^_Nyz?I(h*IU5sC+W?u z7CQolwtXo`z=*0000hbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJAV*0}P#|J?AWmU) zXkl(3LTPMlVRB@4h{i7f000t6L_t(I%VS^|1*2dTi~EX>4Tx04R}tkv&MmP!xqvQ^is$4t5Z6$WWc^qD35Q6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~=;Wm6A|>9J6k5c1;qgAsyXWxUeSpxaG0o~r0-A1{ z*>p^gBQq)(LxlU^gX)Iz15=1Cypo$u7#A(+_v5=+nl#hSZ^-JVZ$W;X+ z#{%lmAiI9>KlnXct2903B}Gy||BK^%i~|F^K)dNU-^Y&AJ^_Nyz?I(h*IU5sC+W?u z7CQolwtKJn9hOl5WKuSW4K}JlF;mND_DB`xSS@636+1cotWi0|3{!1A#{FgF9aS0Q; zlg#wg8Dzu+F>HGD=plw{4vYR_U__4vY)&US7Gx~~86LAJVpS+3CWzH#Ecl!W(+CR_ z8xfU^PHSOb{iIVDXHc`mhBu qT=vwZn|S?-D~y=%1r)Zlj}8EWmsJKB{#|we0000EX>4Tx04R}tkv&MmP!xqvQ^is$4t5Z6$WWc^qD35Q6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~=;Wm6A|>9J6k5c1;qgAsyXWxUeSpxaG0o~r0-A1{ z*>p^gBQq)(LxlU^gX)Iz15=1Cypo$u7#A(+_v5=+nl#hSZ^-JVZ$W;X+ z#{%lmAiI9>KlnXct2903B}Gy||BK^%i~|F^K)dNU-^Y&AJ^_Nyz?I(h*IU5sC+W?u z7CQolwtg!QbEmv|d4~=WgH`00000NkvXX Hu0mjf_u?`= literal 0 HcmV?d00001 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) {