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

varley

v0.1.6

Published

A multiplayer game engine with rapid prototyping as its sole focus. Intended to be used for game jams with limited time, such as the 1 hour game jam.

Downloads

37

Readme

Varley

npm version License: MIT

A multiplayer game engine with rapid prototyping as its sole focus. Intended to be used for game jams with limited time, such as the 1 hour game jam.

Features

  • Multiplayer.
  • Top down and platformer movement, including collisions.
  • Animations, sprite sheets.
  • Matchmaking, lobby: you can start games with a minimum and maximum number of players, and there can be multiple games running at the same time.
  • Game state diffing: only the data that has been modified is sent every network tick, not the entire game state.
  • Chat module available.

Examples

Try playing with a friend!

The source code of these 3 games is available in the examples folder.

Documentation

There's a wiki available.

Quick Start

To start a new Varley project, simply create a new directory, then run npm init -f and npm install varley --save inside of it.

Afterwards, pick an example from above, and copy the files from the examples folder of this repository.

Then, use node server.js to run your game.

You can then play it at http://localhost:8080!

Code Example

To see how short games can be, an example of a tron-like game is available below.

server.js:

const varley = require('varley')(this);

varley.on('start', () => {
  varley.pub.world = Array(WORLD_WIDTH * WORLD_HEIGHT).fill(-1)
})

varley.on('connect', player => {
  player.vx = 1, player.vy = 0
  player.x = Math.floor(Math.random() * WORLD_WIDTH)
  player.y = Math.floor(Math.random() * WORLD_HEIGHT)
})

let keys = {'UP': [0, -1], 'LEFT': [-1, 0], 'RIGHT': [1, 0], 'DOWN': [0, 1]}
varley.on('press', (player, key) =>
  [player.vx, player.vy] = keys[key] || [player.vx, player.vy])

varley.on('playertick', player => {
  player.x = player.x + player.vx, player.y = player.y + player.vy

  if(player.x < 0 || player.y < 0 ||
     player.x >= WORLD_WIDTH || player.y >= WORLD_HEIGHT ||
     varley.pub.world[player.x + player.y * WORLD_WIDTH] !== -1)
    return player.disconnect()

  varley.pub.world[player.x + player.y * WORLD_WIDTH] = player.id
})

varley.on('disconnect', player =>
  varley.pub.world = varley.pub.world.map(t => t == player.id ? -1 : t))

varley.run()

client.js:

const SIZE = [1000, 700]
const BLOCK_SIZE = SIZE[0] / WORLD_WIDTH

const PAGE_BG = '#FFFFFF'
const CANVAS_BG = 'green'

const colors = ['#FF0000', '#00FF00', '#0000FF',
                '#FFFF00', '#FF00FF', '#00FFFF']

function update() {
  for(let y = 0; y < WORLD_HEIGHT; ++y)
  for(let x = 0; x < WORLD_WIDTH; ++x) {
    let color = pub.world[x + y * WORLD_WIDTH] % 6
    const BS = BLOCK_SIZE
    drawRect(x * BS, y * BS, BS, BS, colors[color])
  }
}

shared.js:

const WORLD_WIDTH = 50, WORLD_HEIGHT = 35

Contributing

The best way to contribute at this point is to try out the engine, and e-mail ([email protected]) me your thoughts on it, or create an issue if you find a problem with it. Pull requests are also welcome, if you fix the problem you've found.

If you have a feature request, feel free to open an issue, so that we can discuss it.