Game Development Community

T2D and C

by Melv May · in Torque Game Builder · 12/06/2005 (12:11 am) · 46 replies

Who, what, where, when and how?

So I admit it, I'm a C++ developer that's writing an engine that's typically driven via scripts. All day long I talk to people; script this and script that but what about C++? Scripts work extremely well for lots of games and used correctly, can reduce the development cycle but there's always the need to write your own C++ routines, objects, simple frameworks etc.

To this end, I'm interested in knowing what specific aspects of getting up and running writing C++ code in T2D you'd like to understand. By this I'm talking about myself writing code-examples, tutorials and/or a simple example of using the T2D framework as a whole. I'd like to get a good feel for a natural progression of examples/tutorials that would help here.

There are many frameworks out there that offer a simple and clean layout but don't provide all the wonderful goodies that T2D provides because, in the end, it's an engine, not a basic framework. One isn't necessarily better than the other from different peoples perspectives and I'm not here to start a discussion over which is "best" because that's subjective and to be honest, dull.

In the end, what I'd genuinely like to do is make the "C++ Engine" forum much more active and the only way that'll happen is if people are comfortable working at a lower-level. It's essential that people can do this, especially if they only want to add some simple construct such as a bit of AI code, path-finding, fancy render-fx etc.

So let me start; what I'd like to see explained is the following:-

- Simple, clean example of the basic T2D engine framework (this is essentially the TGE) to build on.
- From "main()" to T2D.
- Using events in T2D.
- The basics of Sound / User-Input.
- Creating GUI objects.
- Creation of console scriptable objects (not necessarily T2D scene-objects).
- Extending the core T2D object (including objects that render).


What I'm definately not interested in here is requests for specific objects so "I'd like C++ path-finding" is going to be ignored. Rather I'd like to talk about the fundamentals of coding T2D at the C++ level. The engine is a huge mass of code but in the end, you can discount 95% of what you see and what's left is what I'd like to explain as best I can.

On a side-note; this isn't an official GG request (I'm not GG) but a personal request as I'd like to attract people who are happy to work with T2D at the C++ level and feel that there's enough information to understand the core-framework of T2D to be able to inject their own code into it for whatever reason. My time to do this is limited but I do get time to work on side-projects and exposing the C++ side of things is something I'd really like to do. This could also serve as a great way for people who own the TGE to learn some stuff as well.

Help in organising this list would be appreciated.

- Melv.
Page «Previous 1 2 3 Last »
#1
12/06/2005 (1:48 am)
For me, i'd like to see how object creation (including the objects respective datablock) can be performed in C.

A great example would be to implementing everything in Torque2D\SDK\example\spacescroller\client\spaceScrollerScreen.gui in C++

i'm not saying rewrite the entie file, but an example that does equivlant functionality (create an object using datablocks with nested objects/datablocks inside of it)

does that make sence?

-Jason
#2
12/06/2005 (1:50 am)
Show us step-by step how to do shaders, motion blur and HDR in T2D ! (joke)
I'd rather see you fixing bugs, but if you need a break that's understandable.

Maybe give hints as to where we might change an object or inject code. Places where doing so might add flexibility or efficiency.

Personally I want to script everything, then move my bottlenecks (if any) to C/C++. However I do understand how a new script object or extending the core might be necessary. So far all I have to go on are resources and some forum posts.. any more info will be great.

Edit: Oh yes, datablocks mystify me too.
#3
12/06/2005 (2:02 am)
Off the top of my head:

1. What is the role of DemoGame? Why would I change that? Is this the place I would create my C++ game if I didn't want to use script at all?
2. How do I create a REALLY simple GUI without a .gui file? For example, if I wanted a GuiCanvas with two t2dSceneWindows... how would I do that?
3. If I want a C++ only game, would I ever call a ConsoleFunction? Or, just the underlying function that the ConsoleFunction calls?
4. How would I sync events and receive schedule callbacks?
5. Creating a really simple example of a single t2dSceneWindow with one ImageMapDatablock and a t2dStaticSprite all registered and working.
6. What do I need to know about memory management if I don't use script? Do I still call .safeDelete? How do I ensure that everything is cleaned up properly?
7. Should I still use SimGroups/SimSets? Do I have to? Can I just create an std::vector of objects?

For context, I think understanding memory management in the Torque engine is probably the single scariest part. I'd love to avoid script because VC is SUCH a better debugger and setting up Torsion or one of the other IDEs seems so complicated and fragile. Also, the entire build time for a clean build of T2D is < 1 minute on a mediorce laptop, so "faster compiles" for script is not really an issue. Granted, I'm used to clean builds at my company for projects to take 12 hours for ship and 12 hours for debug... so I'm a little jaded.
#4
12/06/2005 (2:34 am)
Thanks!

Keep 'em coming, even if they're the same.

- Melv.
#5
12/06/2005 (2:46 am)
Well, i know C++ a bit (doing it since 1 1/2 years for work) and my big question was just this:

Where the heck do i even start?
I never looked at a project this big in C++, and i would like to see some clues like:
"put your code here and start doing the game-logic in c++". ;)
and this with a little clue like, hot to initialize everything so you get a blank screen where you could put T2D objects into.

And also interesting would be an inside look in the implementation of TorqueScript, so eventually you could extend the TorqueScript language itself.

Just some ideas ;)
#6
12/06/2005 (4:19 am)
I'm doing 90% of the coding in C++ because script always seems to get messy very soon for me. These are the things I needed:

