1
0
Fork 0
Go to file
Pabloader 1e60e63213 Fix links 2024-07-09 12:39:59 +00:00
src Add README, more examples and audio imports 2024-07-09 12:38:03 +00:00
.gitignore UI 2024-06-26 16:07:41 +00:00
README.md Fix links 2024-07-09 12:39:59 +00:00
bun.lockb Async imports support, aggressive uglifying 2024-07-08 21:19:02 +00:00
package.json Async imports support, aggressive uglifying 2024-07-08 21:19:02 +00:00
tsconfig.json Add README, more examples and audio imports 2024-07-09 12:38:03 +00:00

README.md

TS-Games

Custom framework/build system for simple single-file TypeScript games.

Installing dependencies

bun install

Make a game

  • Create your game folder in src/games
  • Create src/games/<yourgame>/index.ts with default exported function.

Running:

bun start

Navigate to http://localhost:3000 to see the list of your games. Game rebuilds on each reload.

Building

bun run build <project>

Will create <project>.html in dist folder.

Or to select project from list:

bun run build

Features

  • Bun ♥

  • TypeScript

  • Building into single .html file without any dependencies, all assets are inlined as data-urls.

    • src/games/<yourgame>/assets/favicon.ico is used as page icon if present.
  • TSX supported with Preact, because it's lightweight.

  • Import images as HTMLImageElement

    • PNG & JPG
      import spritesheet from './assets/spritesheet.png';
      console.log(spritesheet); // <img src="data:..." />
      
  • Import audio as HTMLAudioElement

    • WAV, MP3 & OGG
      import heal from './assets/heal.ogg';
      console.log(heal); // <audio src="data:..." />
      heal.play()
      
  • Import css with LigntningCSS

    • Regular CSS

      import "./assets/styles.css";
      
    • CSS modules is supported

      import styles from './assets/styles.module.css';
      console.log(styles.awoo); // G7sddg_awoo
      
      export default <div className={styles.root}></div>;
      
    • Modern CSS features are transpiled

      • Nested CSS
        .root {
            display: flex;
            .row {
                display: flex;
                flex-direction: row;
            }
        }
        
      • Vendor prefixed if needed
    • Import fonts (see example)

      import "./assets/lcd.font.css";
      
  • AssemblyScript support (TypeScript-like language compiled into WebAssembly)

    • Example
    • Triggered by file name *.wasm.ts

Publishing

  • Make sure you have scp installed (it most certainly is)

  • Make .env file

    PUBLISH_LOCATION=ssh.example.com:/var/www/games/
    PUBLISH_URL=https://example.com/
    
  • Run build & publish

    bun run build <project>
    

    Or to select project from list:

    bun run build