{"id":19218200,"url":"https://github.com/greggman/happyfuntimes","last_synced_at":"2025-04-05T12:09:20.504Z","repository":{"id":15182888,"uuid":"17910854","full_name":"greggman/HappyFunTimes","owner":"greggman","description":"A System for creating 10-100+ player local games","archived":false,"fork":false,"pushed_at":"2020-04-17T03:23:58.000Z","size":59974,"stargazers_count":383,"open_issues_count":16,"forks_count":55,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-03-29T11:11:40.843Z","etag":null,"topics":["game","games","happyfuntimes","localmultiplayer","smartphone"],"latest_commit_sha":null,"homepage":"http://greggman.github.io/HappyFunTimes","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greggman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-19T16:03:44.000Z","updated_at":"2025-03-18T13:45:26.000Z","dependencies_parsed_at":"2022-09-08T20:32:04.218Z","dependency_job_id":null,"html_url":"https://github.com/greggman/HappyFunTimes","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greggman%2FHappyFunTimes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greggman%2FHappyFunTimes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greggman%2FHappyFunTimes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greggman%2FHappyFunTimes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greggman","download_url":"https://codeload.github.com/greggman/HappyFunTimes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332612,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","games","happyfuntimes","localmultiplayer","smartphone"],"created_at":"2024-11-09T14:25:40.916Z","updated_at":"2025-04-05T12:09:20.483Z","avatar_url":"https://github.com/greggman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"HappyFunTimes\n=============\n\n\u003e ## **DEPRECATED**\n\u003e\n\u003e I'm deprecating happyfuntimes. I'll keep the rendevous server running for a while\n\u003e longer but I think it's unfortunately time to mostly depreciate this project\n\u003e\n\u003e i'll consider accepting PRs still if you want to fix something but otherwise just\n\u003e fork it if you want to keep using it\n\u003e\n\u003e ## Issues\n\u003e\n\u003e There are a few major issues on why\n\u003e\n\u003e 1. **device orientation is no longer usable**\n\u003e\n\u003e    Both Safari and Chrome have made getting device orientation require HTTPS\n\u003e    which is something HFT can't provide at the moment. It would require\n\u003e    $$$$$$$. If a end-user friendly solution comes up maybe I'll revisit\n\u003e\n\u003e 2. **Browsers break stuff**\n\u003e\n\u003e    Every year or so a browser changes something or breaks something. Over the course\n\u003e    of HTF browser broke fullscreen support, audio support, touch support, orientation support,\n\u003e    and other things. It's no fun to keep up on that\n\u003e\n\u003e 3. **OSes break stuff**\n\u003e\n\u003e    For whatever reason networking that work before stops working. HFT has to do\n\u003e    some things to find out all the ways your phone might connect to the game\n\u003e    and that stuff seems to break every 2 years or so\n\u003e\n\u003e 4. **Offline Support breaks**\n\u003e\n\u003e    Using HFT without internet breaks every few year and will likely eventually\n\u003e    be unfixable. Both iOS and Android ping Apple and Google respectively when you\n\u003e    connect to WiFi to check if you're acutally on the internet. HFT tries to send\n\u003e    them *fake* data so they believe they are, otherwise they'll stop using the WiFi\n\u003e    and switch to mobile.\n\u003e\n\u003e    How they do this changes every few years so HFT has to figure out how to change its\n\u003e    faking. It is within Apple and Google's power to make this faking impossible and\n\u003e    I supsect they might at sometime which is scary because if they do then there is\n\u003e    no solution (well, short of acutally providing internet access)\n\u003e\n\u003e 5. **More browser features require HTTPS**\n\u003e\n\u003e    This is really #1 and #2 repeated but more and more browser features require HTTPS\n\u003e    and as it says above there is no way for hft to provide HTTPS at the moment.\n\u003e\n\u003e ## Good news\n\u003e\n\u003e If you don't need device orientation and you have no need for offline mode/installation mode\n\u003e then HFT still works. Write your own controllers to keep up to date with the latest changes\n\u003e in the browsers.\n\u003e\n\u003e ## Bad news\n\u003e\n\u003e I don't really have time to keep it running.\n\n[![Build Status](https://travis-ci.org/greggman/HappyFunTimes.svg?branch=master)](https://travis-ci.org/greggman/HappyFunTimes)\n\n# Want to play?\n\n*   [Try a few examples](https://itch.io/games/tag-happyfuntimes)\n\n# Make games with Unity?\n\n*   [Getting Started with Unity](http://docs.happyfuntimes.net/docs/unity/getting-started.html)\n\n# Make games with HTML5?\n\n*   [Making games](docs/making-games/index.md)\n\n# Docs\n\n*   [Docs](http://docs.happyfuntimes.net/docs)\n\n# Other\n\n*   [Home Page](http://docs.happyfuntimes.net/)\n*   [Changelist](docs/changelist.md)\n*   [License](LICENSE.md)\n\n# Support\n\n*   [Blog](http://blog.happyfuntimes.net)\n*   [Facebook Group](https://www.facebook.com/groups/timesfunhappy/)\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/scene-00-jumpjump.jpg\" width=\"782\" height=\"441\" /\u003e\n\n[HappyFunTimes](http://greggman.github.io/HappyFunTimes/) is a system for playing party games that are meant to be\nplayed with a bunch of people in the same room and 1 ideally large display.\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/scene-04-boomboom.jpg\" width=\"782\" height=\"441\" /\u003e\n\nPeople participate in the game using their smartphone by going to a webpage\nprovided by the game. The webpage lets them use their phone as a controller.\nThis lets you make games that support more than the typical 4 players.\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/scene-01-powpow.jpg\" width=\"782\" height=\"441\" /\u003e\n\nI suppose theoretically there's no limit to the number of players.\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/400-player-bombbomb.jpg\" width=\"782\" height=\"441\" /\u003e\n\nIt also lets you make games with unique controllers.\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/scene-02-jamjam.jpg\" width=\"782\" height=\"441\" /\u003e\n\nThere's a Unity3D library if you'd like to make the game in Unity3D.\n\n\u003cimg id=\"test\" src=\"http://docs.happyfuntimes.net/images/scene-03-unity.jpg\" width=\"782\" height=\"441\" /\u003e\n\n*   The smartphones end up just being smart controllers.\n\n    As there is just one machine running the *real* game this means\n    they are relatively easy to create. No crazy networking, state syncing,\n    or dead reckoning required.\n\n*   JavaScript libraries for the browser and Unity3D libraries are provided\n\n    This makes it easy to bang out a game. Use any JavaScript framework or Unity3D.\n\n*   For controllers the sky is the limit.\n\n    *   Have a one button game. The user touches their screen.\n\n    *   Make virtual DPads\n\n    *   Make virutal paddle controllers (think Pong)\n\n    *   Have users choose answers to question like Jeopardy\n\n    *   Access the camera, send selfies to the game.\n\n    *   Emit sound effects from the phone\n\n    *   Use the device orientation API and rotate something in game to match\n\n    *   Make a rhythm band where each device becomes an instrument.\n\n    *   Make a rhythm game like Parappa but each person is a different color\n        so that they each have to play their part at the right time\n\n    *   Let the user draw something on their phone. Insert that drawing into the game.\n\n    *   Show diagrams. Let the user plan out football plays.\n\n    *   Controllers can change dynamically.\n\n        Have 2 dpads for the dual stick part of your game. Have a single\n        button for the speed contest. Change to a 3 letter box to let a player\n        enter their high score initials.\n\n*   The API is simple to use (for some defintion of *simple* :D).\n\n    Games create a `GameServer` object\n\n       var server = new GameServer();\n\n    From that point on anytime a player connects the GameServer will emit an event\n    `playerconnect`\n\n       server.addEventListener('playerconnect', createNewPlayer);\n\n    It's up to you what to do when a new player connects. For example if you had a `Player`\n    object you might do something like this\n\n       var players = [];\n\n       Player = function(netPlayer) {\n         this.netPlayer = netPlayer;  // remember this Player's NetPlayer\n       };\n\n       // make a new Player anytime the 'playerconnect' event is emitted\n       function createNewPlayer(netPlayer) {\n         players.push(new Player(netPlayer));\n       }\n\n    If the player disconnects or quits the `NetPlayer` will emit a `disconnect` event.\n    If we want to handle that we might do something like\n\n        Player = function(netPlayer) {\n          this.netPlayer = netPlayer;  // remember this Player's NetPlayer\n\n          netPlayer.addEventListener('disconnect', Player.prototype.remove.bind(this));\n        };\n\n        Player.prototype.remove = function() {\n          players.splice(players.indexOf(this), 1);  // remove ourselves from our array of players.\n        };\n\n    We can send events to the player's phone by calling `netPlayer.sendCmd` For example\n\n        Player.prototype.score = function(points) {\n          this.netPlayer.sendCmd('score', {points: points});\n        };\n\n    That will cause an event `score` to be emitted on the player's phone. The player's phone\n    has a correspondiing `sendCmd` function. When called an event will be emitted on that\n    player's `NetPlayer` object.  Add listeners for any events you make up\n\n        Player = function(netPlayer) {\n          this.netPlayer = netPlayer;  // remember this Player's NetPlayer\n\n          netPlayer.addEventListener('disconnect', Player.prototype.remove.bind(this));\n          netPlayer.addEventListener('moveleft', Player.prototype.moveleft.bind(this));\n          netPlayer.addEventListener('moveright', Player.prototype.moveright.bind(this));\n          netPlayer.addEventListener('jump', Player.prototype.jump.bind(this));\n        };\n\n    Whatever data you pass to `sendCmd` will arrive with the event.\n\n        ...\n        this.netPlayer.sendCmd('die', {\n          reason: \"So and so killed you\",\n          pointsToLose: 100,\n        });\n\n    On the phone we create a `GameClient`\n\n        var client = new GameClient();\n\n    Just like `NetPlayer` above we can listen for events.\n\n        client.addEventListener('die', handleDie);\n\n        function handleDie(data) {\n          console.log(\"you lost\", data.pointsToLose, \"points. Reason:\", data.reason);\n        }\n\n    Similarly you can send events to the game\n\n        window.addEventListener('pointerdown', function(e) {\n           client.sendCmd('jump', { power: e.mouseY });\n        });\n\n    It's up to you to decide which events to send and receive for your particular\n    game's needs.\n\n*   There is also a synchronized clock across machines.\n\n    Use it as follows.\n\n        var online = true;\n        var clock = SyncedClock.createClock(online);\n\n        ...\n\n        var timeInSeconds = clock.getTime();\n\n    If online is false when the clock is created it will create a clock\n    that returns the local time.\n\n## Limitations\n\nThe number of players that can connect to a game is limited by your networking\nequipment. With enough access points there's no limit to the number of player\nthat could connect that I know of but of course 1000s of players would require\nlots of access points and lots of bandwidth and a game design that lets 1000s of people\nactually participate.\n\nAnother limit in the default mode is players must be on the same network behind\na NAT. This is standard for most if not all home routers. It's probably less standard in\noffice setups. In this mode you start HappyFunTimes, tell your users to connect to\nyour WiFi and then have them go to `happyfuntimes.net`.\n\nHappyFunTimes has the option to run it's own DNS which is another option but\nrequires configuring your router. This option is probably more suited to\nevents, installations, and things like that. In this mode, players connect\nto the WiFi specificaly setup to run HappyFunTimes. iOS devices will automatically\nfind HappyFunTimes once connected to the WiFi, no other interaction required by the user.\nAndroid devices require the user to first connect to the WiFi and then go to any random\nurl like `hft.com` or `h.com`.\n\nNotes\n-----\n\n*   How secure is this?\n\n    Not at all. This is not a library for the internet. It's a library for\n    running a game at a party, meeting, bar, etc...\n\n    That said if there's anything easy and performant you'd like to suggest\n    submit a pull request.\n\n*   What about cheating?\n\n    Again, this is meant for games where everyone is in the same room watching\n    the same display. If someone is off in the corner trying to hack the game\n    through the net maybe you shouldn't have invited them to your party.\n\n    That said if there's anything easy and performant you'd like to suggest\n    submit a pull request.\n\n*   Does it work on Windows, OSX, and Linux?\n\n    The controllers of course run in any modern browser. Games run in\n    whatever environment you've created them for. Most of the samples here\n    are HTML and so should run in any modern browser on any platform.\n\n    As for happyFunTimes I've run it on OSX, Linux and Windows with\n    no problems.\n\n*   Why not WebRTC?\n\n    WebRTC would possibly allow the phones to talk directly the game rather than through\n    the happyfuntimes. happyfuntimes would need to setup a rendevous between the 2 machines\n    but after that the conncetion should be peer to peer.... Or so I'm lead to believe.\n    WebRTC still doesn't currently exist in iOS Safari as of iOS8. It does exist in Chrome.\n\n    Feel free to submit a pull request ;-)\n\nTo Do\n-----\n\n[There's lots of ideas](todo.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreggman%2Fhappyfuntimes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreggman%2Fhappyfuntimes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreggman%2Fhappyfuntimes/lists"}