Skip to content

Quick Start

Installing the Framework

Make sure you have an up-to-date version of Node.js installed and your current working directory is the one where you intend to create a project. Run the following command in your command line:

Terminal window
npm i dill-pixel

“Hello World” Example

The most basic example of a dill pixel game is a simple “Hello World” message. Let’s get started…

Hello world example

Create the Files

  1. First, create a package.json in your project’s root directory:

    package.json
    {
    "name": "my-dill-pixel-game",
    "version": "0.0.0",
    "description": "Hello World with dill pixel",
    "main": "index.html",
    "type": "module",
    "scripts": {
    "start": "vite",
    "dev": "vite",
    "build": "vite build"
    },
    "author": "Me<me@myname.com>",
    "dependencies": {
    "dill-pixel": "^3.1.9",
    "typescript": "^5",
    "vite": "^5"
    }
    }
  2. Next, create an index.html file in the root directory:

    index.html
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <title>My dill pixel Game</title>
    </head>
    <body>
    <script type="module" src="src/index.ts" async defer></script>
    </body>
    </html>
  3. Create an index.css file in the src directory:

    src/index.css
    body,
    html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    position: fixed;
    overflow: hidden;
    }
    #game-container {
    width: 100%;
    height: 100%;
    border: none;
    }
  4. Create the remaining files in the src directory:

    import { create } from 'dill-pixel';
    import { Application } from './Application';
    import './index.css';
    // Create the application
    create(Application, {
    antialias: false,
    resizeOptions: {
    minSize: { width: 375, height: 700 },
    },
    resolution: Math.max(window.devicePixelRatio, 2),
    backgroundColor: 0x0,
    });

Your project directory should look like this:

  • package.json
  • index.html
  • Directorysrc
    • index.css
    • index.ts
    • Application.ts
    • Directorystate
      • LoadScreen.ts
      • MyScreen.ts

Install the Dependencies

Once you have created the files, install the dependencies:

Terminal window
npm install

Start the Dev Server

Terminal window
npm run dev

Build for Production

Terminal window
npm run build