Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19

    Creating an program that programs another program


    How would i go about creating an execute file that has the potential of creating another execute file in c++. I can do all the rest but i need the code to create a c++ file that can be automatically compiled into an execute file. I want to create a useful program that can create another text based generic console execute file which the user does not have to have any knowledge of c++ or programming in itself. Is the only way i can go about this is just use fout.open("c:\\WHATEVER FILE.c++) And at the end have a completely created c++ file that can be compiled and then have to include dev c++ and put a readme that gives instructions on compiling their own created game? These are all just ideas but can someone tell me maybe the "best" way to go about doing this.
  2. #2
  3. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    Not sure why this was posted in Game Development, Moved to C Programming.
  4. #3
  5. No Profile Picture
    Closet coder
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2005
    Location
    Plantation, FL <---south florida
    Posts
    1,431
    Rep Power
    153
    you can create a batch file that takes arguments when you call it. inside the batch file you can include commands to compile code youve written. google things like "batch compile". heres something i found for visual studio, maybe something similar for devc++ http://www.algorithmic-solutions.inf...MS_Visual.html
  6. #4
  7. Google Relay Server
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2003
    Location
    Oh christ I don't even know any more.
    Posts
    1,812
    Rep Power
    439
    Originally Posted by fierydog
    And at the end have a completely created c++ file that can be compiled and then have to include dev c++ and put a readme that gives instructions on compiling their own created game?
    You aren't going to be able to generate executables from C++ code without compiling the code. You probably don't want to write your own C++ compiler in your program. And even if you did keep in mind that you'd have to distribute it with pretty much a full set of system headers and libs, depending on what you were compiling. So generating C++ files is not a bad idea.

    If you go this way, you could place the requirement on the user that they have some sort of C++ compiler installed, such as GCC or the MS compiler. That's not a big requirement, as C++ compilers are readily available. Your program could then use that compiler to compile the generated code for them.

    If it makes you feel any better, this is how pretty much every IDE (like Visual Studio) works... the compiler is a separate program, the IDE is just a nice convenient front-end for it.

    What are you trying to do?

    Alternatively you may wish to reconsider how your program works. Are you sure you want to generate C++ code and compile executables? Perhaps you could just store the required data in a data file and then you could have a single executable that could "run" whatever was in those data files.

    For example, if you just wanted the user to be able to, say, print things to the console without knowing C++, you could store commands in a file, like:

    Code:
    PRINT here is a line
    PRINT here is another line
    Then you'd write a program that can interpret that data and do the right thing with it. And so you didn't need to generate actual C++ code and a binary for it. That's a really trivial example, though.
    Last edited by peenie; June 29th, 2006 at 09:36 AM.
    OMG RAVER CHICKS!!
    On a related note: C/C++ Programming Tutorials


    "Science is based on reality staying the same, and Nature ignores what humans vote upon." -- Bill Beaty
    "Three litres of sherry up the butt can only be described as astounding." -- Darwin Awards
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19
    Yeah i want to create something that can use just simple if statements maybe switch statements too and be able to create a basic text based game of the users desired choice that is completely written as a c++ compiler and just include some compiler (heh, i use dev c++ so download time would be forever and i dont know any other compiler) that should be pretty cool right? This would be an example of what the program would be like:

    What do you want to do?
    Print-1
    Use if statement-2
    use switch statement-3
    (say user enters 1)
    What would you like to print? (say user enters "something")
    Then all i would do is:
    fout << "cout << variable << endl;";
    Then enter some goto menu;
    and just have a continuous loop until the user has written his program.
    Good idea?
    Also can strings only read the ea in say: ea sports
    Or am I lucky and they read spaces.
  10. #6
  11. Google Relay Server
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2003
    Location
    Oh christ I don't even know any more.
    Posts
    1,812
    Rep Power
    439
    Well, you don't need to have Dev-C++ to use GCC. Dev-C++ uses MinGW tools, which can be downloaded here without all the extra Dev-C++ stuff that your users wouldn't need.

    And in any case, even if you gave the user instructions on how to compile they're code, they'd still have to obtain a C++ compiler at some point. So you might as well just require that they have it and have your program use it to save them the trouble. If you go the route of generating C++ code, you're going to have to have a way to compile it. Period.

    An alternative would be to write your own, minimal script language of sorts, similar to what I had suggested above (but with the addition of the branching and looping constructs that you wanted). The user would need nothing but your program. Not the easiest project in the world, but certainly not the hardest. Going that way will give you a really interesting learning project, at least.

    Have you ever heard of ZZT (I hope you have :D )? It allowed people who knew nothing about "real" programming languages to write games with a graphical editor and a scripting language called ZZT-oop. Good stuff.

    However, no matter what you decide, you may still want to start off generating C++ code. At the bare minimum, you can at least proove to yourself that you can do it and run it on your machine. Then you can move on once you feel comfortable.
    Last edited by peenie; June 29th, 2006 at 12:02 PM.
    OMG RAVER CHICKS!!
    On a related note: C/C++ Programming Tutorials


    "Science is based on reality staying the same, and Nature ignores what humans vote upon." -- Bill Beaty
    "Three litres of sherry up the butt can only be described as astounding." -- Darwin Awards
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19
    Yeah all it really is, is a learning process. Ok, so I am writing my part of the executable program. What do i do about the user input because spaces cannot be in a string? Heres my logic for output:
    Code:
    void createtext()
    {
         ofstream fout;
         fout.open("c:\\YourProgram.cpp");
         string userinput;
         cout << "What do you want to say to the user?" << endl;
         cin >> userinput;
         fout << "cout << " << userinput << "endl;" << endl;
         fout.close();
    }
    But the problem is the string userinput can't have the user enter spaces so when that happens the program goes into an ENDLESS loop.

    And how do i go about learning zzt OOP never worked with scripts and dont know how to get them into c++ and compile it :( I found supposively all the OOP commands but I don't have any idea what to do. Is there supposed to be an #include <OOP> or something?
  14. #8
  15. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,556
    Rep Power
    2338
    Look into cin.getline. Heck, read up on iostreams in general. Certainly can't hurt!

    Comments on this post

    • peenie agrees
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  16. #9
  17. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    You might also want to try to embed a scripting language instead of having the program generate and compile and execute C++ code. I'm not familiar with games programming, but I've heard that Lua is a popular scripting language and I believe that the scripting engine is free.

    One obvious advantage is that your program will include the script interpreter and so the user will not need their own compiler.

    Comments on this post

    • peenie agrees
  18. #10
  19. Google Relay Server
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2003
    Location
    Oh christ I don't even know any more.
    Posts
    1,812
    Rep Power
    439
    Originally Posted by fierydog
    And how do i go about learning zzt OOP never worked with scripts and dont know how to get them into c++ and compile it :( I found supposively all the OOP commands but I don't have any idea what to do. Is there supposed to be an #include <OOP> or something?
    Haha @ #include <OOP> :D

    Anyways, ZZT-oop was a scripting language for writing levels for the game ZZT. Learning it is not going to help you out with your application unless you want to procrastinate by building ZZT levels (*wink* *wink*). I was pointing it out as an example of a game that had it's own scripting language and level editor -- just as an example of what I had been talking about. People can build ZZT levels and program in the behavior and the only program required to run it all is ZZT itself; no C compilers or anything are necessary. The game Quake was the same way, although much more advanced (and games since then have become even more complex).

    Another way to think of it is that your application is the game. But it also has a built-in "level editor". If you design it so that the "levels" that people create are playable entirely by your application, then you don't have to bother generating EXE's or anything like that. All you have to have is files that, in some way or another, store all the data necessary for your application to let a user play that level.

    The suggestion that dwise1_aol made is a good one. I know nothing about Lua, but you could make your program generate Lua scripts and distribute the Lua interpreter with your program. That way you wouldn't have to mess around with a C++ compiler, and you wouldn't have to develop your own scripting language.
    OMG RAVER CHICKS!!
    On a related note: C/C++ Programming Tutorials


    "Science is based on reality staying the same, and Nature ignores what humans vote upon." -- Bill Beaty
    "Three litres of sherry up the butt can only be described as astounding." -- Darwin Awards
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19
    Haha, what if i want to make my own scripting language for the fun and experience :) Where do i start? Lol, I am full of questions aren't I. Maybe I am thinking WAY too high WAY too fast. Right? Maybe I should learn c better than I know c++ right now and then learn more advanced c++ stuff? Then maybe learn python which seems like one of the best languages? Maybe just learning everything I know and don't know better would be better for me?
  22. #12
  23. Google Relay Server
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2003
    Location
    Oh christ I don't even know any more.
    Posts
    1,812
    Rep Power
    439
    Originally Posted by fierydog
    Haha, what if i want to make my own scripting language for the fun and experience :) Where do i start?
    Hmm... where do you start... well, it depends on how complex you want to get. Programming language design is a field unto itself. It also depends on your application. This particular application, for example... you'd probably want to start by figuring out exactly what you need your scripting language to do. Then come up with a good way to represent what you want to do that is easy to parse (the "grammar"). For simple script-like languages it's usually easy enough to just implement everything yourself; for more complex languages there's plenty of design tools out there like lex, yacc, etc. Here is a huge amount of information about programming language design, but as I said, for your application, you should be able to get away with keeping things simple. Here is another good read. I'm sorry, I'll give you a better answer when I get home from work. But keep in mind that those links contain information that applies to the design of full-blown programming languages. They're way more complex than what you would need to do. I just posted them because they seem interesting so don't get discouraged by them.

    Maybe I am thinking WAY too high WAY too fast. Right?
    You might be right :) . It's good that you have a list of things you want to learn but it's always best to get the basics down first. It's not like bad things will happen to you and your family if you set your goals too high; but it does increase the chances of you getting frustrated, discouraged and giving up, which is not a good thing. As long as you don't mind failing at your first attempts, which will happen, then think as high as you want as quickly as you want.

    Maybe I should learn c better than I know c++ right now and then learn more advanced c++ stuff?
    A lot of people start with C because it's "easier". I'm not sure if I agree with that or not. Maybe somebody else will give their opinion. If you'd like to learn C though, the resources are all out there. I don't know anything about Python so I can't give you any advice there.

    Sorry if that was not a good answer.

    Comments on this post

    • para45 agrees
    OMG RAVER CHICKS!!
    On a related note: C/C++ Programming Tutorials


    "Science is based on reality staying the same, and Nature ignores what humans vote upon." -- Bill Beaty
    "Three litres of sherry up the butt can only be described as astounding." -- Darwin Awards
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19
    I don't agree with the C is easier also, I thank you so much for trying to help me. I am just brainstorming a million different paths i want to go. I am considering going rpg and getting into game programming and hopefully miss a lot of the stuff i really don't understand much like pointers. (I think pointers are tough for everyone at first at least thats what the forums are telling me) The thing that probably discourages me most is the fact that when I try to learn say open gl, all the tutorials state stuff I don't know the point of. I hear people say you need a paint program and stuff, all the graphics stuff is too hard to get a good tutorial on. All those first tutorials like how to create a window in open gl is a turnoff. So if i want to eventually end up with pretty sweet world of warcraft type rpg graphics and making a regular rpg what path should i go? Maybe direct x? Learn python for game logic? I guess I am hearing all this stuff but can't really understand it. :confused: Really the tutorials that I like is this tutorial because its got its own dev c++ examples. But, it just seems like all the stuff is irrelevent to animations and stuff. Just call me mr. confused. Could you possibly tell me what i need for the "world of warcraft" graphic type rpg? Could you possibly include any GOOD freeware 3d graphic programs. Or, should I just start out with 2d graphics and build up. I'm just mixed up and need clarification. It would be a miracle to be able to create that "Balmora city" in elder scrolls 3 morrowind and actually have a window! where the player walks around (even cant do anything but walk) with collision detection. That would be so awesome. I want to get to the point that I can do that but I don't know the right path to take. So your best advice to get me to that point would be HIGHLY considered and I would do my best to do what you advise. Because after all, you know ALOT.
  26. #14
  27. Google Relay Server
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2003
    Location
    Oh christ I don't even know any more.
    Posts
    1,812
    Rep Power
    439
    Hmm now you're asking some big questions...

    Originally Posted by fierydog
    I am considering going rpg and getting into game programming and hopefully miss a lot of the stuff i really don't understand much like pointers. (I think pointers are tough for everyone at first at least thats what the forums are telling me)
    Pointers are a hard concept for a beginner, or even a programmer experienced in certain other languages, to understand. But then you'll have an epiphany one day and it will all fall into place.

    The thing that probably discourages me most is the fact that when I try to learn say open gl, all the tutorials state stuff I don't know the point of. I hear people say you need a paint program and stuff, all the graphics stuff is too hard to get a good tutorial on. All those first tutorials like how to create a window in open gl is a turnoff.
    OpenGL programming and artwork design are two entirely different fields. That's why "artists" and "developers" are usually separate in the credits. The "graphics stuff" is tough to find a tutorial on on the internet. You'll frequently find tutorials on how to use specific programs (like Photoshop) for specific tasks, but you'd be hard pressed to find a document that you could read and all of a sudden your a good artist (and/or programmer)... that kind of stuff only happens on the other side of the Matrix ;) . If you are into art, wait until college, depending on where you go there's plenty of diverse courses that will give you hands on training and experience in whatever you are interested in. A good friend of mine, in fact, is a graphic design student in NYC, but his master's thesis is a game that he's been working on for quite some time (the only thing he's missing is a developer, heh).

    OpenGL programming in itself is an incredibly broad field. Nowadays, many people even use OpenGL to program their graphics cards to do things entirely unrelated to 3D graphics. There are entire books written solely about optimizing OpenGL code. But, of course, basics first. If you are interested in OpenGL I have two suggestions: First, check out GLUT (Windows version) if you haven't already. It's a nice, platform-independent GL toolkit that provides convenient and portable ways to do things like create and display windows, respond to user input, etc. That way you don't have to worry about all the tedious system-specific stuff and you can jump right in to messing with OpenGL. Secondly, I highly recommend obtaining a copy of the Redbook (5th edition). You should be able to find it available in PDF format as well. If you are looking for slightly more advanced online OpenGL tutorials, and also interesting articles, check out this site; I think you'll be happy with the content there :) .

    So if i want to eventually end up with pretty sweet world of warcraft type rpg graphics and making a regular rpg what path should i go? Maybe direct x? Learn python for game logic?
    That's not a simple application to write, especially with the "pretty sweet" constraint you've placed on it. You're going to be hard pressed to develop an application like that on your own. If you are wondering what path to take, I'd suggest college and/or finding a good job :) . A decision like DirectX vs. OpenGL is almost trivial and would be the least of your worries in a game like that. I don't know if I would recommend learning Python for the purposes of powering your game. But if you want to learn Python, go ahead, and if you find that Python is the right tool for your job, then use it accordingly.

    You should really try to concentrate on one thing at a time. I hate to say it but you aren't going to be able to develop a really sweet RPG right now. You aren't. Period. My advice is: continue down your path of learning C++. Learn the language first before you start to do a whole bunch of other stuff. Or do a whole bunch of other stuff, whatever, but just remember that your near-term goal right now is learning C++. Maybe you will find that C++ is not a language that you like, who knows? But just concentrate on that. Then you can get into other things, like OpenGL or DirectX or whatever, and more advanced topics like game design, software engineering, etc.

    I guess I am hearing all this stuff but can't really understand it. :confused:
    The reason for this is because there is a lot of stuff to hear. You don't just, learn how to program a computer and all of a sudden you can do anything. If you want to be a doctor, you study a specific thing. The term "doctor" covers a very broad field. I work in the medical field and I have yet to meet a single surgeon that can both replace your hip and remove a tumor in your brain. The field is just too huge. Your real goal eventually is to find your niche, to figure out what you like to do. I certainly haven't found mine yet. It takes a while. But you try to get experience in a variety of fields and eventually you will find something that you really click with.

    Um, but, you aren't going to learn anything if you try to learn everything all at once. If you take too big bites you'll probably choke. So pick something and stick with it.

    Really the tutorials that I like is this tutorial because its got its own dev c++ examples. But, it just seems like all the stuff is irrelevent to animations and stuff.
    Well it depends. If you are a software developer and you are given the task of working on the graphics engine for a game, how will you be able to animate objects on the screen if you don't know how to create a window or draw a triangle, or transform the objects accordingly? You need to know the basics first. On the other hand, if you are an artist and you are given the task of creating character models and animations for a game, you probably won't even touch an actual programming language.

    Just call me mr. confused.
    If you ask one of the admins, you may be able to get your username changed :p .

    Could you possibly tell me what i need for the "world of warcraft" graphic type rpg?
    No, I can't. Not to be snippy but, what kind of answer are you expecting for this question? It's kind of a tough one.

    Could you possibly include any GOOD freeware 3d graphic programs. Or, should I just start out with 2d graphics and build up. I'm just mixed up and need clarification.
    I think you are mixing up the fields of programming and graphic design. Photoshop is a good 2D image editor. Lightwave, Maya, 3D Studio MAX, etc, are all professional quality 3D modellers. Not a single one of those has anything to do with software development. They're tools. For example, let's say you write a program whose sole purpose, for some reason, is to display a photograph of an elephant on the screen. How would you do this? Well you'd probably take a picture, convert it to some digital image format, and write a program that can display that image on the screen. But look how many skills and tools this involves: You aren't going to be able to take a decent picture of an elephant unless you have at least some knowledge of photography. You'd probably use a camera to do it. Does a camera write your program for you? No. The camera is a tool that you can use. You might use any one of hundreds of different makes and models of cameras out there. Now you have a picture that you've taken with your camera, you need to convert it to a digital image format. How would you do this? You might use Photoshop, you might use software that came with the camera, you might have the photo developed and use a scanner to scan it in. Who knows? But all of those are merely tools. Not a single one of them helped you take the photograph to begin with or helped you write your program. Then you write your program. It displays an image on the screen. Despite the fact that the purpose of your program was to display a photograph of an elephant on the screen, the code itself had nothing to do with taking pictures of elephants or converting them to digital images. You (or somebody else, like the photographer you hired) used various tools for that.

    That's why you aren't going to find many 2D graphics + 3D graphics + OpenGL + programming tutorials out there. Would you expect to find a tutorial on programming that also covered photography? No that would be ludicrous.

    It would be a miracle to be able to create that "Balmora city" in elder scrolls 3 morrowind and actually have a window! where the player walks around (even cant do anything but walk) with collision detection. That would be so awesome. I want to get to the point that I can do that but I don't know the right path to take. So your best advice to get me to that point would be HIGHLY considered and I would do my best to do what you advise.
    My best advice is to take it one step at a time. Pick something basic. Learn it and get familiar with it. Then concentrate on more complex tasks. If you find something that you like, stick with it. If you find something you don't like, try something else. Also, you can't just pick up an anatomy book and expect to be a brain surgeon by the time you are finished reading it. You have to learn a lot of stuff in between... I mean, how would you ever be able to finish a game like WoW if most of your time is spent figuring out how, say, arrays work?

    Ok I need to stop procrastinating now.

    PS: Sorry if you are already in college; I'm just guessing :)

    Comments on this post

    • para45 agrees : Doh, can't give mod points :\ great post though
    Last edited by peenie; June 29th, 2006 at 06:55 PM.
    OMG RAVER CHICKS!!
    On a related note: C/C++ Programming Tutorials


    "Science is based on reality staying the same, and Nature ignores what humans vote upon." -- Bill Beaty
    "Three litres of sherry up the butt can only be described as astounding." -- Darwin Awards
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    245
    Rep Power
    19
    lol, I know I'm never going to make anything of the caliber of world of warcraft or morrowind, that would be me working a lifetime. I guess with my artistic skills all i could do is 2d playerworld type stuff (haha) I guess thats better where I am at right now. I am a while away from college. (psst: don't think that because then you might not answer my questions :( ) But, I definately plan taking some course of computer programming for college. Which I guess isn't that far away (bout 2 more summers) Since it's summer though I have time to work on learning more because no sports or stuff (haha I have to be quarterback on my football team next year) Wow, so I guess I just need to learn what I like and just stick with what I learn. I might just learn java for the heck of it, I mean I have this big dusty java book sitting in my room for about a year. Heck, if I learn a bunch of languages: python c java and stuff I could probably get a pretty nice summer job next year :) So really my goal should be learn to learn what i like. Thanks alot for pointing me in the un- :confused: way.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo