@@ -36,13 +36,17 @@ function buildView(stateMachine, model) {
36
36
elInfo = document . getElementById ( 'info' ) ,
37
37
elDetails = document . getElementById ( 'details' ) ,
38
38
39
+ imgPlayer = new Image ( ) ,
40
+ imgExit = new Image ( ) ,
41
+
39
42
ctx = elCanvas . getContext ( '2d' ) ,
40
43
CELL_SELECTED_COLOUR = '#006BB7' ,
41
44
CELL_DEFAULT_COLOUR = 'white' ,
42
45
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" ;
46
50
47
51
const renderer = ( ( ) => {
48
52
const WALL_THICKNESS = 1 , OFFSET = WALL_THICKNESS / 2 ;
@@ -71,6 +75,10 @@ function buildView(stateMachine, model) {
71
75
ctx . fillText ( text , coord ( x ) + ( cellSize - fontSize ) , coord ( y ) + cellSize - ( cellSize - fontSize ) / 4 ) ;
72
76
}
73
77
78
+ function drawImage ( x , y , img ) {
79
+ ctx . drawImage ( img , coord ( x ) , coord ( y ) , magnification , magnification ) ;
80
+ }
81
+
74
82
let magnification ;
75
83
76
84
return {
@@ -93,10 +101,10 @@ function buildView(stateMachine, model) {
93
101
drawRectangle ( x , y , CELL_VISITED_COLOUR ) ;
94
102
}
95
103
if ( cell . metadata . player ) {
96
- drawText ( x , y , CELL_PLAYER_SYMBOL ) ;
104
+ drawImage ( x , y , imgPlayer ) ;
97
105
98
106
} else if ( cell . metadata . finish ) {
99
- drawText ( x , y , CELL_FINISH_SYMBOL ) ;
107
+ drawImage ( x , y , imgExit ) ;
100
108
}
101
109
102
110
if ( ! cell . neighbours . north . link ) {
0 commit comments