Jump to content
  • Advertisement

Archived

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

Drakkcon

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

This topic is 5328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try the WinExec() function to execute an executable from another program.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!