delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

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.


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.

TOP

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.in..._MS_Visual.html

TOP


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:
  1. PRINT here is a line
  2. PRINT here is another line
Copy Code
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.

TOP

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.

TOP

abstract:

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.


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 )? 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.

TOP

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:
  1. void createtext()
  2. {
  3.      ofstream fout;
  4.      fout.open("c:\\YourProgram.cpp");
  5.      string userinput;
  6.      cout << "What do you want to say to the user?" << endl;
  7.      cin >> userinput;
  8.      fout << "cout << " << userinput << "endl;" << endl;
  9.      fout.close();
  10. }     
Copy Code
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?

TOP

Look into cin.getline. Heck, read up on iostreams in general. Certainly can't hurt!

TOP

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.

TOP


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>
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.

TOP

abstract:

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.


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?

TOP

Back Forum