Jump to content


how to organize my game objects in game world


2 replies to this topic

#1 zydgyy

    New Member

  • Members
  • PipPip
  • 10 posts

Posted 24 October 2011 - 07:24 AM

Hi,guys!
I read about,in my game loop,
while(true)
{
//update states of game objects in the game world
gameworld.update(dt);
physicsEngine.update(dt);
animationEngine.update(dt);
redner();
}
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 fireside

    Senior Member

  • Members
  • PipPipPipPip
  • 1621 posts

Posted 24 October 2011 - 10:29 AM

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.
Currently using Blender and Unity.

#3 robobrain

    New Member

  • Members
  • Pip
  • 3 posts

Posted 01 November 2011 - 03:52 PM

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 {

    public: 

    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.
Want to make Android Games?
Then check out the RoboBrain SDK beta.
http://www.robobrainsdk.com/beta/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users