npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-game

v1.0.5

Published

The fastest way to get started making WebGL games.

Downloads

26

Readme

create-game

The fastest way to get started writing WebGL games.

This is a small library that makes getting started with a new WebGL game quick and easy. It has one function, createGame, which takes two objects as its parameters, your callbacks and your configuration options.

All callbacks are optional, missing callbacks are simply ignored.

Most configuration options are optional, save for canvas which is necessary for create-game to know where it should acquire its WebGL context. For the other options, sensible defaults are used.

Rendering, state management, physics, networking, and any other functionality you might want are out of the scope of this library. You are free to use whichever other libraries you see fit for those purposes.

Install

npm install create-game --save

Usage

import createGame from 'create-game';

createGame({
  create: () => {
    // your asset loading and initialization code here
  },
  render: (canvas, gl) => {
    // your rendering code here
  },
  update: () => {
    // your update code here
  }
}, {
  canvas: document.getElementById('my-canvas') // use your canvas here
});

Options

The following options are available:

  • canvas takes a canvas DOM element, which is used for rendering.
  • renderInterval takes a number that determines how many milliseconds should pass between two invocations of the render callback. The default value is 60 frames per second.
  • updateInterval takes a number that determines how many milliseconds should pass between two invocations of the update callback. The default value is 60 updates per second.

Callbacks

The following callbacks are available:

  • create(gl) is called once before the loop starts. Initialize your state and load your assets here.
  • render(gl) is called every renderInterval milliseconds, and is the place to do your rendering.
  • update() is called every updateInterval milliseconds, and is the place to do your state updates.
  • onClick(x, y) is called when the mouse is clicked.
  • onKeyDown(key, keyCode) is called when a key is pressed.
  • onKeyUp(key, keyCode) is called when a key is released.
  • onMouseDown(x, y) is called when the mouse is pressed.
  • onMouseMove(x, y) is called when the mouse is moved.
  • onMouseUp(x, y) is called when the mouse is released.
  • onResize(gl) is called when the window is resized.