Merge branch 'master' of https://git.etud.insa-toulouse.fr/nbillard/sokoban
This commit is contained in:
commit
cf0abf0670
6 changed files with 58 additions and 2 deletions
|
@ -21,11 +21,18 @@
|
||||||
your experience.
|
your experience.
|
||||||
</p>
|
</p>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<nav>
|
||||||
|
<ol id="level-lists">
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
=======
|
||||||
<div id="timer">Time</div>
|
<div id="timer">Time</div>
|
||||||
<button id="Pause" onclick="Pause()">Pause</button>
|
<button id="Pause" onclick="Pause()">Pause</button>
|
||||||
<br>
|
<br>
|
||||||
<div></div>
|
<div></div>
|
||||||
<canvas id="canvas" width="800" height="400"></canvas>
|
<canvas id="canvas" width="800" height="400"></canvas>
|
||||||
|
>>>>>>> 380cebd36dc4e3a1f3af185d1a7e3f0adb3e04d1
|
||||||
<div class="to-center">
|
<div class="to-center">
|
||||||
<canvas id="canvas" width="800" height="400"></canvas>
|
<canvas id="canvas" width="800" height="400"></canvas>
|
||||||
<div class="text-bubble">
|
<div class="text-bubble">
|
||||||
|
|
11
modules/fillLevelsSelection.mjs
Normal file
11
modules/fillLevelsSelection.mjs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { levelsBlueprint } from '/modules/levels.mjs'
|
||||||
|
|
||||||
|
export const fillLevelSelection = () => {
|
||||||
|
let levelList = document.getElementById('level-list');
|
||||||
|
for (let i = 0; i < levelsBlueprint.size; ++i) {
|
||||||
|
let listElement = document.createElement("li");
|
||||||
|
let selectionButton = document.createElement("button");
|
||||||
|
selectionButton.setAttribute("array-index", index);
|
||||||
|
// selectionButton.addEventListener
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,18 @@
|
||||||
import { Square } from '/modules/enums.mjs';
|
import { Square } from '/modules/enums.mjs';
|
||||||
|
|
||||||
// Blueprint for the first level
|
// Blueprint for the first level
|
||||||
export const level1Blueprint = [[ Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall ],
|
//
|
||||||
|
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.Destination, Square.Box, Square.Floor, Square.Player, 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.Wall ]];
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
const level2Blueprint = [
|
||||||
|
=======
|
||||||
|
|
||||||
// Blueprint for the second level
|
// Blueprint for the second level
|
||||||
export const level2Blueprint = [
|
export const level2Blueprint = [
|
||||||
|
>>>>>>> 380cebd36dc4e3a1f3af185d1a7e3f0adb3e04d1
|
||||||
[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.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.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.Floor, Square.Box, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Wall],
|
||||||
|
@ -18,3 +24,8 @@ export const level2Blueprint = [
|
||||||
[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.Wall ],
|
[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.Wall ],
|
||||||
[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 ],
|
[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 ],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const levelsBlueprint = [
|
||||||
|
level1Blueprint,
|
||||||
|
level2Blueprint,
|
||||||
|
]
|
||||||
|
|
20
notes_implementation.md
Normal file
20
notes_implementation.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Implementation
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
enum BackgroundTile {Wall, Floor, Destination};
|
||||||
|
enum ForegroundTile {Player, Box, Empty};
|
||||||
|
|
||||||
|
let playground = {
|
||||||
|
background<Layer, BackgroundTile>: {
|
||||||
|
tiles<BackgroundTile>: [[]]
|
||||||
|
},
|
||||||
|
foreground<Layer, ForegroundTile>: {
|
||||||
|
tiles<ForegroundTile>: [[]]
|
||||||
|
},
|
||||||
|
move(sourcePos, destPos) {
|
||||||
|
if (this.move(destPos, ))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
import { generatePlayground } from '/modules/playground.mjs'
|
import { generatePlayground } from '/modules/playground.mjs'
|
||||||
import { level1Blueprint, level2Blueprint } from '/modules/levels.mjs'
|
import {levelsBlueprint } from '/modules/levels.mjs'
|
||||||
import { MoveDirection } from '/modules/enums.mjs'
|
import { MoveDirection } from '/modules/enums.mjs'
|
||||||
|
import { fillLevelsSelection } from '/modules/fillLevelsSelection.mjs'
|
||||||
|
|
||||||
|
fillLevelSelection();
|
||||||
let canvas = document.getElementById('canvas');
|
let canvas = document.getElementById('canvas');
|
||||||
let ctx = canvas.getContext('2d');
|
let ctx = canvas.getContext('2d');
|
||||||
window.ctx = ctx
|
window.ctx = ctx
|
||||||
|
<<<<<<< HEAD
|
||||||
|
let playground = generatePlayground(levelsBlueprint[0], canvas.width, canvas.height);
|
||||||
|
=======
|
||||||
let playground = generatePlayground(level2Blueprint, canvas.width, canvas.height);
|
let playground = generatePlayground(level2Blueprint, canvas.width, canvas.height);
|
||||||
|
>>>>>>> 380cebd36dc4e3a1f3af185d1a7e3f0adb3e04d1
|
||||||
window.addEventListener("keydown", (event) => {
|
window.addEventListener("keydown", (event) => {
|
||||||
if (!event.defaultPrevented) {
|
if (!event.defaultPrevented) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
body {
|
body {
|
||||||
background-color: var(--main-background-color);
|
background-color: var(--main-background-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
color: --main-invert-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog {
|
.dialog {
|
||||||
|
|
Loading…
Reference in a new issue