# wand-js

> wand js utils for wand and dragon

Latest version **0.0.2** (published 2020-04-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install wand-js
pnpm add wand-js
yarn add wand-js
bun add wand-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-04-18 |
| First published | 2020-04-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stefan Liu |
| Maintainers | devfans |
| Keywords | game, asset |

## Links

- npm: https://www.npmjs.com/package/wand-js
- Repository: https://github.com/devfans/wand-js
- Homepage: https://github.com/devfans/wand-js#readme
- Issues: https://github.com/devfans/wand-js/issues
- npm.io page: https://npm.io/package/wand-js

## Recent versions

- 0.0.2 (latest) — 2020-04-18
- 0.0.1 — 2020-04-17

## README

## Wand JS

A simple library to manage asset bundles and input for games, especially for wand (https://github.com/devfans/wand) and dragon(https://github.com/devfans/dragon)

## Get Started

```
const wand = require('wand-js')

class Game {
  constructor (options={}) {
    this.audios = options.audios
    this.images = options.images
    this.ab = options.ab
    this.init()
  }

  init() {
    this.mixer = this.audios.newMixer()
    const canvas = document.getElementById("canvas");
    const ctx = canvas.getContext('2d')
    this.scene = this.images.newScene({ctx})
    this.audios.add('explosion', 'explosion_1', {
      url: '/sound/explosion_1.ogg'
    })

    this.audios.add('bgm', 'bgm', {
      url: '/sound/powerup_pick.ogg'
    })
    this.images.add('tank', 'tank', {
      url: '/img/general_sprites.png'
    })
    this.scene.add('tank', 'tank', {
      h: 40,
      w: 37
    })
    this.input = new wand.Panel({ctx})
    const button = new wand.Button('A', {
      x: 200,
      y: 200,
      r: 100
    })
    this.input.register(button)
  }

  play_audio(name) {
    this.mixer.play(name)
  }

  draw_sprite(name, x, y) {
    this.scene.draw(name, x, y)
  }

  preTick() {
    this.input.tick();
  }

  tick() {
    this.input.render();
  }

  buttonPressed (name) {
    return this.input.keyup(name)
  }
}

const newGame = () => {
  const game = new Game({
    audios: wand.Audios,
    images: wand.Images,
    ab: wand.AB
  })
  return game
}

```

---
_Source: https://npm.io/package/wand-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
