Game Development Community

Unity user has lots questions ... contemplating TGB purchase ...

by David Janik-Jones · in Torque Game Builder · 02/02/2007 (4:00 am) · 11 replies

Hey everyone!

While I know some of the following questions have been asked in various threads before, I hoped that some kind soul might happen along and be kind enough to answer all of our specific questions about TGB in one spot. Our situation is that we're using Unity (well) to do our 3D game work, but are considering TGB for our 2D game projects.

I tinkered around a bit last night (with one of my kids) and got a fun little "space ship with flaming exhaust and bouncing asteroids" thing going without much work at all (20-30 minutes?) and I generally like the interface, power, scripting etc of TGB. However our experimentation has lead me to a few questions and also some neat ideas for games; sort of a bad/good thing, right? :-) With that in mind, here are some questions I had about TGB in no specific order ... thanks to anyone who hops in to answer ...

Generally, how easy is it to do the following in TGB:

1. Lock an item (card, playing piece, etc) to a grid? The grid might be squares, rectangles, odd shapes, hexes, etc. This might involing moving it by WASD or perhaps as below in item 2.
2. Grab and drag an object around the play area? And then snap it to the above grid when you let go?
3. Do screen fades from one "level" to another?
4. Incorporate True Type fonts into your game for display, etc?
5. Simple timers for count downs, moves done, etc?
6. Classic "drag-pull-shoot" indicators you might find in a billiards game? Example: You click on a playing piece and drag down to the lower right. A line (pixel, graphic etc) appears 3x the length you've pulled down-right out of the piece towards the uppper left to show force and direction. A pixel line will do for now.
7. Replace an object's graphic when it collides with a second object and is killed? Ship hits asteroid and explodes.
8. Move an object in the direction it's pointing?
9. Load levels? I assume it's very simple. Combine with 3? If object touches object X (invisible) fade over a few seconds, show next level load screen then few seconds and fade to new level.
10. Apply (standard or variable) gravity to an object so that it falls "down"? Friction during movement to slow something down? Mass?
11. Move a window around a larger play area/level?
12. Follow an object as it moves? Relates to 11.
13. Post a score/time/etc and name to a website's MySQL database after a game is complete?
13. A toughie now ... has anyone come up with simple way of incorporating some form of SIMPLE registration and/or copy protection for their game? And I do mean simple ... something that can be tacked on without more than 30 minutes work or so? And is willing to, or already has, share(d) with the TGB community?

Finally, I had a few questions about the TDN:

1. How good is the community around the TGB (as opposed to the TGE)? Size, willing to help newbies, put out simple scripting snippets for free, etc?
2. How extensive are the additional samples and examples and tutorials for TGB inside TDN? What sorts of things are covered?

I know it's alot but what to make certain before another purchase. Many, many thanks.

DaveyJJ (the WidgetMonkey guy)

#1
02/02/2007 (6:22 am)
Additionally ...

1. How easy is it to move an object using the WASD or arrow keys relative to the direction it's pointing?

Also, I found my own answer about Gravity. None per se, but the proper use of Constant Force could simulate it enough for my needs.
#2
02/02/2007 (7:41 am)
Welcome! Unity's a great engine (as you know)! Nice to see the dev's out and about!

1. Lock an item (card, playing piece, etc) to a grid? The grid might be squares, rectangles, odd shapes, hexes, etc. This might involing moving it by WASD or perhaps as below in item 2.

I haven't used grids in TGB other than the one with the editor, so I'm not sure. Neo Bindell and Kevin Ryan would probably be two of the most knowledgable people in this (aside from GG employees in charge of TGB) because of their work with Puzzle Poker and the isometric pack.

2. Grab and drag an object around the play area? And then snap it to the above grid when you let go?

Again, since I haven't used grids, I'm not sure. But you can mount objects to other objects (do not know if a grid is an object) to "snap" to a deck of cards or some such (ala Solitaire).

3. Do screen fades from one "level" to another?

Yup.

4. Incorporate True Type fonts into your game for display, etc?

I haven't played with the text tools that are included in the newest release. I'm not sure about embedded TTF's.

