• Stars
    star
    371
  • Rank 114,691 (Top 3 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A System for creating 10-100+ player local games

HappyFunTimes

DEPRECATED

I'm deprecating happyfuntimes. I'll keep the rendevous server running for a while longer but I think it's unfortunately time to mostly depreciate this project

i'll consider accepting PRs still if you want to fix something but otherwise just fork it if you want to keep using it

Issues

There are a few major issues on why

  1. device orientation is no longer usable

    Both Safari and Chrome have made getting device orientation require HTTPS which is something HFT can't provide at the moment. It would require $$$$$$$. If a end-user friendly solution comes up maybe I'll revisit

  2. Browsers break stuff

    Every year or so a browser changes something or breaks something. Over the course of HTF browser broke fullscreen support, audio support, touch support, orientation support, and other things. It's no fun to keep up on that

  3. OSes break stuff

    For whatever reason networking that work before stops working. HFT has to do some things to find out all the ways your phone might connect to the game and that stuff seems to break every 2 years or so

  4. Offline Support breaks

    Using HFT without internet breaks every few year and will likely eventually be unfixable. Both iOS and Android ping Apple and Google respectively when you connect to WiFi to check if you're acutally on the internet. HFT tries to send them fake data so they believe they are, otherwise they'll stop using the WiFi and switch to mobile.

    How they do this changes every few years so HFT has to figure out how to change its faking. It is within Apple and Google's power to make this faking impossible and I supsect they might at sometime which is scary because if they do then there is no solution (well, short of acutally providing internet access)

  5. More browser features require HTTPS

    This is really #1 and #2 repeated but more and more browser features require HTTPS and as it says above there is no way for hft to provide HTTPS at the moment.

Good news

If you don't need device orientation and you have no need for offline mode/installation mode then HFT still works. Write your own controllers to keep up to date with the latest changes in the browsers.

Bad news

I don't really have time to keep it running.

Build Status

Want to play?

Make games with Unity?

Make games with HTML5?

Docs

Other

Support

HappyFunTimes is a system for playing party games that are meant to be played with a bunch of people in the same room and 1 ideally large display.

People participate in the game using their smartphone by going to a webpage provided by the game. The webpage lets them use their phone as a controller. This lets you make games that support more than the typical 4 players.

I suppose theoretically there's no limit to the number of players.

It also lets you make games with unique controllers.

There's a Unity3D library if you'd like to make the game in Unity3D.

  • The smartphones end up just being smart controllers.

    As there is just one machine running the real game this means they are relatively easy to create. No crazy networking, state syncing, or dead reckoning required.

  • JavaScript libraries for the browser and Unity3D libraries are provided

    This makes it easy to bang out a game. Use any JavaScript framework or Unity3D.

  • For controllers the sky is the limit.

    • Have a one button game. The user touches their screen.

    • Make virtual DPads

    • Make virutal paddle controllers (think Pong)

    • Have users choose answers to question like Jeopardy

    • Access the camera, send selfies to the game.

    • Emit sound effects from the phone

    • Use the device orientation API and rotate something in game to match

    • Make a rhythm band where each device becomes an instrument.

    • Make a rhythm game like Parappa but each person is a different color so that they each have to play their part at the right time

    • Let the user draw something on their phone. Insert that drawing into the game.

    • Show diagrams. Let the user plan out football plays.

    • Controllers can change dynamically.

      Have 2 dpads for the dual stick part of your game. Have a single button for the speed contest. Change to a 3 letter box to let a player enter their high score initials.

  • The API is simple to use (for some defintion of simple :D).

    Games create a GameServer object

    var server = new GameServer();

    From that point on anytime a player connects the GameServer will emit an event playerconnect

    server.addEventListener('playerconnect', createNewPlayer);

    It's up to you what to do when a new player connects. For example if you had a Player object you might do something like this

    var players = [];

    Player = function(netPlayer) { this.netPlayer = netPlayer; // remember this Player's NetPlayer };

    // make a new Player anytime the 'playerconnect' event is emitted function createNewPlayer(netPlayer) { players.push(new Player(netPlayer)); }

    If the player disconnects or quits the NetPlayer will emit a disconnect event. If we want to handle that we might do something like

    Player = function(netPlayer) {
      this.netPlayer = netPlayer;  // remember this Player's NetPlayer
    
      netPlayer.addEventListener('disconnect', Player.prototype.remove.bind(this));
    };
    
    Player.prototype.remove = function() {
      players.splice(players.indexOf(this), 1);  // remove ourselves from our array of players.
    };
    

    We can send events to the player's phone by calling netPlayer.sendCmd For example

    Player.prototype.score = function(points) {
      this.netPlayer.sendCmd('score', {points: points});
    };
    

    That will cause an event score to be emitted on the player's phone. The player's phone has a correspondiing sendCmd function. When called an event will be emitted on that player's NetPlayer object. Add listeners for any events you make up

    Player = function(netPlayer) {
      this.netPlayer = netPlayer;  // remember this Player's NetPlayer
    
      netPlayer.addEventListener('disconnect', Player.prototype.remove.bind(this));
      netPlayer.addEventListener('moveleft', Player.prototype.moveleft.bind(this));
      netPlayer.addEventListener('moveright', Player.prototype.moveright.bind(this));
      netPlayer.addEventListener('jump', Player.prototype.jump.bind(this));
    };
    

    Whatever data you pass to sendCmd will arrive with the event.

    ...
    this.netPlayer.sendCmd('die', {
      reason: "So and so killed you",
      pointsToLose: 100,
    });
    

    On the phone we create a GameClient

    var client = new GameClient();
    

    Just like NetPlayer above we can listen for events.

    client.addEventListener('die', handleDie);
    
    function handleDie(data) {
      console.log("you lost", data.pointsToLose, "points. Reason:", data.reason);
    }
    

    Similarly you can send events to the game

    window.addEventListener('pointerdown', function(e) {
       client.sendCmd('jump', { power: e.mouseY });
    });
    

    It's up to you to decide which events to send and receive for your particular game's needs.

  • There is also a synchronized clock across machines.

    Use it as follows.

    var online = true;
    var clock = SyncedClock.createClock(online);
    
    ...
    
    var timeInSeconds = clock.getTime();
    

    If online is false when the clock is created it will create a clock that returns the local time.

Limitations

The number of players that can connect to a game is limited by your networking equipment. With enough access points there's no limit to the number of player that could connect that I know of but of course 1000s of players would require lots of access points and lots of bandwidth and a game design that lets 1000s of people actually participate.

Another limit in the default mode is players must be on the same network behind a NAT. This is standard for most if not all home routers. It's probably less standard in office setups. In this mode you start HappyFunTimes, tell your users to connect to your WiFi and then have them go to happyfuntimes.net.

HappyFunTimes has the option to run it's own DNS which is another option but requires configuring your router. This option is probably more suited to events, installations, and things like that. In this mode, players connect to the WiFi specificaly setup to run HappyFunTimes. iOS devices will automatically find HappyFunTimes once connected to the WiFi, no other interaction required by the user. Android devices require the user to first connect to the WiFi and then go to any random url like hft.com or h.com.

Notes

  • How secure is this?

    Not at all. This is not a library for the internet. It's a library for running a game at a party, meeting, bar, etc...

    That said if there's anything easy and performant you'd like to suggest submit a pull request.

  • What about cheating?

    Again, this is meant for games where everyone is in the same room watching the same display. If someone is off in the corner trying to hack the game through the net maybe you shouldn't have invited them to your party.

    That said if there's anything easy and performant you'd like to suggest submit a pull request.

  • Does it work on Windows, OSX, and Linux?

    The controllers of course run in any modern browser. Games run in whatever environment you've created them for. Most of the samples here are HTML and so should run in any modern browser on any platform.

    As for happyFunTimes I've run it on OSX, Linux and Windows with no problems.

  • Why not WebRTC?

    WebRTC would possibly allow the phones to talk directly the game rather than through the happyfuntimes. happyfuntimes would need to setup a rendevous between the 2 machines but after that the conncetion should be peer to peer.... Or so I'm lead to believe. WebRTC still doesn't currently exist in iOS Safari as of iOS8. It does exist in Chrome.

    Feel free to submit a pull request ;-)

To Do

There's lots of ideas.

More Repositories

1

twgl.js

A Tiny WebGL helper Library
JavaScript
2,451
star
2

better-unity-webgl-template

A better default template for Unity WebGL
HTML
630
star
3

html5bytebeat

Bytebeats in HTML5
JavaScript
369
star
4

webgl-memory

A library to track webgl-memory
JavaScript
306
star
5

tdl

A low-level WebGL library
JavaScript
280
star
6

ffmpegserver.js

Receives canvas frames from browser to generate video on the server. Compatible with CCapture.js
JavaScript
267
star
7

servez

A simple web server for local web development.
JavaScript
258
star
8

hsva-unity

A Hue Saturation Value adjustment shader for Unity. Useful for making lots of character colors.
GLSL
202
star
9

webgl-lint

Checks your WebGL usage for common issues
JavaScript
160
star
10

wgpu-matrix

Fast WebGPU 3d math library
JavaScript
129
star
11

virtual-webgl

Virtualize WebGL Contexts
JavaScript
105
star
12

unzipit

Random access unzip library for JavaScript
JavaScript
100
star
13

unity-webgl-copy-and-paste

Support Copy and Paste in Unity WebGL
C#
90
star
14

doodles

Random JavaScript doodles
JavaScript
58
star
15

getuserimage-unity-webgl

How to ask the user for a photo in Unity-WebGL
C#
55
star
16

webgl-helpers

some tiny webgl scripts that might come in handy
JavaScript
54
star
17

webgpu-memory

Track your WebGPU memory usage
JavaScript
43
star
18

servez-cli

The cli version of servez
JavaScript
38
star
19

ImHUI

Experimental UI
TypeScript
34
star
20

webgl-capture

code to help make a reduced test case for WebGL by capturing the commands and generating a stand alone program
JavaScript
34
star
21

oes-vertex-array-object-polyfill

WebGL OES_vertex_array_object polyfill for GPUs/Drivers/Browsers that don't have it
JavaScript
33
star
22

hft-unity3d

Unity3D Libraries for HappyFunTimes
C#
31
star
23

requestanimationframe-fix.js

Fix for requestAnimationFrame with lots of elements
JavaScript
31
star
24

webgpu-utils

Some helpers for webgpu
JavaScript
30
star
25

youtube_chromecast_speed_hack

A way to play a youtube video on Chromecast with settable speed
HTML
28
star
26

pico-8-post-processing

post process pico-8
JavaScript
28
star
27

hft-tonde-iko

A Multi-Machine Platformer
JavaScript
24
star
28

react-split-it

A React Based Splitter
JavaScript
24
star
29

pixel-perfect.js

Display Image Pixel Perfect
HTML
22
star
30

gradient-editor

A Jquery based gradient editor
JavaScript
20
star
31

jsgist

A code playground that stores data as github gists
JavaScript
16
star
32

interval-timer

A Simple Interval Timer
JavaScript
16
star
33

html5-gamepad-test

HTML
15
star
34

webgpu-avoid-redundant-state-setting

Check for and avoid redundant state setting
JavaScript
15
star
35

webgl-canvas-2d

A minimal implementation of the canvas 2D API through WebGL
JavaScript
14
star
36

rockfall

Rockfall. A game where rocks fall
JavaScript
14
star
37

jsbenchit

A JavaScript benchmark static page website that uses gists to store benchmarks
JavaScript
14
star
38

fanfictionreader

Reads your fanfiction to you.
JavaScript
13
star
39

happyfuntimes.net

The HappyFunTimes.net code
JavaScript
10
star
40

dekapng

Make giant PNG files in the browser
TypeScript
10
star
41

hft-gamepad-api

Emulates the HTML5 Gamepad API using smartphones and HappyFunTimes
JavaScript
10
star
42

hft-boomboom

A happyfuntimes game with splosions
JavaScript
9
star
43

DeJson.NET

A simple serialization library from JSON to C# classes based on MiniJSON good for Unity3D
C#
9
star
44

oculus-anti-spy

Try top stop Facebook from spying on all Oculus Activity
JavaScript
8
star
45

uzip-module

An ES6 module version of UZIP.js
JavaScript
8
star
46

imageutils

A few image utils for in browser JavaScript
JavaScript
7
star
47

hft-unity-gamepad

A Generic HappyFunTimes Gamepad for Unity
JavaScript
7
star
48

MoPho-V

A Community Supported Movie and Photo Viewer
JavaScript
6
star
49

sharks-with-frickin-lasers

JavaScript
6
star
50

hft-clean

The simplest happyfuntimes example, no other scripts
JavaScript
6
star
51

webgpu-helpers

Small scripts useful when debugging or developing webgpu
JavaScript
6
star
52

octopus

JavaScript
5
star
53

audiostreamsource.js

Provides a streamed audio source for WebAudio across browsers
JavaScript
5
star
54

dump-all-the-shaders

A script you can add to dump all your shaders to the console.
JavaScript
4
star
55

epub-viewer

A simple epub viewer. Client side only
HTML
4
star
56

image-grid

A simple image-grid for displaying images um, in a grid in the browser
JavaScript
4
star
57

simple-new-tab-page

A simple new tab page extension
JavaScript
4
star
58

other-window-ipc

IPC between windows in Electron
JavaScript
4
star
59

macos-opengl-experiments

Simple OpenGL stuff on MacOS
Objective-C++
3
star
60

rest-url

Makes REST urls
JavaScript
3
star
61

aws-oauth-helper

An AWS Lambda function to handle the oauth client secret part of oauth
JavaScript
3
star
62

unity-load-mp3-at-runtime

example of loading mp3 at runtime
C#
3
star
63

soundcloud-audio-reactive-example

Soundcloud audio reactive example using new API
JavaScript
3
star
64

hft-unityvideofromunity

An example of sending WebCam video FROM unity to the controller (phones)
C#
3
star
65

muigui

baking
JavaScript
3
star
66

hft-syncthreejs

Shows syncing a three.js example across multiple machines using HappyFunTimes
JavaScript
3
star
67

fixallthetags

SO script to fix tags
JavaScript
3
star
68

hft-local

Run a HappyFunTimes game without HappyFunTimes (no networking .. sometimes good for demos)
JavaScript
3
star
69

screenshot-ftw

screenshot a window across OSes
C++
3
star
70

webgl-benchmarks

WebGL Benchmarks (NOT GPU BENCHMARKS!!!)
JavaScript
3
star
71

opengl-fundamentals

JavaScript
3
star
72

stackoverflow-getallanswers

Get all answers for a particular user (and all the questions for those answers)
Python
3
star
73

hft-unitysimple

The simplest Unity example for HappyFunTimes using C#
C#
3
star
74

jsgistrunner

JavaScript
2
star
75

fisheye-skybox-unity

Make a fisheye skybox shader in unity
ShaderLab
2
star
76

cssparse.net

CSS string to Unity3D Color parser
C#
2
star
77

u2b-ux

better youtube ux
JavaScript
2
star
78

hft-unity-character-select

A HappyFunTimes Unity example showing spawning different prefabs based on player character selection
C#
2
star
79

native-msg-box

Allows you to display a native MessageBox / Dialog from node.js
JavaScript
2
star
80

hft-simple

A simple example for HappyFunTimes
JavaScript
2
star
81

hft-jumpjump

The HappyFunTimes JumpJump Example Platformer
JavaScript
2
star
82

servez-lib

The server part of servez
JavaScript
2
star
83

check-all-the-errors

load all your pages, check for javascript errors
JavaScript
2
star
84

hft-unity-2-button-gamejam

A Unity HappyFunTimes Template for the Pico Pico Cafe 2 Button Gamejam
C#
2
star
85

hft-simple-no-electron

an example of using happyfuntimes without electron
JavaScript
2
star
86

eslint-plugin-one-variable-per-var

Enforce one variable declaration per var statement
JavaScript
2
star
87

ldcp

low dependencies cp for node
JavaScript
2
star
88

LUT-to-PNG

Convert a LUT or CUBE file to a PNG (for Unreal / Unity)
JavaScript
2
star
89

hft-powpow

A simple space shooter game for HappyFunTimes
JavaScript
1
star
90

hft-utils

Various JavaScript files shared among HappyFunTimes example games
JavaScript
1
star
91

vertexshaderart.org

vertexshaderart.org
1
star
92

hft-sync2d

Example showing syncing canvas 2d across machines using HappyFunTimes
JavaScript
1
star
93

dns-server

Automatically exported from code.google.com/p/dns-server
C++
1
star
94

bloom

look at the source
JavaScript
1
star
95

hft-unity-cardboard

Example of using HappyFunTimes with Unity and Google Cardbard
C#
1
star
96

webgpu-dev-extension

Explorational WebGPU Dev Extension
JavaScript
1
star
97

font-utils

Some font utils I wrote to generate fonts for gamemaker
C
1
star
98

jsbenchit-comments

just a point to host jsbenchit comments on another domain for security
HTML
1
star
99

hft-c

HappyFunTimes support for C / C++ based games
C++
1
star
100

hft-exe

HappyFunTimes executable creator
C
1
star