Skip to content

Commit 4c63274

Browse files
committed
added proper images for player and exit
1 parent f0f8e3e commit 4c63274

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

images/finish.png

1.08 KB
Loading

images/player.png

949 Bytes
Loading

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ <h1>Maze Generator</h1>
2525
<button id="mask">Create Mask</button>
2626
<button id="saveMask">Save Mask</button>
2727
<button id="clearMask">Clear Mask</button>
28-
<button id="refreshMaze">Refresh</button>
2928
<button id="play">Play</button>
29+
<button id="refreshMaze">Refresh</button>
3030
<button id="changeMazeConfig">Change Parameters</button>
3131
<div id="info"></div>
3232
<div id="details"></div>
3333
</div>
3434
</div>
35+
3536
<script src="js/config.js"></script>
3637
<script src="js/utils.js"></script>
3738
<script src="js/stateMachine.js"></script>

js/model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function buildModel() {
2-
const size = config.mazeSizes[config.mazeSizes.length - 1],
2+
const size = config.mazeSizes[config.mazeSizes.length - 3],
33
algorithm = config.algorithms[config.algorithms.length - 1];
44

55
const model = {

js/view.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ function buildView(stateMachine, model) {
3636
elInfo = document.getElementById('info'),
3737
elDetails = document.getElementById('details'),
3838

39+
imgPlayer = new Image(),
40+
imgExit = new Image(),
41+
3942
ctx = elCanvas.getContext('2d'),
4043
CELL_SELECTED_COLOUR = '#006BB7',
4144
CELL_DEFAULT_COLOUR = 'white',
4245
CELL_MASKED_COLOUR = 'black',
43-
CELL_VISITED_COLOUR = '#006BB755',
44-
CELL_PLAYER_SYMBOL = 'P',
45-
CELL_FINISH_SYMBOL = 'F';
46+
CELL_VISITED_COLOUR = '#006BB722';
47+
48+
imgPlayer.src = "images/player.png";
49+
imgExit.src = "images/finish.png";
4650

4751
const renderer = (() => {
4852
const WALL_THICKNESS = 1, OFFSET = WALL_THICKNESS / 2;
@@ -71,6 +75,10 @@ function buildView(stateMachine, model) {
7175
ctx.fillText(text, coord(x) + (cellSize - fontSize), coord(y) + cellSize - (cellSize - fontSize) / 4);
7276
}
7377

78+
function drawImage(x, y, img) {
79+
ctx.drawImage(img, coord(x), coord(y), magnification, magnification);
80+
}
81+
7482
let magnification;
7583

7684
return {
@@ -93,10 +101,10 @@ function buildView(stateMachine, model) {
93101
drawRectangle(x, y, CELL_VISITED_COLOUR);
94102
}
95103
if (cell.metadata.player) {
96-
drawText(x, y, CELL_PLAYER_SYMBOL);
104+
drawImage(x, y, imgPlayer);
97105

98106
} else if (cell.metadata.finish) {
99-
drawText(x, y, CELL_FINISH_SYMBOL);
107+
drawImage(x, y, imgExit);
100108
}
101109

102110
if (!cell.neighbours.north.link) {

0 commit comments

Comments
 (0)