laneya2

cave exploration game
git clone https://git.ce9e.org/laneya2.git

commit
163941f3e437f31ee45c6d3769b4e91465d0748f
parent
772dff878b272610db2c8d31669d46dccf3ddea5
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-09-22 08:04
optimize field of vision

Diffstat

M static/main.js 9 ++++-----

1 files changed, 4 insertions, 5 deletions


diff --git a/static/main.js b/static/main.js

@@ -46,22 +46,21 @@ var game = {
   46    46             return [' ', -1];
   47    47         }
   48    48 
   49    -1         var inView = Object.values(this.objects).some(
   -1    49         var inView = () => Object.values(this.objects).some(
   50    50             obj => obj.type === 'player' && this.inView(obj.pos, {x, y})
   51    51         );
   52    -1         var white = inView ? -1 : 0;
   53    52 
   54    53         if (x === this.ladder.x && y === this.ladder.y) {
   55    -1             return ['>', white];
   -1    54             return ['>', inView() ? -1 : 0];
   56    55         }
   57    56         if (Object.values(this.objects).some(obj => x === obj.pos.x && y === obj.pos.y)) {
   58    57             return ['@', 4];
   59    58         }
   60    59         if (this.getRect({x, y})) {
   61    -1             return ['.', white];
   -1    60             return ['.', inView() ? -1 : 0];
   62    61         }
   63    62         if (this.getRect({x, y}, true)) {
   64    -1             return ['#', white];
   -1    63             return ['#', inView() ? -1 : 0];
   65    64         }
   66    65         return [' ', -1];
   67    66     },