264 lines
10 KiB
JavaScript
264 lines
10 KiB
JavaScript
import * as Phaser from 'phaser';
|
|
import { GAME_HEIGHT, GAME_WIDTH, COLORS } from './config.js';
|
|
import BootScene from './scenes/BootScene.js';
|
|
import PreloadScene from './scenes/PreloadScene.js';
|
|
import LandingScene from './scenes/LandingScene.js';
|
|
import ProfileScene from './scenes/ProfileScene.js';
|
|
import GameMenuScene from './scenes/GameMenuScene.js';
|
|
import OpponentSelectScene from './scenes/OpponentSelectScene.js';
|
|
import GameRoomScene from './scenes/GameRoomScene.js';
|
|
import BackgammonGame from './games/backgammon/BackgammonGame.js';
|
|
import HoldemGame from './games/holdem/HoldemGame.js';
|
|
import BlackjackGame from './games/blackjack/BlackjackGame.js';
|
|
import ParchisiGame from './games/parchisi/ParchisiGame.js';
|
|
import YatziGame from './games/yatzi/YatziGame.js';
|
|
import SkipBoGame from './games/skipbo/SkipBoGame.js';
|
|
import Phase10Game from './games/phase10/Phase10Game.js';
|
|
import ChineseCheckersGame from './games/chinesecheckers/ChineseCheckersGame.js';
|
|
import GoFishGame from './games/gofish/GoFishGame.js';
|
|
import UnoGame from './games/uno/UnoGame.js';
|
|
import CrapsGame from './games/craps/CrapsGame.js';
|
|
import RouletteGame from './games/roulette/RouletteGame.js';
|
|
import MexicanTrainGame from './games/mexicantrain/MexicanTrainGame.js';
|
|
import HeartsGame from './games/hearts/HeartsGame.js';
|
|
import CatanGame from './games/catan/CatanGame.js';
|
|
import TicketToRideGame from './games/tickettoride/TicketToRideGame.js';
|
|
import NertsGame from './games/nerts/NertsGame.js';
|
|
import BingoGame from './games/bingo/BingoGame.js';
|
|
import BaccaratGame from './games/baccarat/BaccaratGame.js';
|
|
import DominionGame from './games/dominion/DominionGame.js';
|
|
import CheckersGame from './games/checkers/CheckersGame.js';
|
|
import ChessGame from './games/chess/ChessGame.js';
|
|
import WordleGame from './games/wordle/WordleGame.js';
|
|
import ScrabbleGame from './games/scrabble/ScrabbleGame.js';
|
|
import GhostGame from './games/ghost/GhostGame.js';
|
|
import WordLadderGame from './games/wordladder/WordLadderGame.js';
|
|
import WordSearchGame from './games/wordsearch/WordSearchGame.js';
|
|
import HangmanGame from './games/hangman/HangmanGame.js';
|
|
import SudokuGame from './games/sudoku/SudokuGame.js';
|
|
import OthelloGame from './games/othello/OthelloGame.js';
|
|
import GoGame from './games/go/GoGame.js';
|
|
import BattleshipGame from './games/battleship/BattleshipGame.js';
|
|
import MastermindGame from './games/mastermind/MastermindGame.js';
|
|
import Connect4Game from './games/connect4/Connect4Game.js';
|
|
import BoggleGame from './games/boggle/BoggleGame.js';
|
|
import OldMaidGame from './games/oldmaid/OldMaidGame.js';
|
|
import BlokusGame from './games/blokus/BlokusGame.js';
|
|
import SpellingBeeGame from './games/spellingbee/SpellingBeeGame.js';
|
|
import MiniCrosswordGame from './games/minicrossword/MiniCrosswordGame.js';
|
|
import ForbiddenIslandGame from './games/forbiddenisland/ForbiddenIslandGame.js';
|
|
import SolitaireTourGame from './games/solitairetour/SolitaireTourGame.js';
|
|
import SplendorGame from './games/splendor/SplendorGame.js';
|
|
import TectonicGame from './games/tectonic/TectonicGame.js';
|
|
import LabyrinthGame from './games/labyrinth/LabyrinthGame.js';
|
|
import VideoPokerGame from './games/videopoker/VideoPokerGame.js';
|
|
import FarkelGame from './games/farkel/FarkelGame.js';
|
|
import StrategoGame from './games/stratego/StrategoGame.js';
|
|
import KiitosGame from './games/kiitos/KiitosGame.js';
|
|
import MonopolyGame from './games/monopoly/MonopolyGame.js';
|
|
import TriominoesGame from './games/triominoes/TriominoesGame.js';
|
|
import FreecellGame from './games/freecell/FreecellGame.js';
|
|
import RushHourGame from './games/rushhour/RushHourGame.js';
|
|
import HexsweeperGame from './games/hexsweeper/HexsweeperGame.js';
|
|
import PuddingMonstersGame from './games/puddingmonsters/PuddingMonstersGame.js';
|
|
import ShiftGame from './games/shift/ShiftGame.js';
|
|
import BlockFighterGame from './games/blockfighter/BlockFighterGame.js';
|
|
import MahjongMatchGame from './games/mahjongmatch/MahjongMatchGame.js';
|
|
import MahjongGame from './games/mahjong/MahjongGame.js';
|
|
import JewelQuestGame from './games/jewelquest/JewelQuestGame.js';
|
|
import ZumaGame from './games/zuma/ZumaGame.js';
|
|
import ZumaEditor from './games/zuma/ZumaEditor.js';
|
|
import BejeweledGame from './games/bejeweled/BejeweledGame.js';
|
|
import MiniMotorwaysGame from './games/minimotorways/MiniMotorwaysGame.js';
|
|
import SlotsGame from './games/slots/SlotsGame.js';
|
|
import CribbageGame from './games/cribbage/CribbageGame.js';
|
|
import CanastaGame from './games/canasta/CanastaGame.js';
|
|
import DotLinkGame from './games/dotlink/DotLinkGame.js';
|
|
import Game2048 from './games/2048/2048Game.js';
|
|
import RummikubGame from './games/rummikub/RummikubGame.js';
|
|
import GinRummyGame from './games/ginrummy/GinRummyGame.js';
|
|
import RiskGame from './games/risk/RiskGame.js';
|
|
import GeniusSquareGame from './games/geniussquare/GeniusSquareGame.js';
|
|
import KataminoGame from './games/katamino/KataminoGame.js';
|
|
import BookworkGame from './games/bookwork/BookworkGame.js';
|
|
import PaiGowPokerGame from './games/paigow/PaiGowPokerGame.js';
|
|
import SpireClimbGame from './games/spireclimb/SpireClimbGame.js';
|
|
import AzulGame from './games/azul/AzulGame.js';
|
|
import JumbleGame from './games/jumble/JumbleGame.js';
|
|
import DungeonBossGame from './games/dungeonboss/DungeonBossGame.js';
|
|
import SWDBGGame from './games/swdbg/SWDBGGame.js';
|
|
import BalatroGame from './games/balatro/BalatroGame.js';
|
|
import PeggleGame from './games/peggle/PeggleGame.js';
|
|
import PeggleEditor from './games/peggle/PeggleEditor.js';
|
|
import ColoradoDefenseGame from './games/coloradodefense/ColoradoDefenseGame.js';
|
|
import StarControlGame from './games/starcontrol/StarControlGame.js';
|
|
import CivilizationGame from './games/civilization/CivilizationGame.js';
|
|
import TempestGame from './games/tempest/TempestGame.js';
|
|
import SuperKartGame from './games/superkart/SuperKartGame.js';
|
|
import SuperKartEditor from './games/superkart/SuperKartEditor.js';
|
|
import AdvanceWarsGame from './games/advancewars/AdvanceWarsGame.js';
|
|
import TetrisAttackGame from './games/tetrisattack/TetrisAttackGame.js';
|
|
import TotalAnnihilationGame from './games/totalannihilation/TotalAnnihilationGame.js';
|
|
import BloxorzGame from './games/bloxorz/BloxorzGame.js';
|
|
import GooTowerGame from './games/gootower/GooTowerGame.js';
|
|
import GooTowerEditor from './games/gootower/GooTowerEditor.js';
|
|
import ExcitebikeGame from './games/excitebike/ExcitebikeGame.js';
|
|
import MasterOfVegaGame from './games/mastervega/MasterOfVegaGame.js';
|
|
import VegaCombatSim from './games/mastervega/VegaCombatSim.js';
|
|
import WolfensteinGame from './games/wolfenstein/WolfensteinGame.js';
|
|
import WolfensteinEditor from './games/wolfenstein/WolfensteinEditor.js';
|
|
|
|
const config = {
|
|
type: Phaser.AUTO,
|
|
parent: 'game-container',
|
|
backgroundColor: COLORS.bgHex,
|
|
scale: {
|
|
mode: Phaser.Scale.FIT,
|
|
autoCenter: Phaser.Scale.CENTER_BOTH,
|
|
width: GAME_WIDTH,
|
|
height: GAME_HEIGHT,
|
|
},
|
|
dom: { createContainer: true },
|
|
scene: [
|
|
BootScene,
|
|
PreloadScene,
|
|
LandingScene,
|
|
ProfileScene,
|
|
GameMenuScene,
|
|
OpponentSelectScene,
|
|
GameRoomScene,
|
|
BackgammonGame,
|
|
HoldemGame,
|
|
BlackjackGame,
|
|
ParchisiGame,
|
|
YatziGame,
|
|
SkipBoGame,
|
|
Phase10Game,
|
|
ChineseCheckersGame,
|
|
GoFishGame,
|
|
UnoGame,
|
|
CrapsGame,
|
|
RouletteGame,
|
|
MexicanTrainGame,
|
|
HeartsGame,
|
|
CatanGame,
|
|
TicketToRideGame,
|
|
NertsGame,
|
|
BingoGame,
|
|
BaccaratGame,
|
|
DominionGame,
|
|
CheckersGame,
|
|
ChessGame,
|
|
WordleGame,
|
|
ScrabbleGame,
|
|
GhostGame,
|
|
WordLadderGame,
|
|
WordSearchGame,
|
|
HangmanGame,
|
|
SudokuGame,
|
|
OthelloGame,
|
|
GoGame,
|
|
BattleshipGame,
|
|
MastermindGame,
|
|
Connect4Game,
|
|
BoggleGame,
|
|
OldMaidGame,
|
|
BlokusGame,
|
|
SpellingBeeGame,
|
|
MiniCrosswordGame,
|
|
ForbiddenIslandGame,
|
|
SolitaireTourGame,
|
|
SplendorGame,
|
|
TectonicGame,
|
|
LabyrinthGame,
|
|
VideoPokerGame,
|
|
FarkelGame,
|
|
StrategoGame,
|
|
KiitosGame,
|
|
MonopolyGame,
|
|
TriominoesGame,
|
|
FreecellGame,
|
|
RushHourGame,
|
|
HexsweeperGame,
|
|
PuddingMonstersGame,
|
|
ShiftGame,
|
|
BlockFighterGame,
|
|
MahjongMatchGame,
|
|
MahjongGame,
|
|
JewelQuestGame,
|
|
ZumaGame,
|
|
ZumaEditor,
|
|
BejeweledGame,
|
|
MiniMotorwaysGame,
|
|
SlotsGame,
|
|
CribbageGame,
|
|
CanastaGame,
|
|
DotLinkGame,
|
|
Game2048,
|
|
RummikubGame,
|
|
GinRummyGame,
|
|
RiskGame,
|
|
GeniusSquareGame,
|
|
KataminoGame,
|
|
BookworkGame,
|
|
PaiGowPokerGame,
|
|
SpireClimbGame,
|
|
AzulGame,
|
|
JumbleGame,
|
|
DungeonBossGame,
|
|
SWDBGGame,
|
|
BalatroGame,
|
|
PeggleGame,
|
|
PeggleEditor,
|
|
ColoradoDefenseGame,
|
|
StarControlGame,
|
|
CivilizationGame,
|
|
TempestGame,
|
|
SuperKartGame,
|
|
SuperKartEditor,
|
|
AdvanceWarsGame,
|
|
TetrisAttackGame,
|
|
TotalAnnihilationGame,
|
|
BloxorzGame,
|
|
GooTowerGame,
|
|
ExcitebikeGame,
|
|
MasterOfVegaGame,
|
|
VegaCombatSim,
|
|
GooTowerEditor,
|
|
WolfensteinGame,
|
|
WolfensteinEditor,
|
|
],
|
|
};
|
|
|
|
const game = new Phaser.Game(config);
|
|
// Devtools console hook — Phaser itself doesn't track running instances
|
|
// anywhere reachable from outside the module, so there is no way to get back
|
|
// to a live game/scene/state from the console without this. Harmless in a
|
|
// locally-served dev build; not something a production site would want.
|
|
window.game = game;
|
|
|
|
// Phaser positions its DOM overlay container with margins only (no explicit
|
|
// left/top); under Scale.FIT the absolutely-positioned container drifts away
|
|
// from the letterboxed canvas as the viewport narrows, dragging DOM video
|
|
// portraits below their canvas targets. Pin the container to the canvas's real
|
|
// box on every resize so game coordinates map exactly onto the canvas.
|
|
function syncDomContainer() {
|
|
const container = game.domContainer;
|
|
const canvas = game.scale.canvas;
|
|
if (!container || !canvas) return;
|
|
const baseW = game.scale.gameSize.width;
|
|
const baseH = game.scale.gameSize.height;
|
|
const rect = canvas.getBoundingClientRect();
|
|
const parent = container.offsetParent;
|
|
const pRect = parent ? parent.getBoundingClientRect() : { left: 0, top: 0 };
|
|
const st = container.style;
|
|
st.margin = '0';
|
|
st.transformOrigin = 'left top';
|
|
st.left = `${rect.left - pRect.left}px`;
|
|
st.top = `${rect.top - pRect.top}px`;
|
|
st.transform = `scale(${rect.width / baseW}, ${rect.height / baseH})`;
|
|
}
|
|
|
|
game.scale.on('resize', syncDomContainer);
|
|
game.events.once('ready', syncDomContainer);
|