JoshuaKGoldberg / StarCorn

🌟🌽 Fly through the galaxy! Eat your vegetables! 🌽🌟
MIT License
2 stars 0 forks source link

StarCorn

Greenkeeper badge Build Status NPM version

🌟🌽 Fly through the galaxy! Eat your vegetables! 🌽🌟

2018 birthday present for my girlfriend. Shhh!

Usage

The built src/index.html uses UserWrappr to fill the available window size with a game screen, option menus, and piped input events. It stores its generated instance as window.SC.

To do this in your own page, use the exported createStarCornInterface function.

import { createStarCornInterface } from "StarCorn";

createStarCornInterface(document.getElementById("game"))
    .then(() => {
        console.log("Ready to play!");
        console.log(SC);
    });

You can also directly create a new StarCorn instance with a manual size.

import { StarCorn } from "starcorn";

// Creates a new game with a 320x480 screen size
const game = new StarCorn({
    height: 320,
    width: 480,
});

// Games contain a .canvas member for the screen
document.body.appendChild(game.canvas);

// Shows the initial in-game menu with start and load options
game.gameplay.gameStart();

By default, the game doesn't set up input events. You'll need to set up your own event registrations manually.

Documentation

StarCorn is built on top of GameStartr, a modular TypeScript game engine split across separate projects available on npm and hosted on GitHub in the FullScreenShenanigans organization. It consists of a couple dozen core modules under this organization.

Development

After forking the repo from GitHub:

git clone https://github.com/<your-name-here>/StarCorn
cd StarCorn
npm install
npm run setup
npm run verify

Building

npm run watch

Source files are written under src/ in TypeScript and compile in-place to JavaScript files. npm run watch will directly run the TypeScript compiler on source files in watch mode. Use it in the background while developing to keep the compiled files up-to-date.

Running Tests

npm run test

Test files are alongside source files under src/ and named *.test.ts?. Whenever you add, remove, or rename a *.test.t* file under src/, watch will re-run npm run test:setup to regenerate the list of static test files in test/index.html. You can open that file in a browser to debug through the tests. npm run test:run will run that setup and execute tests using Puppeteer.