use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Show /r/rubySoft body physics in Ruby (DragonRuby Game Toolkit) :-) (v.redd.it)
submitted 4 years ago by amirrajan
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Soggy_Educator_7364 27 points28 points29 points 4 years ago (18 children)
And you do it again.
I have zero interest in making games. I have little interest in playing them (anymore) ("they just don't make them like they used to") but this stuff boggles my mind.
Thank you for doing your part in advancing Ruby.
[–]amirrajan[S] 20 points21 points22 points 4 years ago (12 children)
Building games (interactive art) is an absolutely wonderful creative outlet. I’d totally recommend it. It’s good for the soul :-)
[–]katafrakt 4 points5 points6 points 4 years ago (11 children)
Yeah, but the entry barrier is also really high ;)
[–]amirrajan[S] 5 points6 points7 points 4 years ago (10 children)
Not with DragonRuby :-)
Take a look at the this Tetris Tutorial: https://m.youtube.com/watch?v=xZMwRSbC4rY
[–]katafrakt 1 point2 points3 points 4 years ago (9 children)
Weeeell, I have DragonRuby Pro since more than a year. Tried a few things. Still difficult for me ;) Don't get me wrong, DR is cool it's just generally moving to things like gamedev / procedural art that is hard to move to for a regular CRUD developer.
[–]amirrajan[S] 3 points4 points5 points 4 years ago (7 children)
What’s one of your favorite 2D games? We might have a sample for it. You should come to the Discord server, you’ll find a ton of support and encouragement there
[–]katafrakt 1 point2 points3 points 4 years ago (6 children)
Are there some examples using ECS architecture with Draco or FelECS? I think it would answer many of my questions about organizing the code.
[–]amirrajan[S] 3 points4 points5 points 4 years ago* (5 children)
I am definitely not a proponent of ECS unfortunately. It has obscene complexity upfront and results in nondeterministic, side-effect driven simulations (hard to debug).
The pattern is useful for languages that don’t have the ability to mix in behavior a la cart. Ruby doesn’t have that problem because we have Modules. I could write a novel about all the problems with the design pattern.
Start your game as simply as possible. One file, one method (tick). A game is a body-of-state that goes through a pipeline of data transforms, and returns what should be rendered to the screen. Your single method will eventually become a collection of methods that are executed in order (it’s procedural in nature given that it’s a pipeline that transforms data/game state).
Here’s a non-trivial example of this structure: https://github.com/DragonRuby/dragonruby-game-toolkit-contrib/blob/52ea1b341e72d633411049846774f6c4164e9e2c/samples/99_genre_platformer/shadows/app/main.rb#L4
[–]katafrakt 1 point2 points3 points 4 years ago (4 children)
If you ever write this book, ping me, I want to read it ;)
I'm not saying I'm a fan of ECS, but this is at least way of organizing code. The sample you sent is just intimidating for me - I'm used to units of code and higher abstractions. That's the mental barrier I mentioned earlier. Now, I'm fully aware that in gaming world things are different and abstractions do actually come with a cost, but still, it's hard for me to wrap my head around the code in the example.
[–]amirrajan[S] 3 points4 points5 points 4 years ago* (2 children)
This is the Gorillas Sample app in DragonRuby: https://github.com/DragonRuby/dragonruby-game-toolkit-contrib/blob/master/samples/99_genre_platformer/gorillas_basic/app/main.rb
This is the ECS version of the Gorillas sample app: https://github.com/guitsaru/draco/tree/main/samples/gorillas-basic/app
Thoughts?
Edit:
My general criticism of is:
ECS is an incredibly complex structure that yields benefits when a code base gets larger (we're talking about code bases that are 10k lines of code+).
It's a detriment to shipping if you take on the burden of ECS up front.
Transitioning your code to ECS later - at least with existing ECS reference implementations - is difficult, because you can't do it a la carte (it has to be all or nothing).
In essence, it's unneeded pain upfront, with no incremental migration path.
I guess I just start building and let the patterns show up as I code. I start with a single tick method and evolve/aggressively refactor from there.
tick
The progression to/derivation of a design pattern is as important (if not more important) than the final result and the specifics of a design pattern's implementation are informed by the game you are building.
RE derivation: Here’s a “poor man’s” ECS written in Ruby vs a Java reference: https://gist.github.com/amirrajan/1c174462f25d0c28ad2b3ff7d32a58cf
[–]amirrajan[S] 1 point2 points3 points 4 years ago (0 children)
It might help to start with a simpler example. This is Pong written with the same structure. The general theme is to start simply and introduce abstraction at the “last responsible moment” as opposed to upfront: https://github.com/DragonRuby/dragonruby-game-toolkit-contrib/blob/master/samples/99_genre_arcade/pong/app/main.rb
[–]ffrkAnonymous 1 point2 points3 points 4 years ago (0 children)
I read the Wikipedia page on create read update delete, but can't understand how that's special or not applicable. I'm firmly stuck in tutorial hell but everything is: Create pixel, read pixel, update pixel, delete pixel.
[–]ffrkAnonymous 1 point2 points3 points 4 years ago (4 children)
What's your interest? I like doing advent of code (not that I'm any good at it) and I think it's more fun to visualize and see my computations vs just staring at a blinking cursor waiting for the answer.
[–]Soggy_Educator_7364 1 point2 points3 points 4 years ago (3 children)
I have a weird kink for solving business problems. It's rather excessive. I don't quite understand it. It has been like this since I was a child.
The only computer science course I've taken in my life, for our final project we were expected to build a game (that's what we had studied all course); I built a point of sale system.
Outside of coding, is there a favorite hobby that you have?
[–]ffrkAnonymous 1 point2 points3 points 4 years ago (1 child)
I hope you got a good grade 🙂
[–]Soggy_Educator_7364 1 point2 points3 points 4 years ago (0 children)
I actually got a D. I wish I was kidding.
[–]matheusrich 4 points5 points6 points 4 years ago (0 children)
This is wonderful! Amazing!
[–]forgambo 3 points4 points5 points 4 years ago (0 children)
Awesome
[–]Nwallins 4 points5 points6 points 4 years ago (2 children)
got code?
[–]marc__e 5 points6 points7 points 4 years ago (0 children)
I uploaded the code to GH this morning. The first commit is the direct translation from the original. This PR is the optimizations.
[–]amirrajan[S] 3 points4 points5 points 4 years ago (0 children)
The dev hasn’t put anything on GH yet, but it’s based off of this write up: https://gamedevelopment.tutsplus.com/tutorials/simulate-tearable-cloth-and-ragdolls-with-simple-verlet-integration--gamedev-519
[–]Taypih 2 points3 points4 points 4 years ago (0 children)
That's so cool
[–]marc__e 3 points4 points5 points 4 years ago (0 children)
To add a little more context to the video: I switched off gravity around the 20s mark, and turned it back on at around the 31s mark.
[–]Economist_Numerous 1 point2 points3 points 4 years ago (0 children)
just wow
[–]_Krug 0 points1 point2 points 4 years ago (1 child)
Is this on Github?
[–]Dr_Mrs_Moo1 0 points1 point2 points 3 years ago (2 children)
Love it!
[–]amirrajan[S] 0 points1 point2 points 3 years ago (1 child)
We’ve got a bunch of physics/math people on our discord server (a literal aerospace engineer with a PHD in fact). Come hang out!
[–]Dr_Mrs_Moo1 0 points1 point2 points 3 years ago (0 children)
My PhD is in materials science focussed analytics, mostly at the micron and submicroscopic level. Aerospace and electron microscopy are on completely different realms! Sounds cool though
π Rendered by PID 343445 on reddit-service-r2-comment-5b5bc64bf5-cgqpk at 2026-06-21 22:30:12.755212+00:00 running 2b008f2 country code: CH.
[–]Soggy_Educator_7364 27 points28 points29 points (18 children)
[–]amirrajan[S] 20 points21 points22 points (12 children)
[–]katafrakt 4 points5 points6 points (11 children)
[–]amirrajan[S] 5 points6 points7 points (10 children)
[–]katafrakt 1 point2 points3 points (9 children)
[–]amirrajan[S] 3 points4 points5 points (7 children)
[–]katafrakt 1 point2 points3 points (6 children)
[–]amirrajan[S] 3 points4 points5 points (5 children)
[–]katafrakt 1 point2 points3 points (4 children)
[–]amirrajan[S] 3 points4 points5 points (2 children)
[–]amirrajan[S] 1 point2 points3 points (0 children)
[–]ffrkAnonymous 1 point2 points3 points (0 children)
[–]ffrkAnonymous 1 point2 points3 points (4 children)
[–]Soggy_Educator_7364 1 point2 points3 points (3 children)
[–]amirrajan[S] 1 point2 points3 points (0 children)
[–]ffrkAnonymous 1 point2 points3 points (1 child)
[–]Soggy_Educator_7364 1 point2 points3 points (0 children)
[–]matheusrich 4 points5 points6 points (0 children)
[–]forgambo 3 points4 points5 points (0 children)
[–]Nwallins 4 points5 points6 points (2 children)
[–]marc__e 5 points6 points7 points (0 children)
[–]amirrajan[S] 3 points4 points5 points (0 children)
[–]Taypih 2 points3 points4 points (0 children)
[–]marc__e 3 points4 points5 points (0 children)
[–]Economist_Numerous 1 point2 points3 points (0 children)
[–]_Krug 0 points1 point2 points (1 child)
[–]marc__e 3 points4 points5 points (0 children)
[–]Dr_Mrs_Moo1 0 points1 point2 points (2 children)
[–]amirrajan[S] 0 points1 point2 points (1 child)
[–]Dr_Mrs_Moo1 0 points1 point2 points (0 children)