implemented Wall

master
Ugo Finnendahl 5 years ago
parent c5d0176dc0
commit a85cf3a47f
  1. 6
      index.html
  2. 34
      js/rl.js
  3. 7
      js/view.js

@ -41,11 +41,11 @@
</nav>
<script>
var map = [
[0, 0, 4, 2, 0, 0, 0, 0],
[0, 0, 4, 8, 0, 0, 0, 0],
[0, 0, 4, 4, 4, 4, 0, 0],
[4, 0, 0, 0, 0, 4, 0, 4],
[0, 0, 4, 0, 0, 0, 0, 0],
[1, 0, 4, 0, 4, 0, 0, 4]
[0, 0, 1, 0, 0, 0, 0, 0],
[2, 0, 1, 0, 4, 0, 0, 4]
];
</script>
<script src="js/rl.js"></script>

@ -87,9 +87,10 @@ function choose(array) {
// ------------------ maze stuff --------------------------------------------
const tile = {
regular: 0,
start: 1,
end: 2,
wall: 1,
start: 2,
dangerous: 4,
end: 8,
};
const dir = {
@ -124,22 +125,29 @@ class Maze {
get_actions() {
var actions = [];
for (let idy=0; idy<this.map.length; idy++){
var y_actions = [];
if (idy != 0){
y_actions.push(dir.UP);
}
if (idy != this.map.length-1){
y_actions.push(dir.DOWN);
}
for (let idx=0; idx<this.map[0].length; idx++){
var x_actions = [];
var action = [];
if (idy != 0){
if(this.map[idy-1][idx] != tile.wall){
action.push(dir.UP);
}
}
if (idy != this.map.length-1){
if(this.map[idy+1][idx] != tile.wall){
action.push(dir.DOWN);
}
}
if (idx != 0){
x_actions.push(dir.LEFT);
if(this.map[idy][idx-1] != tile.wall){
action.push(dir.LEFT);
}
}
if (idx != this.map[0].length-1){
x_actions.push(dir.RIGHT);
if(this.map[idy][idx+1] != tile.wall){
action.push(dir.RIGHT);
}
}
actions.push([...y_actions,...x_actions]);
actions.push(action);
}
}
return actions;

@ -289,6 +289,13 @@ app = new Vue({
opacity: 1,
...over,
}
case tile.wall:
return {
...layout,
fill: '#000000',
opacity: 1,
...over,
}
}
}
},

Loading…
Cancel
Save