All Projects → stiller → multipong

stiller / multipong

Licence: other
A multiplayer Pong game using Elm, Phoenix and GenServer

Programming Languages

elixir
2628 projects
elm
856 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to multipong

stub on web
Create stub urls to test external API integration
Stars: ✭ 54 (+260%)
Mutual labels:  phoenix
uncharted
No description or website provided.
Stars: ✭ 31 (+106.67%)
Mutual labels:  phoenix
phoenix-react-apollo-demo
Example app using the Phoenix Framework with React and GraphQL
Stars: ✭ 37 (+146.67%)
Mutual labels:  phoenix
algoliax
Algolia integration to elixir application
Stars: ✭ 38 (+153.33%)
Mutual labels:  phoenix
phoenix pagination
Simple pagination for Ecto and Phoenix that uses plain EEx templates.
Stars: ✭ 20 (+33.33%)
Mutual labels:  phoenix
querie
Compose Ecto query from the client side
Stars: ✭ 20 (+33.33%)
Mutual labels:  phoenix
sms blitz
Send SMS messages through multiple different providers
Stars: ✭ 29 (+93.33%)
Mutual labels:  phoenix
pan
The podcast showcase & community / Phoenix based web application
Stars: ✭ 31 (+106.67%)
Mutual labels:  phoenix
phoenix.webui.framework
基于WebDriver的WebUI自动化测试框架
Stars: ✭ 118 (+686.67%)
Mutual labels:  phoenix
dotfiles
💾 dotfiles for macOS - includes zsh, hyper key, Karabiner, and Phoenix configurations. Installation via dotbot.
Stars: ✭ 41 (+173.33%)
Mutual labels:  phoenix
radiopush
Create communities and share songs with Spotify users (https://radiopush.app)
Stars: ✭ 89 (+493.33%)
Mutual labels:  phoenix
phoenix meta tags
Phoenix library helps generating meta tags for website.
Stars: ✭ 25 (+66.67%)
Mutual labels:  phoenix
ecto profiler
Project for Ecto DB profiling
Stars: ✭ 16 (+6.67%)
Mutual labels:  phoenix
gringotts payment
Demo Phoenix app showing gringotts payment library integrations.
Stars: ✭ 24 (+60%)
Mutual labels:  phoenix
elixir-auth-google-demo
⭐️ A basic example of using Google Auth in a Phoenix App.
Stars: ✭ 15 (+0%)
Mutual labels:  phoenix
alternate
Plug and Phoenix helpers to localize your web app via the URL
Stars: ✭ 26 (+73.33%)
Mutual labels:  phoenix
phoenix html simplified helpers
Some helpers for phoenix html( truncate, time_ago_in_words, number_with_delimiter, url_for, current_page? )
Stars: ✭ 29 (+93.33%)
Mutual labels:  phoenix
artemis platform
Enterprise Ready Patterns for Elixir and Phoenix
Stars: ✭ 17 (+13.33%)
Mutual labels:  phoenix
pinterest-backend
Pinterest Clone Backend in Phoenix Framework
Stars: ✭ 19 (+26.67%)
Mutual labels:  phoenix
mfpb
My Frugal PostBin
Stars: ✭ 26 (+73.33%)
Mutual labels:  phoenix

What?

TLDR: I made a mutiplayer Pong game using Elm, Elixir GenServer and Phoenix.

Demo player 1 Demo player 2

Please allow some time for the dyno to spin up. If multiple people try to control the same player, hilarity ensues.

Why?

I wanted to develop my Elixir and Elm skills and I figured a mutiplayer game would really exercise the whole stack. I had come across the original Elm Pong game some years ago and decided to make it multiplayer and move all the game state to the server. After completing the excellent Elm, Elixir and the first part of the Elm + Elixir courses by The Pragmatic Studio, I was confident enough to try.

How?

I started with porting the game state of the original game to a simple Elixir module: https://github.com/stiller/multipong/blob/master/apps/pong/lib/pong/game.ex

I then added a basic GenServer to hold the game state and actually run the game: https://github.com/stiller/multipong/blob/master/apps/pong/lib/pong/game_server.ex

After testing this from an IEx shell, I added a separate Phoenix app, with the sole purpose of serving the Elm game client itself and provide websocket funcionality using the excellent Phoenix Channels. After getting the channels to work in plain old Javascript, I grabbed a 0.18 port of the Elm Pong game: https://github.com/davydog187/elm-pong Then I set to work to replace all the client-side game state updates with calls to and from the Phoenix backend: https://github.com/stiller/multipong/blob/master/apps/multipong/assets/elm/src/Pong.elm

To watch this process, you can checkout commits: https://github.com/stiller/multipong/commit/77b06ff76af740869e1cfd562481e21d719420f3

Through:

https://github.com/stiller/multipong/commit/a0d5cc841fde00ac72fbc1bb3bcf1059fbf792da

Finally I converted the whole thing to an Elixir umbrella app, since that proved easier to deploy to Heroku.

What's next?

Some obvious improvements are:

  • actual user sessions
  • game create
  • share game link

These features are much like some topics in the Unpacked: Multi-Player Bingo course. Then there are some gameplay improvements:

  • do not allow paddle move during pause (because that's cheating)
  • save key-down event in state until key-up event (this is already implemented in the 0.18 port I stole
  • save and publish highscores, which allows me to play with Ecto

Conclusion

This whole exercise was a very pleasant experience with very little frustrating moments. This was very suprising, given my experience with Elixir (little) and Elm (none). If you have any questions, drop me a line.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].