From 6405aedaa7a3da339cf8116d769648689ba2fbc8 Mon Sep 17 00:00:00 2001 From: Pabloader Date: Tue, 9 Jul 2024 12:38:03 +0000 Subject: [PATCH] Add README, more examples and audio imports --- README.md | 107 ++++++++++++++++++++++++- src/build/audioPlugin.ts | 32 ++++++++ src/build/build.ts | 9 ++- src/build/html.ts | 2 + src/common/types.d.ts | 12 +++ src/games/brick-dungeon/index.ts | 2 +- src/games/playground/assets/attack.wav | Bin 0 -> 6426 bytes src/games/playground/awoo.wasm.ts | 3 + src/games/playground/index.tsx | 14 ++++ tsconfig.json | 3 +- 10 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 src/build/audioPlugin.ts create mode 100644 src/games/playground/assets/attack.wav create mode 100644 src/games/playground/awoo.wasm.ts create mode 100644 src/games/playground/index.tsx diff --git a/README.md b/README.md index 9dbc06c..b1122b3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,117 @@ # TS-Games -To install dependencies: +Custom framework/build system for simple single-file TypeScript games. + +## Installing dependencies + +- Install bun (https://bun.sh/) ```bash bun install ``` -To run: +## Make a game + +- Create your game folder in [src/games](src/games) +- Create `src/games//index.ts` with default exported function. + +## Running: ```bash bun start ``` +Navigate to `http://localhost:3000` to see the list of your games. +Game rebuilds on each reload. +## Building + +```bash +bun run build +``` +Will create `.html` in `dist` folder. + +Or to select project from list: + +```bash +bun run build +``` + +## Features + +- Bun ♥ +- TypeScript +- Building into single `.html` file without any dependencies, all assets are inlined as data-urls. + - `src/games//assets/favicon.ico` is used as page icon if present. + +- TSX supported with [Preact](https://preactjs.com/), because it's lightweight. + +- Import images as `HTMLImageElement` + - PNG & JPG + ```typescript + import spritesheet from './assets/spritesheet.png'; + console.log(spritesheet); // + ``` + +- Import audio as `HTMLAudioElement` + - WAV, MP3 & OGG + ```typescript + import heal from './assets/heal.ogg'; + console.log(heal); //