1
- import { Position , Rectangle } from "./util/position" ;
2
- import { Puzzle } from "./puzzle " ;
3
- import { fail } from "./util/fail " ;
4
- import { hexToRgb } from "./util/color" ;
5
- import { Crate } from "./objects/crate" ;
6
- import { Player } from "./objects/player" ;
7
- import { Goal } from "./objects/goal" ;
8
- import { Wall } from "./objects/wall" ;
9
- import { Floor } from "./objects/floor" ;
10
- import { addLights , Light } from "./objects/lights" ;
11
- import { Tile } from "./tile" ;
12
- import { Track } from "./objects/track" ;
1
+ import { Position , Rectangle } from "./util/position.js " ;
2
+ import { fail } from "./util/fail.js " ;
3
+ import { Puzzle } from "./puzzle.js " ;
4
+ import { hexToRgb } from "./util/color.js " ;
5
+ import { Crate } from "./objects/crate.js " ;
6
+ import { Player } from "./objects/player.js " ;
7
+ import { Goal } from "./objects/goal.js " ;
8
+ import { Wall } from "./objects/wall.js " ;
9
+ import { Floor } from "./objects/floor.js " ;
10
+ import { addLights , Light } from "./objects/lights.js " ;
11
+ import { Tile } from "./tile.js " ;
12
+ import { Track } from "./objects/track.js " ;
13
13
14
14
const tileWidth = 7 ;
15
15
const tileHeight = 3 ;
@@ -114,8 +114,8 @@ const visibilityCache = new Map<string, boolean>();
114
114
115
115
function createStaticLights ( level : Level , crow : number , ccol : number ) : Light [ ] {
116
116
const lights : Light [ ] = [ ] ;
117
- for ( let row = 0 ; row < crow ; row ++ ) {
118
- for ( let column = 0 ; column < ccol ; column ++ ) {
117
+ for ( let row = 0 ; row < crow ; row += 3 ) {
118
+ for ( let column = 0 ; column < ccol ; column += 3 ) {
119
119
const p = new Position ( column * tileWidth + tileWidth / 2 , row * tileHeight + tileHeight / 2 ) ;
120
120
const n = [
121
121
level . getCell ( p . move ( - tileWidth , - tileHeight ) ) ,
@@ -129,15 +129,15 @@ function createStaticLights(level: Level, crow: number, ccol: number): Light[] {
129
129
level . getCell ( p . move ( tileWidth , tileHeight ) ) ,
130
130
] ;
131
131
132
- if ( Math . random ( ) < 0.05 && n . filter ( x => x !== Cell . Wall && x !== Cell . Void ) . length > 5 ) {
132
+ // if (n.filter(x => x !== Cell.Wall && x !== Cell.Void).length > 5) {
133
133
lights . push ( {
134
- color : hexToRgb ( 0x555555 ) ,
134
+ color : hexToRgb ( 0x222222 ) ,
135
135
x : p . x ,
136
136
y : p . y ,
137
- z : 3 * tileWidth ,
137
+ z : 4 * tileWidth ,
138
138
direction : null ,
139
139
} ) ;
140
- }
140
+ // }
141
141
}
142
142
}
143
143
return lights ;
@@ -146,16 +146,16 @@ function createStaticLights(level: Level, crow: number, ccol: number): Light[] {
146
146
function createPlayerLight ( level : Level ) : Light {
147
147
return {
148
148
x : level . player . rectangle . x + 4 +
149
- ( level . player . dir === Dir . Right ? - 3 : level . player . dir === Dir . Left ? 3 : 0 ) ,
149
+ ( level . player . dir === Dir . Right ? - 2 : level . player . dir === Dir . Left ? 2 : 0 ) ,
150
150
y : level . player . rectangle . y + 1.5 +
151
- ( level . player . dir === Dir . Down ? - 1 : level . player . dir === Dir . Up ? 1 : 0 ) ,
151
+ ( level . player . dir === Dir . Down ? - 0 : level . player . dir === Dir . Up ? 0 : 0 ) ,
152
152
z : 1 ,
153
- color : hexToRgb ( 0x440000 ) ,
153
+ color : hexToRgb ( 0x888800 ) ,
154
154
direction : {
155
155
x : level . player . dir === Dir . Right ? - 1 : level . player . dir === Dir . Left ? 1 : 0 ,
156
156
y : level . player . dir === Dir . Down ? - 1 : level . player . dir === Dir . Up ? 1 : 0 ,
157
- z : - 0.2 ,
158
- cosTheta : Math . cos ( Math . PI / 3 )
157
+ z : 1 ,
158
+ cosTheta : Math . cos ( Math . PI / 3 ) ,
159
159
} ,
160
160
} ;
161
161
}
@@ -311,7 +311,6 @@ export class Level {
311
311
let oldState = this . state ;
312
312
let newState : State = oldState ;
313
313
const newPlayerRect = this . player . rectangle . move ( dx * tileWidth , dy * tileHeight )
314
-
315
314
newState = {
316
315
...newState ,
317
316
player : newState . player . withDir (
@@ -356,11 +355,13 @@ export class Level {
356
355
case Cell . Goal :
357
356
case Cell . Empty :
358
357
case Cell . Void :
358
+
359
359
newState = {
360
360
...newState ,
361
361
player : newState . player . withCenter ( newPlayerRect . center ) ,
362
362
steps : this . steps + 1 ,
363
363
} ;
364
+
364
365
break ;
365
366
}
366
367
0 commit comments