Sign in to follow this  
maxfire

Game Logic

Recommended Posts

Hey gys, I am currently coding/designing and SDL game Engine and Designer for old RPG style games (zelda, gauntlet, etc). I am currently up to implementing my combat system. Was just wondering if you gys could help me decide on my final design for my implementation.

Currently I have all my logic in one class. this class holds every game item then deals with movement and collisions, calling update function telling individual items how to react depending on the parameters passed in.

Now would it be wise to simply add my new logic combat logic to this class, still directly informing the game object, or should I decouple my logic so that I split the new logic into a new class.
I would then have this scenario, the logic engine would detect a collision decided on the type of collision (an attack, wall boundary, ect) and then pass the relevant object pointers to correct system class.
In game terms if an attack collision was detected the attack object and the attacked object would be passed to my combat system, this system would then make the relevant decision.

See my diagrams bellow;

My question is is this a logical way to go about it, since im simply passing pointer memory references there wont be much of a memory increase so performance loss isnt an issue. Or am I simply making it over complex.


Sorry for the long winded explanation :D

Share this post


Link to post
Share on other sites
Depends on the code and your goals for it, really; the first approach is certainly simpler and will likely be easier to implement the first time, but the second will likely be more flexible in case you want to expand or enhance the game logic down the road. If you can make it work with the first method, I say go for it; just pay careful attention to areas where things seem awkward or sticky, and think about whether or not it would make sense to split out into the second design. Nothing says you can't switch horses in mid-stream, after all!

In general, though, I say prefer the simpler solution unless you find that it's getting in your way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this