Fix reveal mechanic
This commit is contained in:
parent
4639c22025
commit
76875e8ee1
4 changed files with 19 additions and 14 deletions
|
|
@ -1,8 +1,7 @@
|
|||
import { asyncScheduler, distinct, distinctUntilKeyChanged, throttleTime } from 'rxjs';
|
||||
import { map } from 'rxjs';
|
||||
import { mp5 } from '../../main';
|
||||
import { revealedArea$ } from '../area';
|
||||
import { pointIsRevealed, revealedArea$ } from '../area';
|
||||
import { colors } from '../constants/colors';
|
||||
import { shapeCollision } from '../helpers';
|
||||
|
||||
export class Package {
|
||||
x: number;
|
||||
|
|
@ -16,9 +15,11 @@ export class Package {
|
|||
this.y = y;
|
||||
this.size = size;
|
||||
|
||||
revealedArea$.subscribe((revealedArea) => {
|
||||
this.revealed = shapeCollision({ x: this.x, y: this.y, w: 10 }, revealedArea);
|
||||
});
|
||||
revealedArea$
|
||||
.pipe(map((revealedArea) => pointIsRevealed({ x: this.x, y: this.y }, revealedArea)))
|
||||
.subscribe((isRevealed) => {
|
||||
this.revealed = isRevealed;
|
||||
});
|
||||
}
|
||||
|
||||
public place() {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export class Player {
|
|||
if (this.showRevealEl) {
|
||||
const x = this.cursorOnRevealClick.x;
|
||||
const y = this.cursorOnRevealClick.y;
|
||||
const w = Math.floor(timeElapsedSinceRevealClick * 0.4);
|
||||
const w = timeElapsedSinceRevealClick * 0.4;
|
||||
|
||||
mp5.fill(mp5.color(colors.greyLighter));
|
||||
mp5.strokeWeight(5);
|
||||
|
|
|
|||
Reference in a new issue