harrisi

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.

Showing Posts 1 to 10

rvnash

rvnash

I honestly had no idea that OTP had an OpenGL library in it. Thanks for sharing. Ran fine on my Macbook Air.

harrisi

harrisi OP

It’s via wxWidgets, which is what observer uses 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

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

harrisi OP

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 :wx demo. There’s also a menu for selecting levels, and some more bugs! :slight_smile:

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:

  • OpenGL Core Profile rendering with shaders
  • Windowing
  • Input handling
  • Text rendering
  • All the other normal things Elixir is good at

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

harrisi OP

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”. :slight_smile:

harrisi

harrisi OP

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

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 :sweat_smile:

andyleclair

andyleclair

FWIW I’ve tried this on Windows and the application crashes complaining about missing .mp3 files

harrisi

harrisi OP

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

mat-hek

Membrane Core Team

:wave: congrats on a cool project! One problem with using Membrane for this is that it only works via WSL on Windows if you use plugins with C dependencies (which you do). We’re happy to receive contributions on that matter, but cannot prioritize that right now :slightly_frowning_face:

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews