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

jammer

v2.0.1

Published

Minimalist game server to speed up your game jam

Downloads

6

Readme

Jammer - A server for your game jam

Jammer is a ready-to-use game server to speed up game creation in the context of game jams.

It is written in Javascript so it focuses on web based games.

It is designed for games with multiple players playing simultaneously on the same screen.

Install

Install node.js, then:

npm install jammer -g

Usage

jammer

This will generate all the files you need in the current working directory and run npm install automatically:

public/game.html
public/player.html
public/js/gameClient.js
public/js/gameServer.js
server.js
package.json
node_modules/

Then:

node server.js

And you have a server listening on port 4321. To start the server listening on port 7890:

node server.js -p 7890

To generate the files at a specific path:

jammer /path/to/destination/

Documentation

Examples

The generated files include an example showing the basics.

public/player.html
public/game.html

They include or the Javascript files:

public/js/gameClient.js
public/js/gameServer.js

There is a global depedency on socket.io, so make sure to include it (see example).

Game examples using jammer

  • TwinFusion: made at a game jam, but using a previous version (different API).
  • Squame: proof of concept for jammer.

GameServer

var gameServer = new GameServer();
var players = {};
gameServer.on('gameID', function (gameID) {
    // display the game ID on screen for the players
});

gameServer.on('newPlayer', function (player) {
    // player connected
    var playerID = player.id;
    players[playerID] = player; // save it for later use
    player.x = Math.random() * 500;
    player.y = Math.random() * 500;
    player.size = 50;

    // Player listeners
    // Example of a player event: changeSize
    player.on('changeSize', function (size) {
        player.size = size || 50;
    });

    // Send command to the player
    player.send('changeColor', '#FF0000');

    player.on('disconnect', function () {
        delete players[player.id];
    });
});

GameClient

var gameClient = new GameClient();
gameClient.join(12); // join the game 12

gameClient.on('joined', function () {
    // player joined, do something with it, for example change the size
    gameClient.send('changeSize', Math.random() * 100 + 100);
});

gameClient.on('changeColor', function (color) {
  // change the color of the player
});

List of defaults events and actions

On the game side

gameServer.on('gameID', function (gameID) {
    // Do something here to display the game ID on the screen for the players
});
gameServer.on('newPlayer', function (player) {
    // A new player just joined, do something with the player object, store it for later use

    // Default events for the player
    player.on('disconnect', function () {
        // Player disconnected, do something with, remove it from the game for example
    });
});
gameServer.on('disconnect', function (player) {
    // The game disconnected, could be due to network problems, display something to the players or die silently
});

On the player side

// join game number 2
gameClient.join(2);

gameClient.on('joined', function () {
   // the player joined the game, display controller or anything else
});

Motivation

A game jam is all about making a great game fast, so you shouldn't spend to much time in repetitive and time consuming tasks. If you want to go for a multi-player game, you are going to spend quite a lot of time on the network part, testing it, debugging it.

This idea popped up after using HappyFunTimes in a game jam. HappyFunTimes is great, but is limited to a local network. The missing part for us was to be able to put the game online to make it accessible by everyone. Jammer uses game sessions to make it work with multiple game running at the same time.

License

MIT