|
|
@ -82,7 +82,9 @@ app = new Vue({ |
|
|
|
duration: 0, |
|
|
|
duration: 0, |
|
|
|
interval: 0.01, |
|
|
|
interval: 0.01, |
|
|
|
tooltip: 'none' |
|
|
|
tooltip: 'none' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
robot_image: null, |
|
|
|
|
|
|
|
energy_image: null, |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
created() { |
|
|
|
// Resize handler
|
|
|
|
// Resize handler
|
|
|
@ -130,6 +132,21 @@ app = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
machine.score_history = s; |
|
|
|
machine.score_history = s; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const robot_image = new window.Image(); |
|
|
|
|
|
|
|
robot_image.src = "img/robot.png"; |
|
|
|
|
|
|
|
// robot_image.src = "https://konvajs.org/assets/yoda.jpg";
|
|
|
|
|
|
|
|
robot_image.onload = () => { |
|
|
|
|
|
|
|
// set image only when it is loaded
|
|
|
|
|
|
|
|
this.robot_image = robot_image; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const energy_image = new window.Image(); |
|
|
|
|
|
|
|
energy_image.src = "img/station.png"; |
|
|
|
|
|
|
|
// energy_image.src = "https://konvajs.org/assets/yoda.jpg";
|
|
|
|
|
|
|
|
energy_image.onload = () => { |
|
|
|
|
|
|
|
// set image only when it is loaded
|
|
|
|
|
|
|
|
this.energy_image = energy_image; |
|
|
|
|
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
destroyed() { |
|
|
|
destroyed() { |
|
|
|
window.removeEventListener('resize', this.handleResize) |
|
|
|
window.removeEventListener('resize', this.handleResize) |
|
|
@ -227,6 +244,26 @@ app = new Vue({ |
|
|
|
y: this.base_size * this.state.y, |
|
|
|
y: this.base_size * this.state.y, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
robot_config: function() { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
height: this.base_size, |
|
|
|
|
|
|
|
width: this.base_size, |
|
|
|
|
|
|
|
x: this.base_size * this.state.x, |
|
|
|
|
|
|
|
y: this.base_size * this.state.y, |
|
|
|
|
|
|
|
image: this.robot_image, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
energy_config: function() { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
height: this.base_size, |
|
|
|
|
|
|
|
width: this.base_size, |
|
|
|
|
|
|
|
offset: { |
|
|
|
|
|
|
|
x: this.base_size/2, |
|
|
|
|
|
|
|
y: this.base_size/2 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
image: this.energy_image, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
base_size: function() { |
|
|
|
base_size: function() { |
|
|
|
return Math.min(this.stage_config.height * 0.8 / this.maze.height, this.stage_config.width * 0.5 / this.maze.width); |
|
|
|
return Math.min(this.stage_config.height * 0.8 / this.maze.height, this.stage_config.width * 0.5 / this.maze.width); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -427,12 +464,14 @@ app = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const layout = { |
|
|
|
const layout = { |
|
|
|
x: this.base_size * pos.x, |
|
|
|
|
|
|
|
y: this.base_size * pos.y, |
|
|
|
|
|
|
|
width: this.base_size, |
|
|
|
width: this.base_size, |
|
|
|
height: this.base_size, |
|
|
|
height: this.base_size, |
|
|
|
stroke: '#ddd', |
|
|
|
stroke: '#ddd', |
|
|
|
strokeWidth: this.strokeW, |
|
|
|
strokeWidth: this.strokeW, |
|
|
|
|
|
|
|
offset: { |
|
|
|
|
|
|
|
x: this.base_size/2, |
|
|
|
|
|
|
|
y: this.base_size/2, |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
switch (t_type) { |
|
|
|
switch (t_type) { |
|
|
|
case tile.regular: |
|
|
|
case tile.regular: |
|
|
|