Unfortunately I have to use npm

This commit is contained in:
Lani Aung
2025-06-03 21:46:32 -07:00
parent f49a1617fb
commit 23e5e075cc
14 changed files with 2260 additions and 38 deletions
+29
View File
@@ -0,0 +1,29 @@
export default class State {
colors: number[]
maxCracks: number
crackGrid: number[]
height: number
width: number
constructor(colors: number[], maxCracks: number, height: number, width: number) {
this.colors = colors
this.maxCracks = maxCracks
this.height = height
this.width = width
this.crackGrid = []
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
this.crackGrid[y * width + x] = 10000
}
}
for (let i = 0; i < 16; i++) {
this.crackGrid[Math.floor(Math.random() * (height * width))] = Math.ceil(Math.random() * 360)
}
}
getRandomColor(): number {
return this.colors[Math.floor(Math.random() * this.colors.length)]
}
}