Fix background and fix PageElement system
This commit is contained in:
parent
6fc16f4de0
commit
91d92f7f48
24 changed files with 528 additions and 809 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue