Crates.io | deno_sdl2 |
lib.rs | deno_sdl2 |
version | 0.3.1 |
source | src |
created_at | 2022-02-06 14:31:10.44538 |
updated_at | 2022-02-06 17:20:51.31499 |
description | SDL2 Bindings to Deno |
homepage | |
repository | https://github.com/littledivy/deno_sdl2 |
max_upload_size | |
id | 527861 |
size | 3,434,983 |
Cross platform bindings to SDL2. Have fun!
import { Canvas } from "https://deno.land/x/sdl2/src/canvas.ts";
const canvas = new Canvas({
title: "Hello, Deno!",
height: 800,
width: 600,
centered: true,
fullscreen: false,
hidden: false,
resizable: true,
minimized: false,
maximized: false,
flags: null,
});
canvas.setDrawColor(0, 64, 255, 255);
canvas.clear();
canvas.present();
for await (const event of canvas) {
switch (event.type) {
case "draw":
// Your game logic
// ...
break;
case "mouse_motion":
// Mouse stuff
break;
case "key_down":
// Keyboard stuff
break;
// ...
default:
break;
}
}
You need:
deno_bindgen
CLI from the
main
branch1.57.0-nightly
)cargo-vcpkg
toolpkg-config
(on *nix) => brew install pkg-config
deno install -Afq -n deno_bindgen https://deno.land/x/deno_bindgen/cli.ts
cargo install cargo-vcpkg
# build vcpkg dependencies
cargo vcpkg -v build
Build using:
deno_bindgen -- --features "use_vcpkg"
deno_sdl2
...insert your project here
MIT