|
1 |
| -# Carrot Web Game Template |
| 1 | +# Carrot Web Game Template (Apps/Packages Layout) |
2 | 2 |
|
3 |
| - |
4 |
| - |
5 |
| - |
| 3 | +A simple, modular, and extensible web game template based on React, TypeScript, and Vite. Optimized for itch.io and GitHub Pages. This repo is organized for easy reuse and low-maintenance updates. |
6 | 4 |
|
7 |
| -A simple, modular, and extensible web game template based on React, TypeScript, and Vite. Designed for rapid prototyping and building games for platforms like **itch.io** and **GitHub Pages**. |
| 5 | +- Game apps live in `apps/*` (demo apps included) |
| 6 | +- Reusable code lives in `packages/*` and shared configs in `configs/*` |
| 7 | +- Consumers can either manually copy changes or run a tiny sync script (A+ workflow) |
8 | 8 |
|
9 |
| -> **Note**: For detailed technical documentation, please refer to our **[Full Documentation](./docs/README.md)**. |
| 9 | +## Quick Start |
10 | 10 |
|
11 |
| -> **[➡️ Try the Live Demo!](https://tobenot.top/Basic-Web-Game/)** |
12 |
| -
|
13 |
| - |
14 |
| - |
15 |
| -Play Beyond Books on Itch.io based on this project! |
16 |
| - |
17 |
| -[](https://tobenot.itch.io/beyond-books) |
18 |
| - |
19 |
| ---- |
20 |
| - |
21 |
| -## Why Carrot Web Game Template? |
22 |
| - |
23 |
| -While you can always build a project from scratch with `create-react-app`, this template is specifically optimized for web game development, saving you from common setup headaches: |
24 |
| - |
25 |
| -- **Game-Centric Architecture**: Separates the core engine (`carrot`) from game-specific logic (`games`), promoting organized, reusable code. |
26 |
| -- **One-Command Deployments**: Built-in scripts for **itch.io** and **GitHub Pages** that automatically handle tricky path configurations, letting you focus on your game. |
27 |
| -- **Essential Components Included**: Comes with pre-built, customizable components like `ImageLoader`, `TypewriterText`, and `GameShell` for aspect ratio and screen orientation control. |
28 |
| - |
29 |
| -## 🗺️ Roadmap & TODO |
30 |
| - |
31 |
| -This template is actively evolving. Here are the key features planned for the near future. Contributions are highly welcome! |
32 |
| - |
33 |
| -- [ ] **Core Systems** |
34 |
| - - [ ] **LLM/AI Integration**: A generic module for calling large language models, enabling dynamic narrative and NPC interactions. |
35 |
| - - [ ] **Audio Manager**: A robust service for handling background music and sound effects. |
36 |
| - - [ ] **Localization (i18n) System**: A simple framework for supporting multiple languages. |
37 |
| -- [ ] **Performance Optimization**: Focus on code splitting and asset optimization for faster load times. |
38 |
| -- [ ] **Backend Support**: Develop a companion backend template for handling player data or game state persistence. (Vision: [Basic-Web-Game-Backend](https://github.com/tobenot/Basic-Web-Game-Backend)) |
39 |
| - |
40 |
| -## ✨ Features |
41 |
| - |
42 |
| -- **Modular Architecture**: Core engine (`carrot`) is separated from game-specific logic (`games`). |
43 |
| -- **React + TypeScript**: Modern, type-safe UI development with reusable core components. |
44 |
| -- **Vite Powered**: Fast development server and optimized builds. |
45 |
| -- **Automated Deployments**: |
46 |
| - - Built-in script (`npm run build:itch`) to version, build, and package your game for **itch.io**. |
47 |
| - - Streamlined deployment to **GitHub Pages** via `npm run deploy`. |
48 |
| -- **Easy to Customize**: A clean starting point for your next web game. |
49 |
| - |
50 |
| -## 🚀 Getting Started |
51 |
| - |
52 |
| -### Prerequisites |
53 |
| - |
54 |
| -- Node.js 18+ |
55 |
| -- npm or yarn |
56 |
| - |
57 |
| -### Installation & Development |
58 |
| - |
59 |
| -1. Clone this repository or use it as a template. |
60 |
| -2. Install dependencies: |
61 |
| - ```bash |
62 |
| - npm install |
63 |
| - ``` |
64 |
| -3. Start the development server: |
65 |
| - ```bash |
66 |
| - npm run dev |
67 |
| - ``` |
68 |
| - Your game will be running at `http://localhost:5173`. |
69 |
| - |
70 |
| -## 📦 Building for Production |
71 |
| - |
72 |
| -To create a production-ready build, run: |
| 11 | +1. Install deps |
| 12 | +```bash |
| 13 | +npm install |
| 14 | +``` |
| 15 | +2. Dev server |
| 16 | +```bash |
| 17 | +npm run dev |
| 18 | +``` |
| 19 | +3. Build |
73 | 20 | ```bash
|
74 | 21 | npm run build
|
75 | 22 | ```
|
76 |
| -This will generate a `dist` directory with all your game files. |
77 | 23 |
|
78 |
| -- **For itch.io**: Use `npm run build:itch`. This command automatically versions, builds, and packages your game into a `.zip` file, ready for upload. |
79 |
| -- **For GitHub Pages**: Before deploying, ensure the `name` field in `package.json` matches your GitHub repository name. Then, use `npm run deploy`. |
80 |
| - |
81 |
| -> For more details on build commands and local testing, see the [Build and Deployment section in our documentation](./docs/05-build-and-deploy.md). |
82 |
| - |
83 |
| -## 📂 Project Structure |
| 24 | +## Project Structure |
84 | 25 |
|
85 | 26 | ```
|
86 | 27 | /
|
87 |
| -├── dist/ # Production build output |
88 |
| -├── docs/ # Detailed project documentation |
89 |
| -├── public/ # Static assets (images, fonts, config files) |
90 |
| -│ └── version.json # Auto-versioning for itch.io builds |
91 |
| -├── src/ # Source code |
92 |
| -│ ├── carrot/ # The core engine/template |
93 |
| -│ ├── games/ # Houses all specific game projects |
94 |
| -│ └── ... |
95 |
| -├── scripts/ |
96 |
| -│ └── build-itch.js # Script for versioning and packaging for itch.io |
97 |
| -├── .github/ # GitHub-specific files (e.g., workflows) |
98 |
| -└── ... |
| 28 | +├── apps/ |
| 29 | +│ └── web/ # Main web app (Vite root) |
| 30 | +│ ├── public/ |
| 31 | +│ ├── src/ |
| 32 | +│ │ ├── games/ # Demo apps (carrot-card-demo, demo-with-backend, portal) |
| 33 | +│ │ └── ... |
| 34 | +│ └── index.html |
| 35 | +├── packages/ |
| 36 | +│ ├── ui/ # Reusable UI components (ImageLoader, TypewriterText, GameShell, ...) |
| 37 | +│ └── services/ # Reusable services (ResourceLoader, ...) |
| 38 | +├── scripts/ # Build and helper scripts |
| 39 | +│ ├── build-itch.js |
| 40 | +│ └── update-from-template.sh |
| 41 | +├── sync.manifest # Whitelist for template sync (A+) |
| 42 | +├── docs/ # Detailed documentation |
| 43 | +├── vite.config.ts # Vite config points to apps/web as root, outputs to /dist |
| 44 | +└── tailwind.config.js # Tailwind scans apps and packages |
99 | 45 | ```
|
100 | 46 |
|
101 |
| -A more detailed breakdown of the project structure is available in [our documentation](./docs/02-project-structure.md). |
| 47 | +## A+ Template Sync (optional, zero lock-in) |
102 | 48 |
|
103 |
| -## 🎨 Customization |
| 49 | +- For teams preferring manual copy, keep doing that. |
| 50 | +- Alternatively, use the included script to copy only template-managed files from this repo. |
104 | 51 |
|
105 |
| -To create your own game, follow the detailed guide in [our documentation](./docs/04-creation-and-extension.md). |
106 |
| -
|
107 |
| -## 🤝 Contributing |
| 52 | +Configure your project (optional): |
| 53 | +``` |
| 54 | +# .template-source |
| 55 | +TEMPLATE_REPO=https://your.host/your-template.git |
| 56 | +TEMPLATE_REF=main |
| 57 | +MANIFEST_FILE=sync.manifest |
| 58 | +``` |
108 | 59 |
|
109 |
| -Contributions are welcome! If you have ideas for improvements or find a bug, please first read our **[Contribution Guide](./docs/06-contributing.md)** and check out the issues page. |
| 60 | +Run sync in your project root: |
| 61 | +```bash |
| 62 | +bash scripts/update-from-template.sh |
| 63 | +``` |
| 64 | +- Backs up overwritten files to `.template_backups/<timestamp>` |
| 65 | +- Copies only paths listed in `sync.manifest` |
110 | 66 |
|
111 |
| -### 💡 Help Wanted |
| 67 | +## Build & Deploy |
112 | 68 |
|
113 |
| -We are actively looking for help in the following areas: |
114 |
| -- **More Core Components**: Ideas for reusable UI or logic components (e.g., `SoundManager`, `SpriteAnimation`). |
115 |
| -- **Documentation**: Improving existing docs or adding translations. |
116 |
| -- **Game Samples**: Creating more diverse game examples to showcase the engine's capabilities. |
| 69 | +- itch.io: `npm run build:itch` produces `/dist/*.zip` |
| 70 | +- GitHub Pages: `npm run build:pages && npm run deploy` |
117 | 71 |
|
118 |
| -## 📄 License |
| 72 | +## Notes |
| 73 | +- `import.meta.env.BASE_URL` is respected; `ResourceLoader` uses it to resolve assets. |
| 74 | +- Tailwind scans `apps/web` and `packages/*`. |
| 75 | +- Aliases: |
| 76 | + - `@` -> `apps/web/src` |
| 77 | + - `@ui` -> `packages/ui/src` |
| 78 | + - `@services` -> `packages/services/src` |
119 | 79 |
|
120 |
| -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 80 | +See `docs/` for details. |
0 commit comments