CodingRendle & C#

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Mikee   
 To:  ALL
35151.8 
Ok, I've got another one for you if you could be so kind.

Basically, we've extended the XNA framework slightly and bastardized it slightly to suit our needs.

In XNA the main 'Game' class calls methods.. (Initialize(), LoadContent(), Update(), Draw()). It calls update and draw x times per second.

We've set things up so that you add Screens to the main game class, then you add components to screens. Components also have their own list of components and they have their own list of components and so on.

When Update() is called in the main Game class, it'll call Update() on all the screens, which'll call Update() on all the Components and their components..etc..

So, a small example would be like this:

code:
 
Game    Screen        Component    Component
------- ------------- ------------ ----------
 
Game -> 3dScreen   -> Sheep     -> AI
                                -> Render
                                -> Physics
 
                   -> Dog       -> Controller
                                -> Animation
     -> MenuScreen -> Setup
     -> HUDScreen  -> Radar
                   -> Healthbar
 


Although we're not at the stage of making any actual game logic just yet, I know that components will need to talk to eachother and/or their parent component.

In an example of an engine that i've seen, they use this big messaging system to talk between components/screens, whereby components (or screens) can listen to a certian messages and will receive all messages of that type.

This seems all complicated to me and using events and eventhandlers seems like the way to go.

Can you think of a better way to do any of this? I'm also concerned about speed.. for example, would a onPositionChanged event on model (which can fire 100 times a second) be too much?
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Mikee      
35151.9 In reply to 35151.8 
I would certainly start by using event handlers, rather than reinventing the wheel. If you try to implement your own system, you risk problems with objects not getting dereferenced and garbage collected.

Twinkle, twinkle, little star, I don't wonder what you are:
You're the cooling down of gases, forming into solid masses.
0/0
 Reply   Quote More 

Reply to All    
 

1–9

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats