UnderwareDESIGN

PlayBASIC => Game Design => Topic started by: LemonWizard on February 10, 2013, 04:23:23 PM

Title: Best way to handle objects inside a game engine
Post by: LemonWizard on February 10, 2013, 04:23:23 PM
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?
Title: Re: Best way to handle objects inside a game engine
Post by: kevin on February 10, 2013, 09:56:47 PM
Quote200 unique in game objects

   What's unique about them ?
Title: Re: Best way to handle objects inside a game engine
Post by: LemonWizard on February 11, 2013, 04:33:09 PM
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.
Title: Re: Best way to handle objects inside a game engine
Post by: kevin on February 11, 2013, 11:29:28 PM
  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.

[pbcode]
 Type GeneralObject
 
 EndType


 Type Car as GeneralObject


 EndTYpe


 Type Van as Car

 EndType


 etc.

[/pbcode]