1. Doing you're own derivations of t2dSceneObjects and building appropriate datablocks for it.
2. Creating and destroying t2dSceneObjects from C++.
3. A little overview of handy utility functions (t2dSceneObject::getStringElement and the like)
4. Some explanation of what DECLARE_CONOBJECT, IMPLEMENT_CONOBJECT, ... do.
5. What to do exactly, when creating new SimObjects
6. Calling script functions from C++
7. Adding/modifying SimObjects dynamic fields in C++
8. Stringtable workings
9. Explanation of Sim::findObject()
10. Setting up ConsoleMethods and ConsoleFunctions right. Especially things like returning strings

Would have helped me, if I had had some docu to look that up. I don't mind too much but not everybody likes to find out how things work by looking at the code. And there's always the chance you miss something important or handy.

EDIT:

11. A tutorial on t2dActiveTiles!!
12. Some explanation of the inner workings of T2D. Something like: the t2dSceneGraph does all the updating of the sceneobjects. first the collision then physics... it stores t2dSceneObjects in a linear list, mounted objects are attached to their mounts... and so on..
there are things, that are quite time consuming to figure out.

-Michael
#7
12/06/2005 (4:20 am)
Awesome guys; thanks!

-Melv.
#8
12/06/2005 (11:42 am)
Hi there! a little late but I would be very interested to
make a game full C++ too, scripts only needed to load
prefs and additional simple behavior, but all the main
loop and logic in the C++ part.
Right know it would be handy to have a "Hello block" demo
for start
"Hello block" is a simple program that:
- Loads a sprite block in screen
- Creates 2 botons to rotate to left or right the sprite
- Uses the key arrows to move the camera.
This has been always my intro to any graphic framework, just
to test if the library is correctly installed, something like a "hello world".
Even so simple i don't have any idea how to achieve this in T2D without using scripts...
*ashamed*
#9
12/06/2005 (11:53 am)
An "hello world" app or series is a good idea Adam.

Thanks.

- Mevl.
#10
12/06/2005 (3:00 pm)
I would love to see the simple Hello World. Or in this case hello block and/or fx.

I would like to know what is minimum in the C world to get started. Start with an torque context/world (Open GL/DirectX). I don't know what you guys call this. I just started with Torque so the vocubular is a bit lacking.

1. Create an object in the world. Animate the object or something.
2. Create a scene in the world. Add the object. Add some effect. Cloud, fog, etc.

This would give a lot of basics.

Thanks,
Matt
#11
12/06/2005 (3:55 pm)
I think yeah, a simple hello world would be very excelent. (maybe emulating the basicTutorial torquescript, so we have something to compare side-by-side)

I would also like to see a C++ "hello world" created without the use of *any* torquescript. maybe you cant delete the base example\main.cs, but one issue i have with the torquescript stuff is there is a lot of inter-related stuff floating around in the example\common and example\t2d folders, and i dont really know what's going on in there.

I would like to be able to delete all that stuff and "start from scratch"... granted i can do this in torquescript, but it would be nice to have a C++ that did that.
#12
12/06/2005 (3:57 pm)
@Jason Cahill: I agree that the memory management is very confusing. I know for some functions (such as addField) you need to first push the object name onto the stack... the only reason i know that is because i asked the question in the fourms and Melv was kind enough to inform me.

I can see that as being a big problem with anyone wanting to implement in C++.
#13
12/06/2005 (5:18 pm)
For my part, I would appreciate a little introduction in how you would see extensions to the physics part fit.

As an example, I'm to re-implement my version of a moveTo which includes soft start / stop, and curves as well as rotation, a hint as to where you see such extensions to the code fit would be great.

Keep up the good work and even better attitude :-)
#14
12/08/2005 (11:34 pm)
I would second almost everying Michael said, stuff I see as fundamental towards personalizing the engine to more diverse projects. The rest of the things he listed are problems I haven't run into yet, but expect I will.
#15
12/09/2005 (12:03 am)
Thanks everyone.

- Melv.
#16
12/13/2005 (3:00 pm)
Some documentation on the serialization system would be nice too. I have not used it by now but sooner or later I'll need to save things to disk and I would be smart to do this with existing means.
#17
12/13/2005 (7:58 pm)
I'll add my vote to some detailed "from the ground up" tuts on instatiating objects in C++ and how that affects memory management. I'm not planning to make a whole game in C++, but I would like to do some stuff like say, data structures beyond the TGE vector class (heaps, stacks, queues, etc) that can hold script objects. Ive been scared that any objects added to any containers I make won't get into the Torque memory manager. I barely have an understanding of what that even means :)

All the other stuff in your original list is great, esp user input and sound items. A whirlwind tour of the codebase is good also. What are all the parts, and what do they do?

Very exciting stuff!
#18
12/13/2005 (11:50 pm)
Thanks guys.

- Melv.
#19
12/17/2005 (4:01 pm)
I'd like to see an example of how to create a lockstep networking system for T2D. Seems like it shouldn't be too far from the turnbased stuff... with turns every .002 seconds or something. Seems like if the data packets could be made efficient enough, you could network simple t2d games pretty easily without ghosting or other tge fanciness.
#20
12/18/2005 (9:15 am)
Something simple would do me, something like has been suggested already. i.e. the ship shooter done without script, so we can see what plugs in where, etc.
Page «Previous 1 2 3 Last »