This commit is contained in:
lanxu 2024-11-11 21:31:06 +02:00
parent a8a7215a79
commit 25021fb93e
3 changed files with 48 additions and 3 deletions

3
package-lock.json generated
View File

@ -11,9 +11,6 @@
"mini-game": "file:../pkg", "mini-game": "file:../pkg",
"phaser": "^3.86.0" "phaser": "^3.86.0"
}, },
"bin": {
"create-wasm-app": ".bin/create-wasm-app.js"
},
"devDependencies": { "devDependencies": {
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vite": "^5.4.9" "vite": "^5.4.9"

42
src/scenes/game.ts Normal file
View 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) {
}
}

View File

@ -1,6 +1,7 @@
import * as Phaser from "phaser"; import * as Phaser from "phaser";
import Card from "../objects/card"; import Card from "../objects/card";
import GameButton from "../objects/button"; import GameButton from "../objects/button";
import SilverFangMiniGame from "./game";
class MainMenuScene extends Phaser.Scene { class MainMenuScene extends Phaser.Scene {
constructor() { constructor() {
@ -8,6 +9,11 @@ class MainMenuScene extends Phaser.Scene {
} }
preload() { preload() {
for(let n = 0; n < 40; n++) {
console.log('TEST ' + n)
const g = new SilverFangMiniGame()
g.addCards(n)
}
} }
create() { create() {