Game Development Community

//

by Ryan Clifton · in Torque Game Builder · 12/28/2005 (7:19 pm) · 4 replies

//

About the author

Recent Threads

  • //
  • //
  • //
  • //
  • //

  • #1
    12/28/2005 (8:06 pm)
    Ryan it sounds like you could really benefit from checking out the tutorials section on TDN. While many of the articles are not finished yet the basic tutorials section is complete. There is also a platformer tutorial that is really good.

    The question you pose in this thread can be easily answered by going over the basic tutorial included in the Doc folder in your t2d install.

    best of luck!

    - Jesse
    #2
    12/28/2005 (10:57 pm)
    //
    #3
    12/29/2005 (7:48 am)
    The tutorial goes over the basics of how to setup keyboard commands using the "ActionMap" (Page#7) so I won't go over that again.

    There are two types of variables, local and global. Local ones only exist within each function but global ones exist, well, globally. :)

    Local variables use the prefix "%" whereas global ones use the prefix "$". Here are a few examples:
    %localVar1
    %localVar2
    $globalVar1
    $globalVar2
    All the standard operators you'd expect are available to you so you can assign a value to a variable (or a string) using...
    %localVar1 = 100;
    %localVar2 = "Hello!";
    $globalVar1 = 200;
    $globalVar2 = "Hello World!"
    You can also add/subtract with...
    %localVar1 = %localVar1 + 10;
    $globalVar1 = $globalVar1 - 20;
    ... or the shortcuts ...
    %localVar1 += 10;
    $globalVar1 -= 20;

    You are not restricted to using local/global variables. There are ones that can be dynamically assign to objects. Let's say you have a player static-sprite called "$playerObject", you can do...
    $playerObject.score = 1000;
    $playerObject.name = "Ryan";
    ... and even change them as normal...
    $playerObject.score += 20;
    $playerObject.name = "Ryan Clifton";

    You can either put these commands directly into the ActionMap command (not recommended) or just call a function that does this; something like "increaseScore()"...
    function increaseScore()
    {
      $playerScore += 20;
    }

    Hope this helps,

    - Melv.
    #4
    12/29/2005 (9:58 am)
    //