harrisi
I made a breakout clone in Elixir with no dependencies. It’s mostly terrible, but I’ve tested it on macOS, Windows, and Ubuntu. Find it here: GitHub - harrisi/elixir_breakout: OpenGL-rendered Breakout port in Elixir. · GitHub. You can clone the repo and run the game with iex -S mix or mix run --no-halt. A/D, H/L, or left/right arrows to move left/right, space to launch the ball, N to switch levels, and P to profile for ten seconds (if you’re interested).
The code is quite bad. It’s a mostly straightforward port of the breakout implementation on https://learnopengl.com. My intention is to now make it more “BEAM-y”, but I think it’s an interesting project already.
Let me know if you have any problems running it or playing it. My machines are reasonably powerful, so I’m not sure how it runs in general.
EDIT: I posted in the blog post thread, but if anyone’s interested in random thoughts about this, Breakout Musings.
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
rvnash
I honestly had no idea that OTP had an OpenGL library in it. Thanks for sharing. Ran fine on my Macbook Air.
harrisi
It’s via wxWidgets, which is what
observeruses for its GUI.The best example of its use is https://wings3d.com, which is a 3D modeling software written in Erlang (primarily by two Erlang maintainers). I use it to export 3D models that I render in Elixir in another project, actually.
EDIT: Thanks for testing it!
andyleclair
This is extremely cool and inspiring!
Don’t be so hard on yourself, plenty of production code around the world is “bad” and nobody will ever notice. Focus on what you did right, which is make a working game with Elixir! Very few people have done that.
harrisi
Thanks for the kind words!
I’m not too worried about the code quality. I’m not new to programming, but I’ve only recently started working with Elixir, OpenGL, or any sort of game development, so I don’t expect much.
This is really the continuation of an exploration into what the BEAM can do in a game development situation. It started with a triangle, went to a (bad) ray tracer, the start of some 3d physics simulations, 3d modeling, and now a 2d game. Slightly going backwards, but it’s good progress I think.
I pushed an update with some text rendering. It’s basically a copy of the OpenGL text rendering in the
:wxdemo. There’s also a menu for selecting levels, and some more bugs!Text rendering is the last main thing I can do without bringing in some dependencies. I think it’s worth mentioning all the things Elixir can do by itself:
Really the only thing missing is audio playback. I’ve already tested Membrane, which seems to be the best (only?) option. I really wish there was a way to do audio playback without any dependencies. Oh well.
I’ll be adding audio playback soon, which will, I think, put this over the line into the lonely category of “finished games written in Elixir”.
harrisi
I added Membrane, with looped background audio and a few sound effects. I haven’t tested it on anything other than my M2 MacBook Air, but I think it should work elsewhere.
It’s not the ideal way to do it, but I’m not sure yet what is. There’s a PR just adding the audio code, if anyone is familiar with Membrane and has suggestions (I asked in the Membrane Discord as well).
This is also the first use of the supervision tree, although it’s not really necessary.
There is still no win condition. Call it “art”.
harrisi
If anyone can’t be bothered with building the project after adding some dependencies (this is not a dig at Membrane - it’s fantastic), I made standalone executables for Windows, macOS, and Linux with the help of burrito.
I haven’t tested the Windows, Linux, or non-arm macOS builds, but I’m hopeful that things just work. As long as those work, this project actually seems much closer to being a game written in Elixir distributed on Steam, Gog, itch.io, etc., which is pretty exciting. If I get to that point, it would be a different game, but probably something reasonably simple (maybe 3D though).
There’s still a lot to prove, but it’s still coming along nicely, I think. Any suggestions on what to do next would be great. What would help convince you to work on a game in Elixir?
andyleclair
I have such dreams of writing a game in Elixir, and you’ve basically followed the exact path I’ve envisioned (compiling for each platform with Burrito)
I’d thought it would be more straightforward to wrap something like Raylib, but mostly because I didn’t know about using OpenGL directly.
What’s keeping me from making a game? A full time job and a baby
andyleclair
FWIW I’ve tried this on Windows and the application crashes complaining about missing
.mp3filesharrisi
It probably is easier to do something like what Rayex is doing, but the main reason I’ve not spent effort improving that instead is that I think shoehorning a C-based state machine-like API into Elixir isn’t what will make a great tool for making a game in Elixir. Of course, you can abstract a more idiomatic layer in Elixir on top of Raylib, but I think it would end up being confusing to reason about. Needing to understand Elixir, the abstraction layer, Raylib, and how the abstraction layer communicates to Raylib, just seems like too much. That doesn’t even get into the complexities of actual game development. It’s no wonder nobody is hungry for that system to exist.
The ease I’ve had in jumping into various projects in Elixir and understand what’s going on and even make changes has been inspiring. I personally feel like that ease could apply to game development as well, which would allow for rapid development. Which isn’t a new idea - that’s exactly why scripting languages are used in many games. I just have a crazy idea of using Elixir for the core engine and the “scripting” language.
There’s also a ton of interesting things thanks to easy DSLs, like creating shaders, objects, scenes, etc., but that’s a ways away.
mat-hek