-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example of using Tetra with an ECS library #45
Comments
Someone has been porting their own Specs code to Tetra as an experiment, and they made a good observation - currently The solution might be as simple as replacing the |
Hi! First off, thanks for creating Tetra. It really suits the concept of a game I'm creating right now. I especially like how simple working with animations is. Now for the relevant bit. I am planning to use Specs for this game, and I would really like to use Have you looked into implementing |
First of all, thank you for the kind words :) I'd be interested to hear your experiences with Onto the actual question! It would be possible (and quite easy!) to make
So I'm currently leaning towards thinking that storing a
You'd potentially also need to add some kind of identifier component to know which entities should be drawn with which texture, but that'd be a lot cheaper than trying to synchronize access to the texture object itself. Hopefully that gives you some ideas! The fact I'm having to write a post this long definitely indicates I need to write some example code 😛 If you get stuck with it, I'd definitely like to hear the pain points. |
The game I am creating is quite simple and I hope to replicate the feel/responsiveness of an 8-bit Atari game. For instance, the tick rate is at 1/30, and the frame_length of my main character walk animation is 4, so that animation runs at 7.5 fps. It's not performance or predictability I'm specifically after. I have experience with sprite animation in Unity, and I've looked into approaches in Amethyst. When I saw how simple sprite animation was in Tetra, things clicked. It's about workflow; the minimal info you need for an animation is the location of the frames in a texture, and the speed at which the animation runs. The fact that an animation is considered a Drawable, makes for really elegant code, Textures can be replaced by Animations by changing one line of code. The use of the Rectangle Row and Column classes makes understanding the code a breeze. I can add stuff fast, and that's so nice, considering I'm working on this project in my spare time.
That sounds like the best approach. In fact, your roguelike demo gave me the confidence to start with Tetra, as it showed that Specs integration was possible. Though, I thought you were using text output (Console), but I now see that the font is basically a spritesheet, and the Console module an abstraction. I think I can get away with a custom Component that holds the information needed to know what to draw. It's really only a tag (Spider, Rat, Wasp, Door) and an animation state (Walking, Attacking, Dead, Open, Closed). I think hashmaps will work well for this. There's just one thing I need to figure out. If the Entity does not hold it's own Animation object, but the Animation object is determined in And... If I determine the animation based on some Entity state, I should not determine the animation every game tick; if the Entity was walking, and is now still walking, we should only I am confident enough to try it. Maybe my experiences can help designing a bare-bones Tetra/Specs example, considering that's what this issue's actually about 😄 |
That's really helpful feedback, thank you! I To focus on a few bits in particular:
I'm actually currently looking at potentially changing the
This is a really good point, and I hadn't considered this use case until now! One potential solution I can think of off the top of my head - maybe Tetra could offer a The There's nothing about
I'd definitely love to take a look at your code, if you do come up with anything 😄 |
@SymenTimmermans: Here's some minimal example code for how Feel free to copy it into your codebase and use it as a starting point if you want 😄 https://gist.github.com/17cupsofcoffee/1eb6b061a9c4b5f9237d25de49c1dc52 Also check out the animation controller example if you haven't already - it shows how you could wrap an animation in a state machine to handle transitioning between states. Should apply equally to |
That's amazing! Thanks. I recognize the implementation of |
I see this is marked as a good first issue. I don't know if @SymenTimmermans intends to contribute an example here, but I'll take a shot at converting Also - thanks for the cool engine, @17cupsofcoffee ! |
@rghartmann I would rather keep the existing |
Yes, that's what I was thinking - a separate version altogether. Sorry it
wasn't clear 🙂
…On Sun., May 30, 2021, 01:39 Joe Clay, ***@***.***> wrote:
@rghartmann <https://github.com/rghartmann> I would rather keep the
existing bunnymark minimal, as it's what I usually use to benchmark
changes to the renderer, but if you'd like to create a seperate version of
it (or a new example entirely) that uses Legion/Hecs/whatever, I'd
definitely be interested in that!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADUSLKQH4GJ4PHYIKY6JUATTQH2THANCNFSM4GLEZUEA>
.
|
I've got the example working - how best to contribute it? I also couldn't find where you keep documentation so I could add the ECS example to the list; Let me know how to proceed. |
If you could submit it as a PR, that'd be ideal - if it's just one file you can do that pretty easily through the GitHub UI: Documentation is in a seperate repo, I can update that myself later. |
Yeah, I couldn't push a branch due to permissions, that's why I asked. It's
two files since I'm including legion as an optional dependency.
…On Mon., May 31, 2021, 01:52 Joe Clay, ***@***.***> wrote:
If you could submit it as a PR, that'd be ideal - if it's just one file
you can do that pretty easily through the GitHub UI:
[image: image]
<https://user-images.githubusercontent.com/784533/120167465-aee00f80-c1f5-11eb-9a90-64a006870972.png>
Documentation is in a seperate repo
<https://github.com/17cupsofcoffee/tetra-www/blob/main/docs/examples.md>,
I can update that myself later.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADUSLKSIDPH45ZPLIHOHQSDTQNE47ANCNFSM4GLEZUEA>
.
|
Just following up; Any guidance?
On Mon, May 31, 2021 at 6:29 AM Rodrigo Hartmann ***@***.***>
wrote:
… Yeah, I couldn't push a branch due to permissions, that's why I asked.
It's two files since I'm including legion as an optional dependency.
On Mon., May 31, 2021, 01:52 Joe Clay, ***@***.***> wrote:
> If you could submit it as a PR, that'd be ideal - if it's just one file
> you can do that pretty easily through the GitHub UI:
>
> [image: image]
> <https://user-images.githubusercontent.com/784533/120167465-aee00f80-c1f5-11eb-9a90-64a006870972.png>
>
> Documentation is in a seperate repo
> <https://github.com/17cupsofcoffee/tetra-www/blob/main/docs/examples.md>,
> I can update that myself later.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#45 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADUSLKSIDPH45ZPLIHOHQSDTQNE47ANCNFSM4GLEZUEA>
> .
>
|
Sorry for the delay, this week's been a bit hectic. I think to push multiple files you'd need to make a fork and then PR from that - if that's too much hassle though, just submit the example file as a PR on it's own and I'll add the Legion dependency 👍 |
No worries mate! I am busy around a sick kiddo too, but should pull it up
this week. It will need some serious review since I'm not experienced with
Rust, nor game dev in general. But if it goes well, I'll likely update it
down the road with a more complete ECS example.
…On Wed, Jun 9, 2021 at 4:49 AM Joe Clay ***@***.***> wrote:
Sorry for the delay, this week's been a bit hectic. I think to push
multiple files you'd need to make a fork and then PR from that - if that's
too much hassle though, just submit the example file as a PR on it's own
and I'll add the Legion dependency 👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADUSLKT5OLMEYGO6BWPGASDTR5INZANCNFSM4GLEZUEA>
.
|
Sounds good, no rush and hope your kid feels better soon! |
Thanks for mentioning me! However, I have basically abandoned Rust game-development for now, in favor of using the Godot engine, since learning bindings with Rust (and ECS libraries) are possible. I still think Tetra is a really nice project and encourage it's further development! |
Done by @rghartmann in #268, finally! 🚀 🚀 🚀 And no problem @SymenTimmermans, glad you've found tools that work well for you :) |
I'm not sure whether I plan on using anything as heavy duty as Specs for now, but it'd be good to have an example in the repository, both for the sake of documentation and to make sure any API changes we make play nicely.
I ported my
rl
demo from GGEZ to Tetra and it seems to work well, although it's probably a bit more complicated than what we're looking for here.The text was updated successfully, but these errors were encountered: