Managing updates of many types of object

Started by
3 comments, last by zqf 12 years, 5 months ago
I've got the hang of most isolated elements of making games, such as loading levels, colliding objects and controlling the state and flow of the game, but I'm having great difficulty with the structure of the game loop itself when it comes to updating all the objects and sorting through such a large potential of actions.

In my previous, simple projects I've stored objects in seperate lists, going through each list in turn and doing exactly what that specific thing should do, but now I'm making something much more complex with a world and many different enemy types, triggers, traps, projectiles and such, and it's twisting my melon trying to find a straight forward and adaptable way to go through all these objects and update/move/collide with the player, collide with monsters, collide with projectiles and so on in the correct way. And how do I feed them the information to do so when I do.

So I guess I'm looking for some general advice or ideas on such things. Will I just have to live with a huge pile of ifs and switches? All of my individual elements are working, but it's confusing me trying to pull it all together...

So any advice is really welcome :wacko:
Advertisement
You want to begin by grouping your game objects into hierarchy's so that you have fewer objects to manage at the root, and things that depend on other things will automatically be handled for you through a parent-child relationship.

Depending on what kind of game you are making, the grouping structure will be different, but the idea is the same. If you google "scene graph" you'll be able to find many details on how to implement this in your game, without knowing exactly what kind of game you are making it is hard to suggest how to group things together.
It might help if you mentioned some details about your project, like what programming language you're using.
2D top down shooter with tiled levels.
I'd like to add some simple adventure/RPG style components that could make the world a bit more varied and interactive.

Language: ActionScript 3
I'll try and be a bit more specific about my problem, I know it's really vague. Perhaps I should just go and mess with some code and then come back with a more defined question, but I'll have another go.
So say I've got an enemy, it's updating searching for objects near it to interact with. It could be other monsters, the player, bullets or items. What would be a stable way for it to identify what an object is and then how to act on this.

Perhaps it calls a collision function that finds a collision between the monster in question and a bullet, but perhaps I want different monsters to react in different ways to being hit. How can I do this with the collision function not knowing exactly what it received (just that it had two things to find a collision between). I'm looking for a structure like this that can interact objects where each object can react in a customised way that might be similar to fellow objects but not the same (like many different monster types).

I hope that explains it better :E

This topic is closed to new replies.

Advertisement