Minigolf Mania's Flying TextAugust 18, 2006 Background As I've worked on Minigolf Mania for the last few decades I've made several changes to stock the Torque Game Engine to accomplish various things. As I get the time I'm going to write up what I did and include the source code that hopefully someone finds useful for their own games. Some of the stuff, like the following, is all script so I can release it here publicly. And in future plans, some of the stuff is more tied to the Torque code so I'll have to talk about in a general way in the plans and post the actual code in one of the Torque private areas. Except for the alphanumeric graphic files (alpha.zip), feel free to use/modify the following in any way you want - commercial - non-commercial - whatever. You can use my PNG letter/numbers for your own internal testing, but please don't release them in any games or demos. Oh, and it really wasn't a few decades of work on Minigolf Mania, it just feels that way sometimes. What it does For Minigolf Mania I wanted to have some dynamic text that could fly out onto the screen and then animate for a while before going away. So I have a script function that can be called with the text to display, how it should make its appearance, and then how it should animate after it is in it's final position on the screen. What it does is create a GuiBitmapCtrl for each letter and then move them around on top of my 3D scene. Once the animation is complete it will delete all of the created controls. Here is a screen shot of the "Hole in One!! Birdie" text in the middle of combo sin bounce/cos side-to-side animation on the screen: Hmmm, hard to visualize the animation, if I get the time I'll put a link to a short video here. Rather than explain everything I'll just post the script file header from popUpText.cs below. It has most of the information on how the function call works: // ------------------------------------------------------------------- // // function showPopupMessage( %textToShow, %appearMethod, %showMethod) // // // Notes: The first parameter is the text that is to be displayed. // Tabs are used (\t) to indicate multiple lines. Second // parameter is the appearance method - first word is the // method (see below) and second word is how long it takes // to appear in miliseconds (ie 1,000 means on second). // Third parameter is the show method - first word is the // method (see below), second word is how long it appears // on screen, and the third word is how long each animation // cycle is. // // showPopupMessage( "text line 1/ttext line 2", // "appearanceMethod appearanceLength", // "showMethod showLength showCycle"); // // // Appearance Methods (appearanceMethod) // ================== // -1 - Random Method (any but 'None' method) // 0 - None // 1 - Rise Up // 2 - Zoom from the left // 3 - Drop Down // 4 - Zoom from the right // 5 - Diagonal to straight // 6 - Four Corners // 7 - Circle in from right // // // Show Methods (showMethod) (bits set - select more than one method) // ============ // 0 - Steady // 1 - Sin bounce // 2 - Cos side-to-side // 4 - Whole word sin bounce // 8 - Whole word cos side-to-side // // // // Some sample calls // ----------------- // // showPopupMessage(\$PlayerName[%playerNum] @ "\tYour Putt", // "2 700", "2 1800 800"); // // This will show player name on 1st line and "Your Putt" on the // second line. It will zoom in from the left and take 0.7 seconds // to appear. It will then animate for 1.8 seconds using the // Cos side-to-side method cycling every 0.8 seconds. // //------------------- // // showPopupMessage( "Got it!", "0 0", "1 1200 800"); // // This will show "Got it!" on the screen. It will appear // immediately with no appearance animation. It will animate // for 1.2 seconds using the Sin bound method with a cycle // of 0.8 seconds. // //------------------- // // showPopupMessage("Hole-In-One!!/tBirdie", // "7 1200", "3 3200 900"); // // This will show "Hole-In-One!!" on the 1st line and "Birdie" on // the second line. It will circle in from the right and take 1.2 // seconds to appear. It will then animation for 3.2 seconds using // both the Sin bounce and Cos side-to-side methods with a cycle // of 0.9 seconds.  Once you have it running it would be very easy to add your own appearance and show methods. What you need You will need the script file: popUpText.cs and the text in graphic format: alpha.zip I have the popUpText.cs file in the client\scripts folder on my computer. Doesn't really matter where you put it. I have a bitmap for each letter of the alphabet, numbers, and also for some puncutation. You will find all of these in the alpha.zip file. I am storing all of these files in the client\ui\alpha folder. If you store them in a different place then you will need to modify the script to point to your location. You can find this folder location in the script right before the GuiBitmapCtrl is created. A few other useful notes I am including the popUpText.cs script file exactly as I have it in Minigolf Mania. There are a couple of minigolf specific things in there that you'll probably want to delete. It is pretty obvious what they are, but it should run fine even with them in there. My main game window is called PlayGui - actually here it is without all the controls contained within it: new GameTSCtrl(PlayGUI) { profile = "GuiContentProfile"; horizSizing = "right"; vertSizing = "bottom"; position = "0 0"; extent = "800 600"; minExtent = "8 8"; visible = "1"; helpTag = "0"; cameraZRot = "0"; forceFOV = "0"; noCursor = "1"; };  You will need to replace all instances of PlayGui in popUpText.cs with whatever your game window is called. I am making a call to updatePopupMessage() once per frame at the very start of GuiCanvas::renderFrame(). You can call it from anywhere you want, but it should be called once per rendered frame so it can update the letter locations. In Closing I think that is it. Nothing real fancy, but it looks nice. If I've missed something or if something is unclear let me know and I'll edit this plan so it is up-to-date. Minigolf Mania is getting close to being complete. I'll try to get a video posted that includes the flying text sometime in the next week. In my next plan I'll post about how I made the automatic ball-following obstacle-avoiding camera. Next Blog: Late Night Reading