Fix background and fix PageElement system

This commit is contained in:
schmelczerandras 2020-11-22 22:41:10 +01:00
parent 6fc16f4de0
commit 91d92f7f48
24 changed files with 528 additions and 809 deletions

View file

@ -1,5 +1,5 @@
export class Random {
public constructor(private seed: number) {}
public constructor(public seed: number = 42) {}
public get next(): number {
// result is in [0, 1)
@ -7,10 +7,10 @@ export class Random {
}
public choose<T>(list: Array<T>): T {
return list[Math.floor(this.randomInInterval(0, list.length))];
return list[Math.floor(this.inInterval(0, list.length))];
}
public randomInInterval(aClosed: number, bOpen: number): number {
public inInterval(aClosed: number, bOpen: number): number {
return (bOpen - aClosed) * this.next + aClosed;
}
}