is just something that i was thinking about lately

normaly game code is something like:
GameMain
{
getinput();
collision();
render();
and it goes...
}
|
but sometimes(actualy all the time...) you wanna to change something, example you wanna to render the screen in wireframe, so normaly you do something like:
GameMain
{
getinput();
collision();
render( type of render );
and it goes...
}
|
so it more-or-less means that:
render(type)
{
if (type == WIREFRAME)
{
do wireframe...
}
else
{
and it goes...
}
|
so in the end you have big number of "if"s, "else"s, "switch"s, etc... and lot of variables to controls those, things that are supose to eat resurces, so i came with this "way of programing"
you make a array of function pointers, do a avaliation of the necessary functions( make lots of non-general functions. like: instead of render() do render_wireframe(), render_textured(),etc) and assign the pointers with they, and execute they in a loop util the program is over or there is need of a new avaliation of the functions
(btw: all extra informatin is keep in globals)
this way allows less "if"s in the code and open a lot of possibilities ( like: you could do a init_render() and a end_render(), and put opcional functions like render_particles(), render_actors(), render_that(), render_this(), etc in the middle. or maybe make diferent function arrays for redering, AI, sound, etc)
but i know that im not a genius, or neither the first person to think in that, so why people don't use it? it makes something hard to program or anything else?-
-------------------------------
MOTHERSHIP!!! hahaha! very funny! now take me outta here!!!!!
Edited by - The Alchemist on July 3, 2001 10:27:29 PM
"Everything works out in the end, if it doesn't then it is not the end"