Dustbin
I made a little falling sand game today in mojo.
https://github.com/helehex/dustbin
GitHub
GitHub - helehex/dustbin
Contribute to helehex/dustbin development by creating an account on GitHub.
27 Replies
Next up, model gym for learning lunar lander but all in mojo
Wheeeeee
Thoughts?
I had to do it
tell me if running
sudo apt install libsdl2-dev
in your terminal works, if not i might have to make some changes to sdl bindings
if your still awake
i didnt see the message until now
i have a feeling you'r gonna have to install all the satellite libraries aswell which im not even using
working on improving sdl bindings rn to give better errors and such
How can I incorporate both magnets and digital intelligence into my little dustbinhttps://anaconda.org/conda-forge/sdl2 It might make sense to use the conda-forge version of sdl2.
that would probly be really helpful
I didn’t realize there were SDL bindings already
I was looking into doing this but the sdl bindings currently use mojo nightly and magic doesn't support nightly yet. Definitely going to try to get that working once next stable drops
We really just need nightly in magic.
yeah this would also work
getting some random segfaults in the nightly that just dropped, same with thermo
i think maybe something with the sdl event system
What’re tonight’s changes?
ok, it's definitely something with the event system causing segfaults.. but now mojo is refusing to compile because of commented out code..
nvm i forgot the sdl example file was using the packaged version 😮💨
i fixed the aforementioned segfault in sdl bindings btw, but also, tonight i added camera movement and zoom
rendering took a performance hit, but it can definitely be improved back to it's former glory
I found it broken in Ubuntu 24 , this is because the Window in sdl-binding will construct Surface , and it's forbidden in SDL2 / Ubuntu2 .
I fix it by remove it . because dustbin use Render and not allow Surface bind to Window
++ b/src/render.mojo
@@ -10,25 +10,25 @@ struct Renderer[lif: AnyLifetime[False].type]:
var sdl: Reference[SDL, lif]
var _renderer_ptr: Ptr[_Renderer]
var window: Window[lif]
- var surface: Surface[lif]
+ #var surface: Surface[lif]
fn init(inout self, owned window: Window[lif], index: Int = -1, flags: UInt32 = RendererFlags.SDL_RENDERER_ACCELERATED) raises:
self.sdl = window.sdl
self._renderer_ptr = self.sdl[]._sdl.create_renderer(window._window_ptr, index, flags)
self.window = window^
- self.surface = Surface(self.sdl[])
+ #self.surface = window.surface
fn init(inout self, owned surface: Surface[lif]) raises:
self.sdl = surface.sdl
self._renderer_ptr = self.sdl[]._sdl.create_software_renderer(surface._surface_ptr)
self.window = Window(self.sdl[])
- self.surface = surface^
+ #self.surface = window.surface
fn moveinit(inout self, owned other: Self):
self.sdl = other.sdl
self._renderer_ptr = other._renderer_ptr
self.window = other.window^
- self.surface = other.surface^
+ #self.surface = other.surface
Renderer could not be created! SDL_Error: Surface already associated with window.
in Ubuntu 22 it works fine , it's seems Ubuntu 24 forbidden it .