8
\$\begingroup\$

I'm learning to create a game engine from scratch in XNA. I'm seeking examples of very small game engines, specifically the architecture and structure of source files, etc. It should include a scripting engine. Articles are also appreciated.

More specifically, I have a problem knowing how to connect the scripting engine to the rest of the game engine, like loading a models from the script.

\$\endgroup\$
3
  • \$\begingroup\$ Just out of interest, why do you need a scripting engine? C# itself already solves almost all of the problems a scripting engine is used to solve. And XNA is already a "very small game engine" that can load models. \$\endgroup\$ Sep 5, 2010 at 1:09
  • \$\begingroup\$ The guy who I'm working with said he wants a scripting engine so he doesn't have to recompile the game whenever something in the story changes. \$\endgroup\$ Sep 5, 2010 at 2:27
  • \$\begingroup\$ Just so you know, there are pure C# solutions to that problem: stackoverflow.com/questions/1353456/… (the C# compiler is part of the runtime). \$\endgroup\$ Sep 5, 2010 at 3:21

2 Answers 2

2
\$\begingroup\$

The Angel Engine is a very nice, small Open Source engine written in C++ and OpenGL. Plus it has a Python scripting interface. Although the engine is not written in C# it should give you a few pointers and ideas, and from the little I've played with it the code is very clean and easy to understand even if you're not totally up on C++.

\$\endgroup\$
4
\$\begingroup\$

I like the book Programming Role Playing Games with DirectX (2nd edition) for its scripting section; I haven't really seen a start-to-finish tutorial on making a scripting engine elsewhere. And of course, being a book, it will walk you through step-by-step creating the scripting part of the engine (and the whole rest of the game engine that he establishes throughout the book, of course). Unfortunately the source code isn't available online.

Once you have a scripting engine, I would keep separate the 3D models from the scripts. Scripts are typically in the logic side of things, while 3D models are most certainly the presentation/view side of things, and those shouldn't really be mixed. When a script commands a character to "walk to (3,5)", it doesn't need to say "load walking animation, set velocity to (-1,1), wait 3 seconds, set velocity to zero, load idle animation"; you'd typically just have a walkTo(x,y) function available to the script, and the intermediate code would take care of 3D models, animations, etc.

But hey, if you really need to, then define your own functions in your scripting interpreter which get 3D models and do whatever you need with them. I think you're thinking a bit too far ahead; worry first about writing a simple script interpreter, and then add the necessary functions to the interpreter as you're writing your scripts.

\$\endgroup\$
0

Not the answer you're looking for? Browse other questions tagged .