# Complex Game Structure?

**URL:** <https://forum.kirupa.com/t/complex-game-structure/280956>\
**Category:** programming\
**Created:** [February 3, 2009, 12:28pm UTC](https://forum.kirupa.com/t/complex-game-structure/280956 "2009-02-03T12:28:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandpaw\_broon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/grandpaw_broon/32/3985_2.png) [@grandpaw\_broon](https://forum.kirupa.com/u/grandpaw_broon)\
**Post date:** [February 3, 2009, 12:28pm UTC](https://forum.kirupa.com/t/complex-game-structure/280956/1 "2009-02-03T12:28:33Z")

</div>

Hi all,

I have quite a complex game in development at the moment and i am struggling with the architecture.

I might have a few questions, and id appreciate if you could give me advice. Some of them might seem basic but i need to get rid of the doubts, often i read books, forums and blogs and get conflicting advice.

Firstly, in terms of larger games, do you use ineritance or composition for display objects?

```auto
public class GridDisplay extends Sprite
{
     public function GridDisplay()
     {
          addEventListener(Event.ADDED_TO_STAGE, init);
     }

     private function init(): void
     {
          //draw your grid here
     }
}

```

Usage:

```auto
var grid:GridDisplay = new GridDisplay();
addChild(grid);

```

Or is it best to use composition?

```auto
public class GridDisplay
{
     private var _sprite:Sprite;

     public function GridDisplay(gridSprite:Sprite)
     {
          init()
     }

     private function init(): void
     {
          _sprite.? //draw your grid here
     }

     public function moveToX(number:Number): void
     {
           _sprite.x = number;
     }
}

```

Usage:

```auto
var gridSprite:Sprite = new Sprite();
gridSprite.x = 400;
gridSprite.y = 400;
addEventListener(gridSprite);

var grid:GridDisplay = new GridDisplay(gridSprite);
grid.moveToX(100);

```

What is the best approach on this?

Thanks!
