How to Create a Good Action System

I need to create an action system for my game in order to dynamically assign bits of code to certain elements of it. Because my game is made up of blocks, actions such as WALK_ON and WALK_OFF would be the most important. What I have done so far is create an array of the class Action in the superclass of the blocks, “BlockSuper” and make an enum inside Action which consists of the 2 aforementioned attributes.

However I am not quite sure where to go from here. What path should I take in order to make this a functional system? This system needs to be dynamic enough that I can easily create new actions such as “When this block gets stepped on, this other block needs to disappear”. Or do I not really need such a system but something much more simple? I may be overthinking things here.

Thanks for any help, it’s greatly appreciated.

This somewhat sounds similar to an EntitySystem,
search in the forum with this keyword, and see if that is what you want to archive

At least Mythruna is using such a system, (wich was even shared with the community, i think its names zay-es,) you will find it in the forums.

Wouldn’t getting a whole library for this one purpose be kind of overkill? Also, I don’t see how an entity system could help in this situation, would you mind explaining?

I’m not sure an ES is really appropriate here.

On the other hand, I’m also not clear from your description what problem you are having. You say “dynamically assign bits of code” but it isn’t clear to me why you wouldn’t just “dynamically assign bits of code”.

Give this a read: Finite State Machines: Theory and Implementation
It has some great examples there and might help you with your design.

1 Like

Problem solved, I had to do a bit of complicated programming, but thanks for the help guys :slight_smile:

@Sploreg said: Give this a read: Finite State Machines: Theory and Implementation It has some great examples there and might help you with your design.

im not the OP, but that was a really good article. thanks for posting it.