WIP grid
This commit is contained in:
parent
a8a7215a79
commit
25021fb93e
3
package-lock.json
generated
3
package-lock.json
generated
|
@ -11,9 +11,6 @@
|
|||
"mini-game": "file:../pkg",
|
||||
"phaser": "^3.86.0"
|
||||
},
|
||||
"bin": {
|
||||
"create-wasm-app": ".bin/create-wasm-app.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.6.3",
|
||||
"vite": "^5.4.9"
|
||||
|
|
42
src/scenes/game.ts
Normal file
42
src/scenes/game.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
export default class SilverFangMiniGame {
|
||||
cards: Number[] = []
|
||||
rows: Number = 0
|
||||
cols: Number = 0
|
||||
|
||||
|
||||
constructor() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
recalculateBoardSize() {
|
||||
const numCards = this.cards.length
|
||||
|
||||
let solutions = []
|
||||
|
||||
for (let x = 1; x < numCards; x++) {
|
||||
for (let y = 1; y < numCards; y++) {
|
||||
if (x*y === numCards) {
|
||||
solutions.push([x, y, Math.abs(x-y)])
|
||||
}
|
||||
}
|
||||
}
|
||||
solutions.sort((a, b) => a[2] - b[2])
|
||||
solutions.forEach(s => console.log(s))
|
||||
}
|
||||
|
||||
addCards(cards: Number) {
|
||||
for(let i = 0; i < cards; i++) {
|
||||
this.cards.push(i);
|
||||
}
|
||||
this.recalculateBoardSize()
|
||||
}
|
||||
|
||||
addPair(card: Number) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import * as Phaser from "phaser";
|
||||
import Card from "../objects/card";
|
||||
import GameButton from "../objects/button";
|
||||
import SilverFangMiniGame from "./game";
|
||||
|
||||
class MainMenuScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
|
@ -8,6 +9,11 @@ class MainMenuScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
preload() {
|
||||
for(let n = 0; n < 40; n++) {
|
||||
console.log('TEST ' + n)
|
||||
const g = new SilverFangMiniGame()
|
||||
g.addCards(n)
|
||||
}
|
||||
}
|
||||
|
||||
create() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user