Computer Science Canada [source code] Text Effects |
Author: | Tony [ Sun Sep 01, 2002 7:07 pm ] |
Post subject: | [source code] Text Effects |
I've seen a lot of people trying to make RPG games in turing and some turned out quite nice actually. As Dan about QFTB, he has it posted somewhere. Most of typical RPGs have plots (atleast they should) and chats with other NPCs. Basically you'll end up displaying a lot of text. In this post I will be posting source codes for different text effects that you can use throughout your games and other applications. |
Author: | Tony [ Sun Sep 01, 2002 7:21 pm ] | ||||
Post subject: | Displaying text | ||||
This is the simpliest way to display text information on the screen:
if you didn't know that already... well you've got a long way to go. Here's a better way to display your text -- Font.Draw
A bit of explanation -- fontID is a variable that stores information about the font you're using. It has to be an 'int' but can be assigned a value only through Font.New as in example. Arial is the name of the font you're using, if the name doesn't match with anything on computer, the default one is used. 14 stands for the size, you can change it to any integer number. 'bold' makes text bold and is optional. You can also add :italic and/or :underline if you want. "Your text here" is the text that will be displayed, it can be a string variable. x and y are the coordinates of the lower-left corner where text starts. fontID is the name of the variable decleared earlier. colour is the color of the text to be displayed - place an integer value or a predefined keyword for color. |
Author: | Tony [ Sun Sep 01, 2002 7:36 pm ] | ||||
Post subject: | Text Delay | ||||
Text Delay is the simpliest text effect. What it does is it delays the time between each character being displayed, making it look like the text is being typed while you're reading it. Very useful, especially for games where a lot of text is displayed like RPG.
I bit of explanation here -- TextDelay is a procedure. This way you can use it again and again in your code just like you use "put" command. "text" is the name of the string variable passed into the procedure. Then a forloop is run from 1 to the total number of charactes in the string. It is displayed 1 character at a time followed by a delay(50). If you increase the number, text will be typed slower, decrease it to display it quicker. Note: after putting each character don't forget '..' to keep them all on 1 line and when getting a text string, don't forget to put ':*' to get all the characters including spaces. And ofcourse you can just put plain text instead of the variable if you already know what to display
|
Author: | Tony [ Sun Sep 01, 2002 7:50 pm ] | ||||
Post subject: | TextDelay -- Coloured | ||||
If you didn't know before, text from 'put' command can be colored as well as text from Font.Draw using color(i:int) and colorback(i:int)
this will output "hello world!" in yellow color on a blue background. Now we can take this one step further and include that in previosly shown TextDelay!
This works the same way as before, but at first the character is printed in red, then it turns blue as the next character is printed. If you understand simple TextDelay, you should understand how this one works too. Note: This procedure uses locate to output this text. In 'locate(5,i)' 5 stands for the row where text will be outputed and should be changed to achive desired results. You should not change 'i' since its the counter for the characters being displayed. |
Author: | Tony [ Sun Sep 01, 2002 8:46 pm ] | ||
Post subject: | 3D text | ||
Here's something new for you guys -- text in 3D! Here's the code, take a look
Now a bit about how this thing works... variable size is the final size of the text that will be outputed. text is the variable for the... TEXT to be outputed. fontID is just like before is used as a font ID. Though this time its an array since we need many different fonts. Each font is of a different size from small to large. Puting those fonts on top of each other will make text look 3D, here's how: the main body runs 2 forloops. "for t" runs to count each character in the text to be outputed. "for i" puts fonts from half the size to full size on top of each other. t*size gives us a value of character position times the final size of the font. that gives a good estimate of spacing between letters. You could adjust that number to finetune spacing for specific fonts. The color is the tricky part. The idea behind the raycasting is to go from darker to lighter color depending on the distance. this piece of code "20+ floor(i/size*10)" will evenly destribute numbers from 20 to 30 over whatever size you chouse. Numbers 20 to 30 corespond with the gridient from black to white in turing and is the easiest one to use to make it look 3D. Since the fontID array is decleared based on the size of text desired and is outside of procedure, this effect is generally one time use. If for some crazy reason you would need to use this as often as 'put' command, I'm sure you can rearange the source code to suit your desire. |
Author: | Tony [ Mon Sep 02, 2002 8:05 pm ] | ||||
Post subject: | Arched Text | ||||
This one took me a while... you better like it, or I'm not posting any more here's the code to make your text in a form of an arch: NOTE: This code will only work under winoot 4.0.1 or higher because it uses a new "Pic.Rotate" feature not available in previous versions.
I really don't feel like explaining it right now... I got really frustrated couple of times today while making this. Basically what it does is that it takes each letter drawn using Font.Draw and saves it as a picture. Then its whole bunch of trigionometry to calculate angles and position of each character to arrangle them in an arch formation. Calculations were done for the first half and then flipped to make values for second... I run into some problems and this seemed a better way out... might not be the best solution though. Also, that little IF statment at the beggining of the program will add an extra character if you got an odd number of characters because otherwise last one will disappear. Also you can change the relative height and width of the arch by messing with declaration of X and Y
in Y, *30* is a relative height of the arch...you can change that... In X, *60 - is the center of the arch, you can move the text left and right by changing this number. The *60* part is the relative width of the arch, you can change this to make the arch wider or thiner. This effect might be a good use for generating custom arched signs for things like park entrances or something... Who knows what kind of stuff you guys are making out there, I'm just giving you source code to use. |
Author: | Mazer [ Mon Oct 07, 2002 9:56 am ] |
Post subject: | |
i liked the text delay with colour but it isn't that impressive since you're still stuck the the stupid turing run window font. think you could come up with a way to use that type of proc with Font.Draw? that would be impressive. don't worry about the text getting cut off i'd just like to see it done even with a few letters. |
Author: | JayLo [ Thu Mar 20, 2003 7:59 pm ] |
Post subject: | |
yes tony. it would be impressive. |
Author: | JayLo [ Thu Mar 20, 2003 8:17 pm ] | ||
Post subject: | Font.Draw in TextDelay | ||
here it is. not as hard as I thought. Text Delay involving Font.Draw!
MOD EDIT: gave you some bits for this, good work. -Dan |
Author: | Asok [ Thu Mar 20, 2003 9:18 pm ] |
Post subject: | |
Jay Lo, there are some spacing issues with your code you should address. |
Author: | Tony [ Thu Mar 20, 2003 9:55 pm ] |
Post subject: | |
well spacing with font.draw would be my bad... I assumed that the size of a letter in pixels would equal to its size. Which is almost accurate. Atleast it would be with a fixed width font. |
Author: | Catalyst [ Thu Mar 20, 2003 10:19 pm ] |
Post subject: | |
jus tuse Font.WIdth |
Author: | Catalyst [ Thu Mar 20, 2003 10:21 pm ] | ||
Post subject: | |||
here i fixed the spacing issue in ur code
Mod Edit: gave some bits for the improved code - Tony |
Author: | Asok [ Fri Mar 21, 2003 12:43 am ] |
Post subject: | |
Excellent job Catalyst! |
Author: | JayLo [ Fri Mar 21, 2003 6:23 pm ] |
Post subject: | lol |
catalyst puts me to shame... |
Author: | Delta [ Fri Mar 21, 2003 10:55 pm ] | ||
Post subject: | Text Effect Number 1 | ||
Types out the text
|
Author: | Tony [ Fri Mar 21, 2003 11:00 pm ] |
Post subject: | |
isnt it the same as textDelay |
Author: | Delta [ Fri Mar 21, 2003 11:04 pm ] | ||
Post subject: | |||
Here is the same thing just with some extras and using Font.Draw
|
Author: | Delta [ Fri Mar 21, 2003 11:06 pm ] |
Post subject: | I'm sorry |
Sorry if some of the text effects are the same I'm just posting what ever I can think of |
Author: | Delta [ Fri Mar 21, 2003 11:17 pm ] | ||
Post subject: | Text Effect Number3 | ||
Fades in text using Font.Draw
to fade out for i : 16 .. 31 fades from black to white |
Author: | Delta [ Fri Mar 21, 2003 11:25 pm ] | ||
Post subject: | Text Effect Number 4 | ||
Flashes the letters in the word
|
Author: | Catalyst [ Sat Mar 22, 2003 12:54 pm ] | ||
Post subject: | |||
This makes the text explode and unexplode, (note for now only on a black background)
MOD Edit: I never realized we had such awesome turing programmers here already This effect by far is the best! +15Bits, I'm VERY impressed -Tony MOD Edit: This is godly! Adding an additional +5 Bits! -Asok |
Author: | Catalyst [ Sat Mar 29, 2003 1:29 am ] | ||
Post subject: | |||
bored... racecar effect...
MOD Edit: Those effects just keep on comming +10Bits -Tony |
Author: | BlAcK TuRtLe [ Mon Mar 31, 2003 7:51 pm ] | ||
Post subject: | |||
Thanks for the help. Here is a primitive piece of crap I just made
|
Author: | Tony [ Mon Mar 31, 2003 8:18 pm ] |
Post subject: | |
lol, not exactly a text effect, but its still cool |
Author: | Catalyst [ Mon Mar 31, 2003 10:25 pm ] | ||
Post subject: | |||
looked at my last post here (racecar) an got and idea...
|
Author: | Catalyst [ Mon Mar 31, 2003 10:28 pm ] | ||
Post subject: | |||
this happened to come about when i was making the last one... (altho i dont need to for some reason i still use particles)
|
Author: | Tony [ Mon Mar 31, 2003 10:59 pm ] |
Post subject: | |
AWESOME... just AWESOME. +20Bits ofcourse... each |
Author: | Tony [ Sat Apr 05, 2003 3:36 pm ] | ||||
Post subject: | |||||
Count-Down Note: This text effect works only in v4+ compilers because of View.Update. The effect will work in v3 if View.Update is removed, but it will flicker. If you want to use it in v3 anyway, atleast get rid of cls to reduce flicker amount.
Counts down from/to numbers your specify. Good for the start of the "movie" or whenever you need to count down to something. Also this procedure is screen-size independant. Meaning it would work properly in any screensize of your program. Note: if you count in single digits only, you can take out
|
Author: | void [ Mon Apr 07, 2003 6:34 pm ] |
Post subject: | patch |
is there a patch i can get for v3 to run v4 programs because i really dont feel like paying money for v4 but all these neat effects require v4 because of the one line that all of them use "View.Update" if anyone knows of any site where i can in theory "GET" this v4 of winOOT...a link would be much appreciated or a link to a patch..(my skools too cheap for v4) |
Author: | Dan [ Mon Apr 07, 2003 7:03 pm ] |
Post subject: | |
i do not bilve there is a pach for 3.1.1 to 4.X . Also the only site i know of that has pachs for turing is holths site. |
Author: | haujobb [ Tue Apr 15, 2003 9:28 am ] | ||
Post subject: | |||
Didn't see this anywhere else so...
The first variable passed is the text that you want displayed and the second variable is which row you want it displayed on... Also... the Y coordinate - in this case 60 - intTextlength - only works with the screen size I used to you might have to alter that value. |
Author: | Tony [ Tue Apr 15, 2003 10:09 am ] |
Post subject: | |
if you replace 60 with maxcol it would work for any window size Also, there is no patch from v3 to v4 since v4 was rewriten from scrach. You can take out View.Update and View.Set("offscreenonly") as the rest of the code should be compatible with v3. The only downside is flashing. |
Author: | haujobb [ Tue Apr 15, 2003 10:16 am ] |
Post subject: | |
60 is the center of the screen, so it would be maxcol \ 2. Good idea tho, I'm gonna use that now... |
Author: | Blade [ Sat Apr 19, 2003 3:01 pm ] |
Post subject: | |
tony wrote: if you replace 60 with maxcol it would work for any window size
Also, there is no patch from v3 to v4 since v4 was rewriten from scrach. You can take out View.Update and View.Set("offscreenonly") as the rest of the code should be compatible with v3. The only downside is flashing. so thats why sprites dont work in 4.... wierd stuffs.. |
Author: | Blade [ Thu May 22, 2003 11:22 am ] | ||
Post subject: | |||
here's my 2 cents worth of text effect it might help some though because there was a question in turing help forum
MOD EDIT: Fixed some typos so it actually works. -Asok |
Author: | AsianSensation [ Sun Jul 20, 2003 12:28 pm ] | ||
Post subject: | |||
One more text effect.... 3D(sort of) text rising
I got this idea when I was looking back at my midterm mario rpg game. It works the same way with a picture. readjust the delays for different computer. |
Author: | AsianSensation [ Sun Jul 20, 2003 4:59 pm ] | ||
Post subject: | |||
here is a better version of the above one, more 3D-ish...
Tweaking with the RGB value will give you different color displays. Also, tweak depth for how much it rises. Edit: Well, fixed some error, and made it look better, especially with the purple color |
Author: | SilverSprite [ Tue Jul 22, 2003 2:34 pm ] |
Post subject: | |
Sucky.. |
Author: | AsianSensation [ Sun Aug 10, 2003 11:51 am ] | ||
Post subject: | |||
Well, time again for the AsianSensation text effect of the.....um.....month, yeah! 8)
Text shading, I haven't seen this up here, just thought it was useful... now all I need is a sliding shade fade for text... maybe I'll work it out for next month 8) Edit: lol, I realized that I spelt AsianSensation wrong, lol. I also "fixed" that outline thing, and spelt Arial correctly, lol |
Author: | SilverSprite [ Sun Aug 10, 2003 12:41 pm ] |
Post subject: | |
this is even crappier lol |
Author: | PaddyLong [ Sun Aug 10, 2003 2:22 pm ] |
Post subject: | |
a good idea ... unfortunately it looks kind of grubby because of that outline or something lol btw you spelt arial wrong |
Author: | AsianSensation [ Mon Aug 11, 2003 9:47 am ] |
Post subject: | |
lol, I spelt Arial wrong, guess you found another error in the Turing help document, lol. I only copy and pasted what's on the help file. btw, what outline are you talking about? If you mean that line that goes from left to right while shading, just comment off View.Update, and it shouldn't appear anymore. |
Author: | PaddyLong [ Mon Aug 11, 2003 11:28 am ] |
Post subject: | |
no I mean around some of the first letters you can see a few miscoloured pixels... |
Author: | Tony [ Sat Oct 04, 2003 11:05 pm ] | ||||
Post subject: | |||||
This weekend I saw foolproof and desided to try and reprocude the text effect they have in the opening. Its basically a random line of hex numbers (well not really hex, but of 2 digit sets) that randomly rotate into the text wanted. This is what I came up with
Sorry that it's not commented much. I added some key info, but I donno... if you have questions about how it works, ask. Although you dont really need to know how it works. Not unless you would want to modify hardcoded font (btw, if you're to modify font's size, you'd have to reprogram spacing as well). Quote: Effect's method has following format: foolproof(text:string, x:int, y:int, delay:int text - a string to be displayed x/y - location of the left most letter (note, the letter will end up moving a bit to the left during spread out delay - delay between each step during animation. The amount of calculations required makes it run normaly on my computer with 0 delay An example of call is
Notes - some flashing numbers before animation are to load up images of letters and numbers. - View mod is set to "offscreenonly" during animation. - effect uses cls. If you want to use it with background, you would need to modify that line - two procedures are involved. draw is for drawing each letter at spesific step. foolproof is the driver that loads values and calls draw |
Author: | PaddyLong [ Sun Oct 05, 2003 1:30 pm ] |
Post subject: | |
very cool Tony |
Author: | Tony [ Mon Oct 27, 2003 11:04 pm ] | ||||
Post subject: | |||||
yet again - another text effect from the creative mind of bored Tony Falling Binary
kind of documented... not really... should be straight-farward. The binary that's falling are real binary values of text passed to the method. Reading from bottom to up. to run the effect:
where it's binaryFall(text:string, number_of_rows_to_fall:int) |
Author: | thoughtful [ Tue Oct 28, 2003 6:05 pm ] | ||||
Post subject: | My lame effect | ||||
This is a lame strike out effect i made. Still has some length issues.
At the end try this to call the procedure
|
Author: | Tony [ Tue Oct 28, 2003 6:51 pm ] | ||
Post subject: | |||
I'm not sure if this would help, but
might come in handy. It tells you the width of a textstring using sertain font in pixels. |
Author: | thoughtful [ Tue Oct 28, 2003 7:53 pm ] | ||
Post subject: | Thnx | ||
Hey thnx, now the length problem is fixed using the command u gave me. I also added custom color. But still the effect is petty lame will do a better one if got more time.
|
Author: | thoughtful [ Wed Oct 29, 2003 11:27 pm ] | ||
Post subject: | Some other lame effects | ||
Well i made some other lame effects, please do not draw n e thing above 300 y pixels as i m using that area as the scratch pad. PS:= Can n e one tell me how to use the whatdotcolor functions offscreen, as in how to draw something which has a position greater than maxx or maxy and use this function, because i first tried to use that but it didnt work. Here are the 3 effects:
|
Author: | Tony [ Thu Oct 30, 2003 5:35 pm ] |
Post subject: | |
well I'm sure that dodge can tell you all about whatdotcolor though you shouldn't be using it really.Got to be better ways out there. |
Author: | thoughtful [ Thu Oct 30, 2003 7:02 pm ] | ||||
Post subject: | Rainbow Effect | ||||
Well, i made another effect using the same method , now i use window.open for the scratch pad. N E ways this actually look pretty okay. PS:= Can any one tell me the command to get the RGB values of pixels.
note:- If using a backround color other than white change the line
|
Author: | Tony [ Thu Oct 30, 2003 7:54 pm ] |
Post subject: | |
I think the rainbow effect would look better it was vertical instead of horizontal |
Author: | Catalyst [ Fri Oct 31, 2003 8:09 am ] | ||
Post subject: | |||
another effect...
|
Author: | AsianSensation [ Fri Oct 31, 2003 7:55 pm ] |
Post subject: | |
nice...... that is some cool stuff..... though it looked cooler when you use 27 as the color to draw the word, then the word blends into the background, but you can still see it, because it's a bit darker than the background. kudos |
Author: | thoughtful [ Sat Nov 01, 2003 11:28 am ] | ||
Post subject: | Another effect | ||
Here is the vertical effect which infact does look better and another one i made. PS:- Catalyst you are something man! ditch the school goto a uni!!!
|
Author: | Andy [ Sun Nov 02, 2003 3:16 pm ] |
Post subject: | |
tony wrote: well I'm sure that dodge can tell you all about whatdotcolor
damn straight.... use what dot color or be |
Author: | thoughtful [ Sun Nov 02, 2003 7:37 pm ] |
Post subject: | |
LOL, I think ill stick with what dot color ) By the way do you know a way to get RGB values of dots. |
Author: | AsianSensation [ Sun Nov 02, 2003 8:23 pm ] |
Post subject: | |
first, use whatdotcolor (I am being total serious here, you actually have to use whatdotcolor) then use RGB.GetColor |
Author: | Catalyst [ Sun Nov 02, 2003 8:58 pm ] |
Post subject: | |
using the RGB functions can make whatdotcolor not function correctly, so beware |
Author: | Tony [ Sun Nov 02, 2003 10:58 pm ] |
Post subject: | |
I'm sure it would... Since whatdotcolor returns an integer representing color on 255 pallet. RGB ofcourse has 255^3 colors, which is much much more If you really need to, you can keep a vertual buffer in an array, so instead of drawing to screen, you draw to your buffer, which later draws to screen (just like View.Update works). The thing is - you'd have to rewrite all the Draw. module and you'll have major speed issues if your buffer gets too large. |
Author: | santabruzer [ Sun Nov 16, 2003 8:59 pm ] |
Post subject: | |
Holy crap i should pay attention to computer science classes.... this stuff is amazing.. dudes... the font thingies.... |
Author: | Tony [ Sun Nov 16, 2003 9:11 pm ] |
Post subject: | |
yeah... well... you aren't going to learn any special effects in CS classes This is all self-taught. Though you should pay attention to learn new syntax and understand how programing works, then you can imagine an effect you want to achieve and figure out a way of doing so. |
Author: | santabruzer [ Mon Nov 17, 2003 4:53 pm ] |
Post subject: | |
I was told by the teacher i'm a self learner.. now how smart is the teacher? oh well.. i'm in the very first course... and i dunnu.. it's boring like hell.. problem solving... oh well... |
Author: | Tony [ Mon Nov 17, 2003 6:28 pm ] |
Post subject: | |
exactly... thats why you got to find your own challange and figure out your way to achieve that. Variaous text effects are fun to play with |
Author: | Tendulkar [ Tue Nov 25, 2003 10:24 pm ] |
Post subject: | Re: [source code] Text Effects |
tony wrote: I've seen a lot of people trying to make RPG games in turing and some turned out quite nice actually. As Dan about QFTB, he has it posted somewhere.
Most of typical RPGs have plots (atleast they should) and chats with other NPCs. Basically you'll end up displaying a lot of text. In this post I will be posting source codes for different text effects that you can use throughout your games and other applications. % HERE IS YOUR CODE: var fullscreen := Window.Open ("fullscreen") drawfillbox (0, 0, maxx, maxy, black) var word : string var x, c : int colour (brightred) colourback (black) put "Enter The Word: " .. colour (brightgreen) get word : * x := 50 var font : int := Font.New ("Lucida Handwriting:" + intstr (30)) var xwidth : int := Font.Width (word, font) % THE NAME AT THE BOTTOM process name2 loop for i : 1 .. 250 Font.Draw (word, maxx div 2 - (Font.Width (word, font) div 2), 10, font, i) delay (80) end for end loop end name2 fork name2 % THE NAME IN THE MIDDLE x := maxx div 2 - (Font.Width (word, font) div 2) for i : 1 .. length (word) if i = 7 then c := 29 else c := i end if Font.Draw (word (i), x, maxy div 2 - 10, font, c) x := x + 30 delay (100) end for % THE NAME IN THE MIDDLE process name loop x := maxx div 2 - (Font.Width (word, font) div 2) for i : 1 .. length (word) randint (c, 1, 35) if c = 7 then c := 45 else end if Font.Draw (word (i), x, maxy div 2 - 10, font, c) x := x + 30 delay (50) end for end loop end name fork name % THE TOP NAME WHICH IS MOVING drawfillbox (0, 0, maxx, maxy, black) loop for i : 1 .. maxx + Font.Width (word, font) - 100 if i > 250 then randint (c, 0, 15) else end if Font.Draw (word, i, maxy - 50, font, c) delay (15) Font.Draw (word, i, maxy - 50, font, black) end for end loop |
Author: | Tendulkar [ Tue Nov 25, 2003 11:31 pm ] |
Post subject: | Re: [source code] Text Effects |
HEY HERE IS THE CODE FOR TEXT EFFECTS:: Check this out |
Author: | Tendulkar [ Tue Nov 25, 2003 11:32 pm ] |
Post subject: | Re: [source code] Text Effects |
Hey I also have one other program for text effects: Check it out, too. |
Author: | nis [ Wed Nov 26, 2003 11:48 pm ] | ||
Post subject: | Glowing Text | ||
Just a very very simple program i made
|