Game Development Community

How to starts working in C++? Not using scripts in Torque.

by Corin · in Torque Game Engine · 01/11/2005 (1:58 pm) · 6 replies


#1
01/11/2005 (1:58 pm)
Try here

Thats probably as good as you'll get
#2
01/11/2005 (4:00 pm)
For all practical purposes you HAVE to use the scripting enviornment to some extent as it is tightly coupled to all the objects, simulation, graphics and network code, there is really no getting around using it. You HAVE to learn it.

I did give the possibilites, you can but it would be a tremendous amount of work to bypass the scripting sytem which as I stated already is TIGHTLY coupled within the engine, once you look at the code required to bypass the coupling of the scripting system you will more than likely abandon the idea like everyone else that asks this question in the past has.
#3
01/12/2005 (10:47 am)
Juan,

It's obviously possible to working with Torque in C++, it all depends on what you mean by 'work'. If you want to do fancy rendering objects then cool but if you want to be generating the actual fancy rendering objects from with C++ rather than script to define your missions then I wouldn't. I personally don't know why you want to exclude using scripts unless you actually want the complexity, difficulty and inflexibility that goes with C++ only coding of games. Demos yeah, 'games', no.

I would rather do ...

%obj1 = new myFancyObject();
%obj2 = new myFancyObject();
%obj1.mount(%obj2);

than ...

myFancyObject* pMyObj1 = new myFancyObject();
myFancyObject* pMyObj2 = new myFancyObject();
pMyObj1 ->registerObject();
pMyObj2 ->registerObject();
pMyObj1->mount(pObj2);
...
delete pMyObj2;
delete pMyObj1;

.. so on and so forth. Although this is slightly slanted towards convincing you of using the scripts, I will add that the about C++ objects don't have constructors and don't need complex initialisation which you'll probably end up with when linking your objects together.

A way to use the scripts but not use the scripts would be to issue script commands from within the engine. Have a look at the Con:: namespace to see what I mean with execute/eval etc. This is a little crazy but it does work.

If the complexity of the demo scripts is confusing and that's your motivation to do it all in C++ then be aware that you don't actually require any of the example scripts. I believe there's an example of the minimum calls into the engine to get it up and running. Something along the lines of initialising the canvas and setting the mod-paths and you're ready. Think hard before you leap. :)

EDIT: Found it ... Bare App


Hope this helps,

- Melv.
#4
01/12/2005 (11:40 am)
I hope I didn't scare you that much. ;) I think the real question is to ask why the scripts are there. Not because they help newbies or anything but they indeed are a powerful allie in the ways of the force.

Work with the engine, not against it and you'll be suprised how quicky you can get stuff up and running.

- Melv.
#5
01/12/2005 (12:09 pm)
As Melv said, it's really a matter of understanding not just the terminology, but the purpose.

When people say "script", what they really mean is the Torque Scripting Language. This is most certainly part of "coding games in Torque", and provided as a very important part of Torque for a lot of reasons:

--scripting is very easy to implement various things. Even if your eventual plan is to have no Torque Script in your game at all, you should still use Torque Script in many cases to test out your game ideas. In the long run, it's simply quicker and more efficient.

--scripts can be modified very quickly, and brought into your game very quickly as well. Instead of making changes to C++ files, compiling, linking, and then running the game executable over and over again, you restart your executable and your changes are immediately there. Although I personally don't do it myself, I also know that many people don't even bother re-starting their game, they simply open the console and load the new script again (with the exec command).

--in some ways it simply makes more sense to use scripts for certain things. There is no reason you should have to recompile and re-link your game just because you want to move a gui 10 pixels to the left, so script lets you do things like that very easily.

In summary, realize that "script" doesn't mean "newbie programming". The best Torque developers are the ones that know when to use Torque Script, when to use C++ engine changes, and when to migrate from Torque Script to C++ engine changes for the right reasons.
#6
01/21/2005 (11:11 am)
I'm still learning a lot about the different times to manipulate C++ engine code vs. script code... but so far it seems to me if you want to add something manipulated heavily in script you want to do most of the coding in script... while if you want to handle something internally in the engine, not really allowing dynamic manipulation through script (or much) then put it in the C++ engine side...

for example... I've been working on a Journal system, its becomming more like a database though, I want it to be very flexible, easily dynamic and passed between different possibilities... using as inventory, journal, dialog storing, mission storing, image path storing... etc etc.... so I chose to do it almost exclusively in script... It gives me the flexibility as well as the type less nature of the script language that makes it easy to be used dynamically...

If i did it in C++ my head would be aching much more than it is now and trust me it is now.

Don't know if I helped but good luck with whatever your working on.