Giter Club home page Giter Club logo

Comments (9)

miguelmartin75 avatar miguelmartin75 commented on August 23, 2024

What advantage does this have to "scenes" (using polymorphism, that is)? For example, my library called pine has polymorphic states implemented within it: https://github.com/miguelmartin75/pine#game-states (note: the library uses a lot of templates, but it could be implemented without).

I know you use SFML

I only use SFML for the examples and prototyping, because it's simple to use and easy to get something to work. I may/may not use it for my final product, depending on the context (e.g. if I want to have a custom renderer, or use a different library to render objects [such as 3D models, particles, etc.]).


The WorldStateMachine seems a bit 'fixed'. (e.g. wsm.changeState(TITLE_SCREEN) depends on TITLE_SCREEN; is this an enumeration? and why do I need to know the state type during run-time?).

Does the WorldStateMachine depend on anax? I don't think it's really necessary for it to be included with the library. Perhaps make a separate repository for it? You could put a link to it in the wiki if you like, discussing ways to handles states and suggesting your own method (and comparing it with others, such as the one I mentioned above).

from anax.

JesseTG avatar JesseTG commented on August 23, 2024

Yes, TITLE_SCREEN is part of a hypothetical GameState enum. And what do you mean knowing the state type at run-time?

from anax.

miguelmartin75 avatar miguelmartin75 commented on August 23, 2024

I don't necessarily understand why you need to know what specific state you're in. i.e. if you switch to TITLE_SCREEN, you probably store the enumeration that tells you that you're in the title screen. However, you can just use polymorphism to achieve the same result, however, you don't require to know what state you are currently in.

In other words, you're defining a state as an enumeration, but why not as a polymorphic object? Then you don't need to know what type of state you're in, it is much more flexible (but of course requires inheritance, which is in some-ways bad, but in this specific case it seems rather useful IMHO). Unless you could use this state machine for more than just title screens/menus/etc.?

from anax.

JesseTG avatar JesseTG commented on August 23, 2024

I maintain it as both in case the same state object might be reused, but with different parameters of some kind. Also, so state objects aren't copied around too much. Like I said, I haven't worked out all of the design details yet.

In my game, I actually provide two flavors of WorldStates; one is the usual abstract base class with onEnter(), onExit(), and update() methods. The other, CompositionWorldState, takes in three std::functions as parameters, and those are the functions that are called.

from anax.

miguelmartin75 avatar miguelmartin75 commented on August 23, 2024

I maintain it as both in case the same state object might be reused, but with different parameters of some kind. Also, so state objects aren't copied around too much. Like I said, I haven't worked out all of the design details yet.

I'm actually interested to know what this is exactly. I suggest putting up the code on github so I can see it (even if you haven't finished it, it doesn't matter).

from anax.

JesseTG avatar JesseTG commented on August 23, 2024

Sure, I just need to decouple it from my own code. I'll make a pull request some time soon. There's a couple of other unrelated things I noticed would benefit from changing, too.

from anax.

miguelmartin75 avatar miguelmartin75 commented on August 23, 2024

I'll make a pull request some time soon

I'm not sure if it would be best (for users that is) for a WorldStateMachine to be added to the entity system. Since one of the design goals is to be quite minimalistic (i.e. aim to do one thing only, and that is provide an entity system, which is the same reason I don't have my own event system and etc. built in). Perhaps a separate repository would be better suited IMO, unless your "unrelated" changed directly change the entity system itself (if so, then perhaps have a separate pull request for these changes and a independent repo for the WorldStateMachine).

from anax.

JesseTG avatar JesseTG commented on August 23, 2024

I haven't changed Anax itself, I just have some ideas. WorldStateMachine does depend closely on Anax, though.

from anax.

miguelmartin75 avatar miguelmartin75 commented on August 23, 2024

I don't think this is really necessary for the library. However, feel free to link to your project here.

from anax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.