5. Simple timers for count downs, moves done, etc?

Yup.

6. Classic "drag-pull-shoot" indicators you might find in a billiards game? Example: You click on a playing piece and drag down to the lower right. A line (pixel, graphic etc) appears 3x the length you've pulled down-right out of the piece towards the uppper left to show force and direction. A pixel line will do for now.

You would have to code it, but it is definitely possible.

7. Replace an object's graphic when it collides with a second object and is killed? Ship hits asteroid and explodes.

Definitely.

8. Move an object in the direction it's pointing?

I'm not quite sure what you mean here. You can move objects wherever you want, and animate them to point however you want.

9. Load levels? I assume it's very simple. Combine with 3? If object touches object X (invisible) fade over a few seconds, show next level load screen then few seconds and fade to new level.

Yup.

10. Apply (standard or variable) gravity to an object so that it falls "down"? Friction during movement to slow something down? Mass?

Yup. There are a number of physics functions available, but you will need to work with them a bit to get them to work deterministically.

11. Move a window around a larger play area/level?

Do you mean having an extremely large game area and be able to scroll around it? If so, then yes.

12. Follow an object as it moves? Relates to 11.

Mount the camera to the object.

13. Post a score/time/etc and name to a website's MySQL database after a game is complete?

You can send net objects out and about, but direct MySQL access is a resource that would need to be implemented. I believe a number of people have gotten around it by just sending HTTPObjects, but am not sure. I know that a number of TGB games have this feature, but I'm not sure if it required the Pro version with source to perform or not (adding a database resource).

13. A toughie now ... has anyone come up with simple way of incorporating some form of SIMPLE registration and/or copy protection for their game? And I do mean simple ... something that can be tacked on without more than 30 minutes work or so? And is willing to, or already has, share(d) with the TGB community?

There are a number of solutions for this, but I believe all of them require a Pro license to merge the registration SDK (from a third party vendor) into TGB. There have been several discussions about time limited demo procedures and such on the forums because it is a big third-party market.

On a similar note, there is an asset encryption resource which requires a Pro license but uses encrypted zip's to keep your art and scripts and such away from the vast majority of prying eyes.

Finally, I had a few questions about the TDN:

1. How good is the community around the TGB (as opposed to the TGE)? Size, willing to help newbies, put out simple scripting snippets for free, etc?

The community is excellent around TGB (and TGE). There are a lot of people on the private forums that are always willing to help. The developers and GG staff are also on quite often to answer the more niggling questions. There are a number of code-snippets, mini-tutorials, and larger tutorials available as well as several forum topics concerning solutions to common issues with code snippets.

2. How extensive are the additional samples and examples and tutorials for TGB inside TDN? What sorts of things are covered?

Aside from the tutorials that ship, I see platformer, RTS, and tetris tutorials, mini-tutorials for GUI development, car, boat, tank, and ball physics, splash screens, score keeping, a fading tutorial, object selection, pathing code, joystick setup, pause screen, etc...

1. How easy is it to move an object using the WASD or arrow keys relative to the direction it's pointing?

You would just need to make a check to see if it is point in the right direction for movement. If not, then invoke the "turning" animation for the sprite or do it programatically depending on the gametype. For a rudimentary example (assuming you set it up like this, of course), if it is a top-down RPG and the character is facing "down" and the player pushes "up", check what frame the sprite is displaying ("down") and run the animation frames for "turning up" and then move "up".

I don't know how helpful it was, but I tried. If I think of anything else, I'll post it.
#3
02/02/2007 (7:43 am)
Yeah. It's not "gravity" per se, but a force motion. That way you determine your physics constraints rather than being bound to a top-down force approach (or an outer-to-inner approach for something like plant physics).
#4
02/02/2007 (9:44 am)
David, many thanks for taking the time to reply. The Unity engine and community are great indeed, but Unity, for some of what we/I have planned, is a bit of overkill.

1. Lock an item ... and 2. Grab and drag an object ...

I'm pretty certain that this won't be needed and that there are effective (and relatively simple) solutions out there already coded so it's not really an issue. Grabbing and dragging an object (and things like following a mouse position) are, I'm pretty sure, simple.

3. Do screen fades from one "level" to another?
5. Simple timers for count downs, moves done, etc?

Thought so. Can you maybe post a simple code example of one (a moves done counter, say) so I can review the simplicity of the code (so that my artist brain can "get it")?

4. Incorporate True Type fonts into your game for display, etc?

The Mac version is still at 1.1.1 (I think) so I'm not sure the latest 1.1.3 Text Object is yet in it. But from the small screen shot on the GG site, it looks OK to me and has what I need, anyway.

6. Classic "drag-pull-shoot" indicators you might find in a billiards game? ... You would have to code it, but it is definitely possible.

I assumed that. But again, if the Unity community is any indication of the support of your fellows, I'm sure someone has whipped something simple up and might be willing to help out.

8. Move an object in the direction it's pointing? ... I'm not quite sure what you mean here.

Um, I figured out how to rotate objects when I hit the left/right arrows, no problem. So now my object is, say, tipped 30 degrees to the right (so it's nose is pointing towards 030 -- I'm an ex-ATC guy). When you hit the up arrow, I now want the object to travel towards where it's pointing ... a course of 030 degrees. I don't want the "up" arrow to represent 000/360/top of the screen, I would like it to mean "straight ahead". Sorry I didn't explain it well enough.

9. Load levels? ... Yup.

Do simple examples exist in the TDN section?

10. Apply friction and mass ...

Good. Again, I'm looking for only simple interpretations of things like friction and mass here, not exact physics here. Is this done through code or in one of the settings in the right panel?

11. Move a window around a larger play area/level? ... Do you mean having an extremely large game area and be able to scroll around it? If so, then yes.

Yes. Is it simple, i.e., locking/mounting the camera on the object that's moving through the world (and obviously making certain that the objects world boundaries cover the entire (at times hidden) play area/level?


13. Post a score/time/etc and name to a website's MySQL database after a game is complete?

I'm surrounded by programmers here so I asked one of them. I can use any number of simple C#, C++ etc snippets of their code to do this. And I will share when I have a simple way for everyone.

13. A toughie now ... has anyone come up with simple way of incorporating some form of SIMPLE registration and/or copy protection for their game?

I may simply do something as simple as individualizing each game for a person. It's not like anyone is going to play them at the scale that they download the widget games Ron and I make via Widgetmonkeys.com in Unity (350,000+ downloads in 16 months).

1. How good is the community ... The community is excellent around TGB ...

Great, thanks. Can't wait to jump in.

2. How extensive are the additional samples ... I see platformer, RTS, and tetris tutorials ... etc...

Again, excellent.

... I don't know how helpful it was, but I tried.

Outstanding help, many thanks. It's a good sign when a newbie posts what seem like such trivial questions to many but gets the depth of response I got from you. Many thanks. I know I'll have more questions as the days go by playing with the demo.

David
#5
02/02/2007 (10:51 am)
1) Lock an item (card, playing piece, etc) to a grid?
It's not built in by default, but it's trivial in script. Basically, you build your grid mathematically (sounds complicated--I just mean something like "every vertical grid is 4 world units, every horizontal grid is 7 world units), and then on any object movement, have a "snapToGrid" function that sees how close you are, and changes the position to the closest.

The other solution would be to to literally build your grid out of visible or invisible objects, and then mount your "player" object successively to objects that represent the grid as moves are performed. This technique would allow for grid arrangements that aren't easily represented via mathematics. I've seen this used very successfully in prototypes for games like solitare, where the "stacks" are simply invisible objects that the first card in that stack is mounted to, as appropriate.

2. Grab and drag an object around the play area?
You have complete flexibility in how you want to implement this, but one of the standard techniques (examples exist in at least 2 online resources) is to update an invisible "mouseObject" based on the cursor's position, and then mount your player piece to this object. The online Checkers tutorial is an excellent example of this.

3. Do screen fades from one "level" to another?
This is not built in by default, but it's rather trivial (maybe 10-15 lines of script tops) to iterate over all objects in the scene, decrease the blend factors of those objects so that they are more transparent, and increase the blend factors of a transition graphic along the way.

Literally fading in a new level while fading out the old one would be more difficult, since in stock TGB only has one level loaded at a time, and unloads the previous level before loading in the second, but even so you could have two scenegraphs (one with each level), and cross-fade those--would just take some work.

4. Incorporate True Type fonts into your game for display, etc?
TGB (and all Torque engines) support custom fonts, including caching them for delivery to your customers.

5. Simple timers for count downs, moves done, etc?
There are literally dozens of different techniques for different effects. The simplest would be to have a gobal variable that is your counter, a t2dTextObject that is your display, and any time the counter changes, set the text on the t2dTextObject to be the value of the countdown variable.

Implementing a countdown timer is only barely more complex, since it involves scheduling "timer updates", but that's roughly 10 lines of script.

6. Classic "drag-pull-shoot" indicators you might find in a billiards game?
This also can be as easy or as complex as you like. It can be done mostly "visually" by having separate td2Static/AnimatedSprites to represent each "block" of power up/down and using mouse events to determine which is the currently hovered over, or as complex as writing a custom rendering method for a custom object to do exactly what you want. The second would require a Pro license, and rather extensive c++ knowledge. You can download the "Rack 'em Up Road Trip" demo from MSN to see a source code custom implementation.

7. Replace an object's graphic when it collides with a second object and is killed? Ship hits asteroid and explodes.
Very very trivial. TGB uses a concept called callbacks (I'm sure that Unity does the same, although the name may be different) to allow scripters to handle various things that happen in the engine. As a scripter you can do just about anything you want upon receiving these callbacks, and there are literally hundreds that are available to you.

8. Move an object in the direction it's pointing?
I can't remember the exact name of the dynamic field, but all objects have a property similar to "forwardOnly" that does exactly this. I'm pretty certain the TankPhysics mini-tutorial covers this in depth.

9. Load levels? I assume it's very simple. Combine with 3?
As you mentioned, standard load/unload is trivial (a single built in method). More complex interactions require some programming experience/experimentation, but can be accomplished (see 3 above).

10. Apply (standard or variable) gravity to an object so that it falls "down"?
All objects can have all sorts of forces applied to them, but I wanted to point out here a moment that in many many game styles, you don't actually want "real forces". Think tetris for example--blocks don't bounce when they hit a block beneath them, they stick. They don't move in an analog fashion, they "warp" from one position to the next. Good game designs focus strongly on the actual way objects should move, and then the implementation decisions regarding 'do I use built in physics, or do I implement a different system" are important ones.

11. Move a window around a larger play area/level?
As mentioned above, simply mounting the camera to the player object (who would move about a scene), and having a game world that is larger than your visible screen accomplishes this nicely. TGB's camera control is quite flexible, and I honestly cannot think of a 2D camera control mechanism that can't be implemented at least somewhat easily, from what you describe, to a complex "lazy camera following player at a distance, with auto-zoom hotzones on the map, scene focus transfers based on distance from edge of screen, and split screen viewing areas controlled by key/mouse input".

12. Follow an object as it moves? Relates to 11.
see above

13. Post a score/time/etc and name to a website's MySQL database after a game is complete?
TGB has built in TCP and HTTP objects that can be handled in script, and can connect to any external application (databases, web pages, whatever) that utilize either TCP or HTTP as their protocol. With a source code license, your programmers can drop in any other protocols they wish.

Puzzle Poker for one does this exactly.

13. A toughie now ... has anyone come up with simple way of incorporating some form of SIMPLE registration and/or copy protection for their game?
GarageGames as a publisher can provide access to our Ignition registration system as part of the publishing agreement. It's slightly more complex than 30 minutes, but it works well. As mentioned, there is a zip encryption resource available to Pro licensees as well.

Of course, with a Pro license, you have the source code, and can implement anything at all you want!
#6
02/02/2007 (11:31 am)
Stephen,

Thanks for all your help. The whole "fade to new level" is something I'm more interested in being able to implement, rather than actually doing it. Simply going from level 1 to level "2" (a cut scene, static image) into a new game level (level "3") level without fading will more than suffice.

When will the Mac version be up to 1.1.3 and have the t2dTextObject in it?

Again, thanks for your time and effort. I'm fairly certain I can handle much of what I need by exploring (I wrote three of the Unity tutorials) and look forward to buying in a few weeks.

David

PS. Point 8 I figured out on my own ... I was looking for "setForwardSpeed" and making sure the Move Forward Only checkbox was checked.

PPS. How do you name the game window?
#7
02/05/2007 (12:52 pm)
Quote:How do you name the game window?
setCanvasTitle() does the job, e.g.
setCanvasTitle("Asteroids")
#8
02/05/2007 (2:15 pm)
Many thanks, Arthur.

With regards to my other remark about moving from level to a level. I assume you could do something simple based on a timer; e.g. ...

When the player moves his piece through a "portal" area load a static screen, wait 3 seconds, load player into level 2?

Thanks.
#9
02/05/2007 (4:11 pm)
David Jones asked about fading from one level to another. This is certainly a more esthetically pleasing way to make the transition than via the black screen that is displayed while a game loads. The effect would look something like:

1. The player reaches the goal. Play freezes. Fade to...

2. A cut scene, filling the window, shows an entre acte while, behind the scenes, a new level is loading. Fade to...

3. The player is at the start of the new level, ready to engage in game play.

I believe this could be done with TGB in the following way:

Step 1. When the goal is reached, the game loads a transitional Gui at the top of the Canvas. It is transparent and fades in. In this Gui, the entre acte plays out. We are providing the user with entertainment during the time the game is loading the next level.

Step 2. Remove the original Gui (although leaving the transitional Gui in place). Install the Gui for the next level, and begin loading. The entre acte continues to play out.

Step 3. The new level has completed loading. The game removes the transitional Gui, and the player can now play out the game's next level.

The key to realizing this scheme is how the GuiCanvas class works.

When you start a game, you do two things: first in main.cs, Canvas.setContent( Level1Gui ). Here Canvas is the GuiCanvas object (there is only one in any instance of TGB and it is customarily called "Canvas": it represents the application's window itself) and Level1Gui is the GuiControl that comprises the "contents" of the window. Customarily, the name of this control is "mainScreenGui", but in a game with multiple levels, you may have more than one at your disposal. This GuiControl contains all of the user interface elements along with an instance of t2dSceneWindow, customarily called "SceneWindow2D". This scene window is where all of your scene objects live.

The second step, in game.cs, is SceneWindow2D.loadLevel( LevelFile1 ), where "SceneWindow2D" is the t2dSceneWindow refered to above, and "LevelFile1" is the file you created in LevelBuilder. It has a file extension of .t2d and lives in your data/levels directory. Once the loadLevel() function finishes, you are ready to play the level.

Executing GuiCanvas.setContent() and t2dSceneWindow.loadLevel() is the essence of loading a game level. In the process outlined above, we do this action behind the transitional Gui.

The transitional Gui is, in my conception of this scheme, put in place via a call to Canvas.pushDialog(), so it is effectively a dialog box. The key to the success of this scheme is the ability to do a call to Canvas.setContent() without disturbing the dialog. I would not know if this is possible, though, without doing some experimentation.

David said that his purchase of TGB was weeks off, so I'm glad to see some breathing room to resolve this query.

Hope you were informed and entertained.
#10
02/05/2007 (5:03 pm)
Evan,

Yes, something like that would be my intention in the long run. And very well put down as well.

But I also mis-worded the question I had about timing.

Rather than a fade-in it is, I assume, simple to finish one level, pop the player to another "level" that is simply a static image, wait a set number of seconds, then pop him into a new level, correct?

I know how to do this in Unity by simply loading levels using a loadlevel command. The same technique (and set few seconds to wait) can be done easily, correct?

And thanks Arthur! That worked, once I added the semicolon at the end, ala ...

setCanvasTitle("Cal's Space Game")[B];[/B]
#11
02/06/2007 (5:59 am)
Many thanks, Arthur.

With regards to my other remark about moving from level to a level. I assume you could do something simple based on a timer; e.g. ...

When the player moves his piece through a "portal" area load a static screen, wait 3 seconds, load player into level 2?

Thanks.