Best way to handle objects inside a game engine

Started by LemonWizard, February 10, 2013, 04:23:23 PM

Previous topic - Next topic

LemonWizard

How should I handle objects in a game engine if I have say 200 unique in game objects without doing this:


do

;;skip actual code since it's placeholder example only

handleenemytype1(camerax, cameray, scrollx, scrolly, playerx1, playery1, playerx2, playery2)
handleenemytype2( ...)

etc..




loop


What i'm asking is how can I do this type of thing in a more generic way?

kevin

Quote200 unique in game objects

   What's unique about them ?

LemonWizard

They're of different types. So different values would need to be accessed. Different conditions would also apply.
For example certain enemies can fly others can't, certain enemies fly at a faster speed than others.
The flying trait won't even be included in enemies that can't fly.
Various other things, such as how many animation frames each one has.

Different enemies are going to need unique data sets because certain collision detection only occurs between specific enemy types as well.
Certain enemies can interact with tiles or world objects and others can't.

kevin

  If you have lots of different 'structures' then you need lots of different code to drive them, let alone setting up 200 different structures.  Nothing you've outlined requires it.   It doesn't matter if the car object doesn't fly, as long as the structures are inherited from the from common parents.

PlayBASIC Code: [Select]
  Type GeneralObject

EndType


Type Car as GeneralObject


EndTYpe


Type Van as Car

EndType


etc.