Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jozanza committed Feb 22, 2020
1 parent e343d2b commit e059824
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 3,519 deletions.
102 changes: 37 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,37 @@
# starship

Here's a basic "Hello, world!" example:

```ts
import {
StarshipConfig,
StarshipInit,
StarshipDestroy,
StarshipUpdate,
run,
drawText,
FONT_8x8,
isButtonDown,
Button,
} from '@vsmode/starship'

// The game state
interface GameState {
x: 0
y: 0
}

// Set game configuration options
const config: StarshipConfig = {
title: 'My Game',
canvas: { x: 256, y: 144 },
fps: 60,
}

// Creates the initial game state
const init: StarshipInit<GameState> = () => {
return {
x: 0,
y: 0,
}
}

// Do any clean up here before the game ends
const destroy: StarshipDestroy<GameState> = _ => {
// ...
}

// This runs every frame
const update: StarshipUpdate<GameState> = (state, _) => {
clear()
drawText(FONT_8x8, 'Hello, World!', state)
if (isButtonDown(Button.Up)) {
state.y--
}
if (isButtonDown(Button.Down)) {
state.y++
}
if (isButtonDown(Button.Left)) {
state.x--
}
if (isButtonDown(Button.Right)) {
state.x++
}
}

// Start the game! :)
run(config, init, destroy, update)

```
# 🚀 Starship

<img src="https://raster.shields.io/npm/v/@vsmode/starship?style=for-the-badge" />

Simple 2D game framework with no dependencies

## Installation

```bash
npm i @vsmode/starship
```

## API

Full API documentation can be found on the website.

### [View API Docs &rarr;](https://vsmode.github.io/starship/)

## Examples

Check out these basic examples to see how to get started.

### Drawing Text

Learn how to display the text "Hello, World!" in the middle of the screen.

![Hello, World](https://screenshots.codesandbox.io/eqoqv.png)

[![Edit autumn-water-eqoqv](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/autumn-water-eqoqv?fontsize=14&hidenavigation=1&theme=dark)

### Handling Button Input

Learn how to move a rectangle around with the arrow keys.

![Handling Buttonn Input](https://screenshots.codesandbox.io/1o6h7.png)

[![Edit dreamy-grothendieck-1o6h7](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/dreamy-grothendieck-1o6h7?fontsize=14&hidenavigation=1&theme=dark)
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e059824

Please sign in to comment.