Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Minimalist game server for your game jam

License

NotificationsYou must be signed in to change notification settings

jtpio/jammer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 onweb based games.

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

Usage

Docker

To run the server in a docker container, and mount your front-end files:

docker build -t $USER/jammer .docker run -t --name=jammer -v /path/to/your/public/files:/app/public:ro -p 4321:4321 $USER/jammer

Doing so, you only have to provide the files doing the client side work, and let node serve them. This is the easiest way to get started. Even though the server will run in a docker container, it is still possible to modify it and rebuild an image, in case you have specific requirements.

The files are served from the/app/public folder. So if you have two files namedgame.html andplayer.html, visitlocalhost:4321/game.html to create a game instance andlocalhost:4321/player.html to spawn up a player.

Install and run manually

It is also possible to run jammer manually by first installing node.js, and then:

npm install jammer -g

Followed by:

jammer

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

public/game.htmlpublic/player.htmlpublic/js/gameClient.jspublic/js/gameServer.jsserver.jspackage.jsonnode_modules/

Then:

node server.js

And you have a server listening onport 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.htmlpublic/game.html

They include or the Javascript files:

public/js/gameClient.jspublic/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

vargameServer=newGameServer();varplayers={};gameServer.on('gameID',function(gameID){// display the game ID on screen for the players});gameServer.on('newPlayer',function(player){// player connectedvarplayerID=player.id;players[playerID]=player;// save it for later useplayer.x=Math.random()*500;player.y=Math.random()*500;player.size=50;// Player listeners// Example of a player event: changeSizeplayer.on('changeSize',function(size){player.size=size||50;});// Send command to the playerplayer.send('changeColor','#FF0000');player.on('disconnect',function(){deleteplayers[player.id];});});

GameClient

vargameClient=newGameClient();gameClient.join(12);// join the game 12gameClient.on('joined',function(){// player joined, do something with it, for example change the sizegameClient.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 playerplayer.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 2gameClient.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 usingHappyFunTimes 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

About

Minimalist game server for your game jam

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp