Previous Blog Next Blog
Prev/Next Blog
by date

Minigolf Mania's Flying Text

Minigolf Mania's Flying Text
Name:Kevin Ryan
Date Posted:Aug 19, 2006
Rating:5.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Kevin Ryan

Blog post
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.

Edit: Okay, here is a link to a video. It is just the first Tutorial hole with the text animating showing a hole-in-one.


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 - more than one method can be selected)
// ============
// 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.

Recent Blog Posts
List:01/03/07 - Minigolf Mania - New Free Course Now Available
12/19/06 - Mac Minigolf Mania, Cheeseheads, and GGE
11/10/06 - Minigolf Mania Ships - Thanks
08/24/06 - Late Night Reading
08/19/06 - Minigolf Mania's Flying Text
08/15/06 - Something old, something new, something borrowed, ...
07/28/06 - All those years ago...
07/08/06 - Puzzle Poker - New Music/Mac- Minigolf Mania

Submit ResourceSubmit your own resources!

Jesse (Midhir) Liles   (Aug 19, 2006 at 08:46 GMT)
This could come in handy, thank you!

Phil Carlisle   (Aug 19, 2006 at 08:59 GMT)
Nice one Kevin. Another alternative to what you did would be to create an animation in max/maya/whatever and just play it in the gui from a dts file. But yours is the coder-centric way!! :)

Phil Carlisle   (Aug 19, 2006 at 09:00 GMT)
Ah, I just realised that my method would be more work, because it wouldnt easily work with arbitrary text messages. So yours is better.

Mincetro   (Aug 19, 2006 at 12:03 GMT)
Awesome, thanks for sharing this!

Dave D   (Aug 19, 2006 at 15:35 GMT)
This also works with a little modification in TGB. This is alot better than my spaghetti mess way of doing it.

Thanks for sharing

Andy Hawkins   (Aug 19, 2006 at 23:01 GMT)
@Kevin - thanks for the code. BTW I checked out Puzzle Poker and that is an awesome game. I was especially impressed with the way the program could tell you moves to make a score - how does it know???

Great game. Looking forward to Minigolf Mania.

Kevin Ryan   (Aug 20, 2006 at 05:58 GMT)
@Phil
I've been known to write coder-centric tools on occasion. :^) I wrote a 3D camera animation control system for the old Dynamix 3space that I thought was pretty neat, but made our 3D artist eyes glaze over when I showed it to him.

@Dave
Good to hear that it works on TGB. I originally wrote it for TGE 1.1 and I've updated to 1.4 without having to make any changes to the script.

@Andy
To give the player a hint I just do a recursive depth search of all possible moves from the current cards layout. Here is the actual code that figures out what the best move is if you want to check it out. I have a script call psGetHint(searchDepth) that calls the C++ code. It then returns a string to the script with the best set of moves that it found. It is commented and pretty straightforward.

I actually have two different types of searches in there and in the shipping version ended up going with the version that returns the simplest graphical display to the user.

Andy Hawkins   (Aug 20, 2006 at 10:20 GMT)
@Kevin- geeze there must be alot of possibilities??? Do you do it in one cycle or scan over time?

Kevin Ryan   (Aug 20, 2006 at 15:34 GMT)
I just do it in one call. Speed is the reason that it is in C code instead of Torque script. You can notice a slight pause at a depth search of 5 and a much longer pause when searching 6 moves ahead, but I'm only looking 3 moves ahead in Puzzle Poker for the hints. If I needed to look farther ahead I would've optimized the code and spread out the search over several frames.

Alienforce   (Aug 20, 2006 at 20:16 GMT)
Thanks for sharing, looking forward to see the "obstacle-avoiding camera"

Ed Johnson   (Aug 21, 2006 at 18:01 GMT)
Nice!

Kevin Ryan   (Aug 21, 2006 at 21:26 GMT)
I edited the blog to add a link to a short video showing it in action. I used an older version of Adobe Premiere to create it. Does anyone have any suggestions for a tool that will create videos with good compression and not lose to much quality?

It'd be nice to have a unread blogs posts option just like the unread forum post selection.

Matt Cuda   (Feb 03, 2008 at 04:41 GMT)
has anyone tried this with 1.5.2? It is not working for me. The function is called with no errors but the text is not displayed.

H.W. Kim   (Feb 04, 2008 at 11:38 GMT)
I Integrated all but got error like the following:


starter.fps/client/scripts/popUpText.cs (164): GuiBitmapCtrl::setBitmap - wrong number of arguments.
starter.fps/client/scripts/popUpText.cs (164): usage: (string filename)Set the bitmap displayed in the control. Note that it is limited in size, to 256x256.


Any ideas?

You must be a member and be logged in to either append comments or rate this resource.