How to get scripted programs governing game entities run in parallel with a 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/07
15:41 UTC
Read the original article
Hit count: 273
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: How to achieve a similar result using scripted languages in collaboration with a C/C++ main program ?
I found a possible approach using Python, multi-threading and shared memory, although I am not sure yet that it is possible this way. TCP/IP seems a bit too complicated for this kind of application.
© Game Development or respective owner