How to link subprograms to a main program's game loop?
Posted
by
Jim
on Game Development
See other posts from Game Development
or by Jim
Published on 2014-06-02T12:45:06Z
Indexed on
2014/06/02
16:01 UTC
Read the original article
Hit count: 303
c
I recently discovered Crobot which is (briefly) a game where each player codes a virtual robot in a pseudo-C language. Each robot is then put in an arena where it fights against other robots.
A robots' source code has this shape :
/* Beginning file robot.r */
main()
{
while (1)
{
/* Do whatever you want */
...
move();
...
fire();
}
}
/* End file robot.r */
You can see that :
- The code is totally independent from any library/include
- Some predefined functions are available (move, fire, etc…)
- The program has its own game loop, and consequently is not called every frame
My question is roughly : how does it work ?
It seems that each robot's code is compiled by the main program and then used in a way I cannot understand. I thought it could yields a thread for each robot, but I have not any proof of this and it seems a bit complicated to achieve it. Any idea how it could work, someone ?
© Game Development or respective owner