how to organize my game objects in game world

zydgyy 101 Oct 24, 2011 at 07:24

I read about,in my game loop,
//update states of game objects in the game world
So,how do i organize the game objects in the game world?what kind of data structures should i use to update them quickly?Any suggestions?

2 Replies

Please log in or register to post a reply.

fireside 141 Oct 24, 2011 at 10:29

It might be easiest to build a small prototype. Usually the game entity is the smallest object. A world is comprised of entities in a specific situation. The physics engine updates the entities motion.
Also, you can look at some open source engines around and see how they are organized. FlashPunk is a pretty cool little open source engine written in AS3, or find some tutorials on the net.
Mostly just build some small games. It’s just a way of organizing a game loop.

robobrain 101 Nov 01, 2011 at 15:52

Most of the game engine’s I’ve worked on have a base Entity class that all of the game objects derive from. And usually it looks something like this:

class Entity {
    void update();
    void onCollision(Entity e);

that way when you are looping through all of your game objects, you can just call update() and do whatever physics, ai, rendering, etc. you need. Do your collision reactions in onCollision, etc. Just think about what operations you need to do on all of your entities and make sure there is a function for it in the base class.