Archived

This topic is now archived and is closed to further replies.

Arfa

Dynamic modules in a game?

Recommended Posts

I''ve come to the conclusion that modularity is a Good Thing and can be very useful in many cases. Let me tell you what I mean. Say, for instance, I''ve written a nice little driving game, but I want to be able to release loads of extra cars via the internet. I need to compile the cars into some sort of module. This module wouldn''t just contain model data and a few variables to say how it handles. Say that this car was unique in that it could fly, say. I would include some code in the module to make it fly, using the API provided within the game. Really what I want to do is (although alternatives are welcome) to write the flying code in C/C++, compile it, then get the main game code to import and run this module dynamically. The thing is, I''ve got to make calls to the API functions I''ve provided in the game code from the module code, and vice versa. Got no idea how to do this: any ideas? => Arfa <=

Share this post


Link to post
Share on other sites
One solution is to release the cars as dll files (or data files with a dll controller). The DLL contains a Update(myState) function that returns physics and whatnot for the car. This allows for every car to have its own tweaked physics.

Share this post


Link to post
Share on other sites
well, if you really want to do something to wow the rest of the world, right your own scripting engine.


Its an advanced topic, of course, but the result is really cool. Look on Flipcode for a tutorial.

===============================================
"Tell brave deeds of war."
Then they recounted tales, -- "There were stern stands And bitter runs for glory."

Ah, I think there were braver deeds.

Share this post


Link to post
Share on other sites
Thanks guys.

All three solutions would probably work. I think the best one is COM, but it''s a huge topic to learn. Plus, if I was ever going to make the game run under Linux, say, I''d have to learn COM and CORBA.

Another idea: how do WinAmp plugins work?


=> Arfa <=

Share this post


Link to post
Share on other sites
Well OOP is your answer. Just make dynamic table which takes in that module and reads it and melts it to your code.
Also in this case you should put all needed funtions to your code. I think there aren''t much things that car can do? Just basic options, jumping, flying, shooting, and other things like that. Read that file to dynamic table and then just use it...


Also, you can patch all needed files so that it makes that car fly...

Share this post


Link to post
Share on other sites
Good idea. Hadn''t thought of that, Ferdinand.

Arc@eon, OOP sounds a much simpler solution than learning the COM interface, but how do I do it? Any code examples, tutorials or references anywhere?

=> Arfa <=

Share this post


Link to post
Share on other sites