Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jozanza committed Feb 22, 2020
1 parent 9468884 commit 6418cbe
Show file tree
Hide file tree
Showing 18 changed files with 21,994 additions and 3 deletions.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# 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)

```
Loading

0 comments on commit 6418cbe

Please sign in to comment.