Modern web game template built with Phaser 3, TypeScript, and Vite.
- Phaser 3 - Powerful HTML5 game framework
- TypeScript - Type-safe development
- Vite - Fast build tool and dev server
- Clean Architecture - Well-organized project structure
- CI/CD - Automated deployment to GitHub Pages
template-web-game/
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Actions CI/CD workflow
├── public/ # Static assets (favicon, etc.)
├── src/
│ ├── scenes/ # Game scenes
│ │ ├── PreloadScene.ts # Asset loading scene
│ │ └── GameScene.ts # Main game scene
│ ├── assets/ # Game assets
│ │ ├── images/ # Images and sprites
│ │ └── audio/ # Sound effects and music
│ └── main.ts # Entry point
├── index.html # Main HTML file
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite configuration
└── README.md # This file
- Node.js 18 or higher
- npm or yarn
- Clone the repository:
git clone https://github.com/pnstack/template-web-game.git
cd template-web-game- Install dependencies:
npm installStart the development server:
npm run devThe game will be available at http://localhost:5173
Build for production:
npm run buildThe built files will be in the dist directory.
Preview the production build locally:
npm run preview- Create a new scene file in
src/scenes/:
importPhaserfrom'phaser';exportclassMySceneextendsPhaser.Scene{constructor(){super({key: 'MyScene'});}create(){// Your scene logic here}update(){// Update logic here}}- Register the scene in
src/main.ts:
import{MyScene}from'./scenes/MyScene';constconfig: Phaser.Types.Core.GameConfig={// ...scene: [PreloadScene,MyScene,GameScene],};- Place your assets in
src/assets/images/orsrc/assets/audio/ - Import and load them in
PreloadScene.ts:
importlogoImagefrom'@/assets/images/logo.png';importmusicAudiofrom'@/assets/audio/music.mp3';preload(){this.load.image('logo',logoImage);this.load.audio('music',musicAudio);}Or for assets in the public/ folder (copied as-is):
preload(){this.load.image('logo','/logo.png');}The project is configured to automatically deploy to GitHub Pages when you push to the main branch.
- Go to your repository settings
- Navigate to "Pages" section
- Under "Build and deployment", select:
- Source: "GitHub Actions"
The game will be available at: https://pnstack.github.io/template-web-game/
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to submit issues and pull requests.