Dynamic programming, and .exe embedding questions (C++)

Started by
12 comments, last by Drakkcon 20 years, 1 month ago
I have two questions for you C++ experts out there. The first is hard. Im making a gui game maker, and I want it to be as user friendly as possible. Here''s my problem. How do I let the USER create a class. I want them to be able to create a "Soldier" character, and have a class be created with values the user defines like "solder.hitpoints", as well as functions like "soldier.displaysprite()". I already understand dynamic programming concepts, and I understand the theory behind STL; but I don''t know how to let the user create their own abstract data types. I know it''s possible because rpg toolkit has a similar setup.... The second question is probably easy. How do I run executables from source code. Is there some command that I''ve never heard of like execute "midiplayer.exe", or some function in some library like binaryexe("binpatch.com")? Two questions for you friendly experts PS: go easy if you''re elite, Im 14 The true general first seeks victory, then seeks battle - Sun Tzu
Advertisement
Try the WinExec() function to execute an executable from another program.
Perfect, thanks man Any run executable functions for linux? And if anyone would care to answer my hard question...

The true general first seeks victory, then seeks battle
- Sun Tzu
Sounds to me like you would need to use a scripting language, or make your own that runs in a custom virual machine or something... The first would be a lot easier.

Later,
Lord Hen

"I am free of all prejudices. I hate everyone equally." - W. C. Fields

[edited by - Lord Hen on December 2, 2008 2:32:49 AM]
Uhhh, yea, but the scripting language would have to have code that corresponds to it, and I don''t know what that code is, sooo has anyone tried this before?
quote:Original post by Drakkcon
...and I don''t know what that code is...


Umm....pick a scripting language, and find out how it works...

Lord Hen
That makes no sense. Scripting languages either plug in to existing applications, or run on an interpreter, which have no support for this kind of problem. If there are any that do, please direct me to it so the problem can be solved. I also need to understand the logic, so it would help if you could explain why a virtual machine has anything to do with allowing the user to create their own abstract data types. If it DOES, than your help is greatly appreciated.

What I meant by the "i dont know what this code is" part was that I would be coding a scripting language to solve a problem, that I couldn't solve with C++. Sorry for the ambiguity.

[edited by - Drakkcon on April 10, 2004 11:53:41 PM]
Having never done anything like this before, and not being an expert, please be very skeptical of anything I say here, as it is likely somehow flawed. With that said...

If you''re assuming your user has access to a compiler, you can create a base class with all the absolutely necessary functionality and all of the interfaces you''ll need for your program to be able to communicate with the user-created class. You provide this to the user in a header file, then the user creates their class with yours as the base-class, then compiles it as a DLL and places it in your program''s directory. Your program can scan its directory and link to any dll''s sitting there at runtime.

To see a system like that in action, check out the GDArena forum (you may have to set the "Show Topics From" date back a few months), and download it. That''s the system that was being used for Bot entries.


Unfortunately, if you aren''t assuming your user has a compiler, you either have to go with scripting language, or you can (I *believe*) write into your program something that will compile their code for them and do all the messy details for them. That, however, would require asm, and makes me shudder to think of it .
Actualy that''s what Im doing, and I''m learning assembly for that explicit purpose (maybe). Still, I know there''s an easier way to do it. The users will not know they''re using a compiler, it''s all point and click. Still, it''s possible that the class could be written to the clipboard when they hit "compile", then I could activate my scripting language compiler (which is nonexistant : ). Easy, but I''d rather find a hardcoded method (if one exists).

The true general first seeks victory, then seeks battle
- Sun Tzu
You could invoke the compiler from your gui builder on generated source code, and create a DLL (or indeed an exe which uses your library as a DLL) with the declarations / definitions of the new classes in.

It won''t be easy.

Of course you may then depend on shipping or having available a C++ compiler; this is non-trivial (from a technical and licence point of view).

The alternative is to use a scripting language (I find this more compelling).

Mark

This topic is closed to new replies.

Advertisement