How GE goes about displaying your game
Posted: Tue May 02, 2006 6:04 am
Take this with a grain of salt: I didnt write GE, so only Makslane really knows. This is how it SEEMS to work however.
First, your game starts up. Something similar to a create game event happens. You will not find this in the list of events. Its behind the scenes; only Makslane has access to it. In it, all the variables get created, the actors, and whatnot. Incidently, the Global code happens around here.
Actors are really just complicated variables, you see. Just a little collection of numbers and functions, and a series of pointers to graphics in memory.
Anyway...
The first thing that your new game does is execute a special function called create actor for View! Did you know view has a create actor event?
It sure does, and you can put stuff in it just like an actor! It is an actor! furthermore, it calls each actors create actor events.
So what happens next? Create actor->view calls another function belonging to view, and not so coincidently, every actor. That function is the Draw event. Again, you can put stuff here too, and it only happens once every frame, so its a great way to reduce lag.
Inside the views draw event, GE makes a list of all the actors in the game, that are at least partially in the limits of view, and then calls their draw actor events.
Each actors draw event does what you tell it(events, scripts, whatnot), then it communicates how to draw itself to the view. It finishes and hands control back to view.
One per draw event, the keyboard gets checked for keypresses, and the mouse does too. All the other events happen around here.
View takes over and sorts the actors by their z depth and draws the furthest first, and the closer ones last. Then it makes a new list of all the actors in view... and starts all over again.
Thats it in a nutshell.
First, your game starts up. Something similar to a create game event happens. You will not find this in the list of events. Its behind the scenes; only Makslane has access to it. In it, all the variables get created, the actors, and whatnot. Incidently, the Global code happens around here.
Actors are really just complicated variables, you see. Just a little collection of numbers and functions, and a series of pointers to graphics in memory.
Anyway...
The first thing that your new game does is execute a special function called create actor for View! Did you know view has a create actor event?
It sure does, and you can put stuff in it just like an actor! It is an actor! furthermore, it calls each actors create actor events.
So what happens next? Create actor->view calls another function belonging to view, and not so coincidently, every actor. That function is the Draw event. Again, you can put stuff here too, and it only happens once every frame, so its a great way to reduce lag.
Inside the views draw event, GE makes a list of all the actors in the game, that are at least partially in the limits of view, and then calls their draw actor events.
Each actors draw event does what you tell it(events, scripts, whatnot), then it communicates how to draw itself to the view. It finishes and hands control back to view.
One per draw event, the keyboard gets checked for keypresses, and the mouse does too. All the other events happen around here.
View takes over and sorts the actors by their z depth and draws the furthest first, and the closer ones last. Then it makes a new list of all the actors in view... and starts all over again.
Thats it in a nutshell.