zetsin / node-sdl2

Bindings for SDL2 in Node
54 stars 14 forks source link

node-sdl2

Bindings for SDL2 in Node

Installation

Install with npm:

npm install node-sdl2

Usage

1. Use with wrapped class ( Api Reference )

const NS = require('node-sdl2')
const App = NS.app
const Window = NS.window

let win = new Window
win.on('close', () => {
  App.quit()
})
win.on('change', () => {
  draw()
})

let draw = () => {
  ...
}

2. Use as primitive SDL2 API ( SDL 2.0 API by Category )

const NS = require('node-sdl2')
const SDL2_video = NS.require('SDL2_video')
const SDL2_render = NS.require('SDl2_render')
...

Tutorials

Screenshot

Screenshot

API References

app

Control your application's event lifecycle.

window

Create and control window(s).

clipboard

Get and set the clipboard text.

keyboard

Control the keyboard.

mouse

Control the mouse and cursor.

power

Moniter the power infomation of hardware

font

Allow you drawing text into window's face. please npm install sdl2-ttf before use.

image

Load image from file. please npm install sdl2-image before use.