Letter sprites for words     (Moderator: Edward) Previous Topic | Next Topic
Page 1 of 1
 Author 
 Post 
Hell Raiser
Site Developer
Post 14-Aug-2015 02:10        

I noticed in Grismaths thread you mentioned using sprites For words to spell sentences. This Intrigues me, and I would like to know more on how it's set up.
Post 14-Aug-2015 14:43        

Well, first off, you'll need to create 254+ BMPs with letters and symbols in them (possibly not having to include the accentuos combinations like +a=, ~+n=, +A= etc, but combine them in COG), and best group them in a subfolder (mat\font1).

Then a batch convertion to MAT is in order, hopefully you can set the transparency pixels in that. If you want fading animation as well (an extra 15 cels to every chr) then it will have to be by hand (unless you program a MatMaster16+ to do the job for you ).

Wait, why don't I? Guess I tried but couldn't quite get the MATs just right. But I did do something to make it easy to do this next step: Create a SPR for each MAT and a template to follow (explosion with timer=0 or some timer and SetLifeLeft(spr, 0); later).
Here's the program that creates SPRs and templates: http://jkhub.net/project/show.php?projid=718
Note, it will only create +name basedon sprite=... You will have to prepare the "basedon" template yourself.

And then the cogging... Maybe you've seen it, maybe you remember something about some custom huds or numbers like score or timer (as seen in this Sonic mod). This is done using FireProjectile and a little fancy math on which number to use in the millions as well as offsets.

So far, I've found that a good sprite size has been 0.0025 (width or square) and a Y distance (from GetPrimaryFocus(0)) of 0.075. If you want the fonts bigger then it is just to decrease the distance. I'm not really sure what the clipping distance is in JK, so if you want to have the text as close as possible (so as not to clip into anything else the view might be moving around) but still keep those small sizes, you'll have to experiment a bit (with one sprite to begin with, then do the mass conversion).

So lets say you have sprites that are 0.0025 small, a simple "Hello" in the top right corner would look like this:

t=FireProjectile(GetPrimaryFocus(0), chr_BH, -1, -1, '-0.0550 0.075 0.04', '0 0 0', 0, 0, 0, 0);
t=FireProjectile(GetPrimaryFocus(0), chr_le, -1, -1, '-0.0525 0.075 0.04', '0 0 0', 0, 0, 0, 0);
t=FireProjectile(GetPrimaryFocus(0), chr_ll, -1, -1, '-0.0500 0.075 0.04', '0 0 0', 0, 0, 0, 0);
t=FireProjectile(GetPrimaryFocus(0), chr_ll, -1, -1, '-0.0475 0.075 0.04', '0 0 0', 0, 0, 0, 0);
t=FireProjectile(GetPrimaryFocus(0), chr_lo, -1, -1, '-0.0450 0.075 0.04', '0 0 0', 0, 0, 0, 0);

In the offset, the X would be left to right, the Y would be the distance, and the Z would be top to bottom.

The thing is stored into "t", and between each FP you could handle things like SetLifeLeft(t, 0); AttachThingToThing(t, GetPrimaryFocus(0)); and anything else you'd like. Actually, before the FP, I'd set t=-1; and then after the FP see if(t!=-1) and then do your stuff.

But with so many IF statements when you are going to have text appear after a certain amount of time, best set the offset as a seperate vector, set the chr as a seperate template, and then handle everything in a custom called message. For example:


offset='-0.0550 0.075 0.04';
chr = chr_BH;
call make_text;
offset='-0.0525 0.075 0.04';
chr = chr_le;
call make_text;
offset='-0.0500 0.075 0.04';
chr = chr_ll;
call make_text;
...
make_text:
  t=-1;
  t=FireProjectile(GetPrimaryFocus(0), chr, -1, -1, offset, '0 0 0', 0, 0, 0, 0);
  if(t!=-1)
  { .....
return;


Now, due to the limited number of symbols you can have, you will have to split your chr templates over several cogs and get them through SendMessageEx() (or possibly LoadTemplate()).

And there we have it! Now my cutscenes are no longer that special.

Also, depending on how many "screens" of text you are gonna have, you may run into limits which means you'll have to split your "stories" across several cogs.

Enjoy!
/Edward

Last edited by Edward on 14-Aug-2015 18:46; edited 1 time in total
Hell Raiser
Site Developer
Post 14-Aug-2015 17:50        

That's crazy good Edward! Thanks for sharing.
Post 14-Aug-2015 23:25        

Edward is a freakin genius. the stuff hes done is simply amazing.
*** Post commands are unavailable for guests. ***