0.0.4 • Published 3 years ago

jellyfish.js v0.0.4

Weekly downloads
45
License
MIT
Repository
github
Last release
3 years ago

Jellyfish

Multiplayer game development made easy.

Jellyfish is a game engine designed around multiplayer. We handle networking, sending packets, and updating state, so you can focus on what you care about — designing your game.

Features

  • Write your code once, run the same bundle on the server and the client, and we take care of the rest. State is automatically synchronized between clients.

  • Supports WebGL rendering (thanks to PIXI.js) and optionally, physics (thanks to matter.js).

  • Supports JavaScript and TypeScript.

  • No IDE. You already like your editor, and we could never compete with it. Use what you're comfortable with.

  • Easy to learn, but powerful. Jellyfish isn't magic — it does things automatically when you want, but let's you control the details when you need.

Simple Multiplayer Game

const { GameObject, ImageSprite, Vector, Server, Client, isServer, game, serve } = require('jellyfish.js');

class Player extends GameObject {
    onCreate() {
        this.position = Vector.xy(100, 300);
        this.sprite = this.createSprite(ImageSprite, '/assets/player.png');
        this.sprite.following = this;
    }

    keyHeld(keycode) {
        if (!this.isOwnedByCurrentUser()) { return; }

        let movement = Vector.zero;
        switch (keycode) {
            case 40: movement = Vector.up; break;
            case 38: movement = Vector.down; break;
            case 37: movement = Vector.left; break;
            case 39: movement = Vector.right; break;
        }

        this.position = this.position.plus(movement);
    }
}
game.registerClass(Player);

class GameServer extends Server {
    onCreate() { this.start(); }
}

class GameClient extends Client {
    onCreate() { this.connect(); }
    onRegistered() {
        const player = this.createObject(Player);
        player.setOwner(this.user());
    }
}

if (isServer) { game.createObject(GameServer); }
else { game.createObject(GameClient); }

game.setCanvasByID("game");
game.start();
serve();

Getting Started

To get started quickly, check out the first game guide.

For more information, see the rest of the documentation.

Contributing

Ideas? Want to help out? Great! Make a new issue or a new pull request.

Check out the development docs for more information.

Contact Us

If you have a question, have general feedback, want to insult us, or want to help out, join our Discord!