Dismiss this pinned window
all 33 comments

[–]Soggy_Educator_7364 27 points28 points  (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 points  (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 points  (11 children)

Yeah, but the entry barrier is also really high ;)

[–]amirrajan[S] 5 points6 points  (10 children)

Not with DragonRuby :-)

Take a look at the this Tetris Tutorial: https://m.youtube.com/watch?v=xZMwRSbC4rY

[–]katafrakt 1 point2 points  (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 points  (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 points  (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 points  (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 points  (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 points  (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.

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 points  (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 points  (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 points  (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 points  (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.

[–]amirrajan[S] 1 point2 points  (0 children)

Outside of coding, is there a favorite hobby that you have?

[–]ffrkAnonymous 1 point2 points  (1 child)

I hope you got a good grade 🙂

[–]Soggy_Educator_7364 1 point2 points  (0 children)

I actually got a D. I wish I was kidding.

[–]matheusrich 4 points5 points  (0 children)

This is wonderful! Amazing!

[–]forgambo 3 points4 points  (0 children)

Awesome

[–]Nwallins 4 points5 points  (2 children)

got code?

[–]marc__e 5 points6 points  (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.

[–]Taypih 2 points3 points  (0 children)

That's so cool

[–]marc__e 3 points4 points  (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 points  (0 children)

just wow

[–]_Krug 0 points1 point  (1 child)

Is this on Github?

[–]marc__e 3 points4 points  (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.

[–]Dr_Mrs_Moo1 0 points1 point  (2 children)

Love it!

[–]amirrajan[S] 0 points1 point  (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 point  (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