Thread: Creating a program within a program

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    14

    Creating a program within a program

    I know, the title does no justice.

    I want to know how to, say I was making a game engine (I want to, but I know I'm not exactly ready yet) say I compiled the program without errors, and now I test the game engine, now how would I be able to export my game made in this engine into an .exe that can be played without worrying about using the engine anymore?

    So how would I go about doing this? I fear the only two ways I know are...

    (A) Somehow compile the game within the program when it exports the game. (Which I don't believe is possible)

    (B) Put every little piece of binary into a file and call it SOMETHING.exe. (WAAAAY to tedious)

    (C) Use an external library or engine to export the game. (I don't know tof any engines that does this...)

    I know, I'm a newb, but I'm sure a lot of people have had this troublesome question before, I would be grateful if someone can help.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Are you thinking of your engine as something GameMaker-like (just as an example) where your game is not really code, but in your proprietary game engine format and has to be run through your engine?

    In that case, it's your job as the engine writer (not the game developer; the people making games wouldn't have a chance) to provide the functionality to turn that proprietary format into an executable (details would depend on how you build your engine, natch).

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    14
    I WOULD use that method, but I'm afraid that might sacrifice lots of speed.

    But what I mean is to export a functional .exe at all through my "game engine" whether it reads and executes a scripted language or not.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So that means "all" you have to do is write a compiler.

    (No, not that's not really true: what you can do is turn your proprietary language into an already-existing language like, say, C++, and then compile that code.)

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Basically, you create a library version of your game engine (everything except the main() you used to test the game engine). This you call for example mygameengine.lib.

    Along side that, you also have mygameengine.h which is the API of your masterpiece.

    Then newgame.cpp would be
    Code:
    #include "mygameengine.h"
    
    int main ( ) {
        // do stuff
    }
    Finally
    g++ newgame.cpp mygameengine.lib
    to compile your new game with your library.

    The syntax for creating and using libraries varies from one compiler to the next, so if you get stuck say what you have.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a program to help with modding
    By chuck22 in forum C++ Programming
    Replies: 9
    Last Post: 02-16-2006, 10:16 AM
  2. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  4. creating a simple program to accept a password.
    By boy1015 in forum C++ Programming
    Replies: 11
    Last Post: 02-05-2002, 08:34 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM