Jump to content


Photo

Text Fx (collection Of Text Manipulating Tricks)


  • Please log in to reply
15 replies to this topic

#1 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 19 November 2009 - 02:22 AM

Text FX Scripts
Easy, copy and paste tricks that give dazzling results.
Posted Image

This is a collection of scripts that I've used throughout my game maker days.
I'm sharing them with everyone. They're very easy to use. A simple copy and
paste with a few edits to customize your result is all that it takes. Below are all
the scripts. On the very bottom I have a demo with all the scripts implemented.
There's 22 scripts. If you use the demo, all you have to do is change variables in
the create event to manipulate the effects. And that's it. Enjoy. :)


Current Effects [10]:
  • Wave
  • Outline
  • Shadow
  • Reflect
  • Stretch
  • Scrolling Banner
  • Blur
  • Glow
  • RPG Style Scrolling with wordwrap
  • Clickable Text

Wave Text
(Consists of two scripts)
scr_text_wave_init(x, y, text, wave_amount, col1, col2, col3, col4);
wave_x = argument0;
wave_y = argument1;
wave_text = argument2;
wave_amount = argument3;
wave_col1 = argument4;
wave_col2 = argument5;
wave_col3 = argument6;
wave_col4 = argument7;

scr_text_draw_wave(x, y, text, wave amount, col1, col2, col3, col4);
var xx, l, i, c, a;
xx = argument0;
l = string_length(argument2);
draw_set_halign(fa_center);
draw_set_valign(fa_left);
for (i = 1; i <= l; i += 1) 
	{
		c = string_char_at(argument2, i);
		a = i / 5;
		draw_text_transformed_color(xx, argument1 + argument3 * cos(a),c, 1, 1, radtodeg(arctan(sin(a))),argument4,argument5,argument6,argument7,1); 
		xx += string_width(c) * 1.1;
	}

Outlined Text
(Consists of two scripts)
scr_text_outlined_init(x, y, outline thickness, text);
outline_x=argument0;
outline_y=argument1;
outline_width=argument2;
outline_text=argument3;

scr_text_draw_outlined(x, y, outline thickness, text);
var _x, _y, outline, precision, text, dir_inc, dir, dist_inc, dist;
_x = argument0;
_y = argument1;
outline = argument2;
text = argument3;
dprecision = 8;
lprecision = 2;
dir_inc = 360 / dprecision;
dist_inc = outline / lprecision;
draw_set_color(c_black);
for (dir = 0; dir < 360; dir += dir_inc)
	{
		for (dist = dist_inc; dist <= outline; dist += dist_inc)
			{
				draw_text(_x+lengthdir_x(dist,dir),_y+lengthdir_y(dist,dir),text);
			}
	}
draw_set_color(c_white);
draw_text(_x,_y,text);

Shadowed Text
(Consists of two scripts)
scr_text_shadowed_init(x, y, text, shadow direction, shadow offset, alpha, text color, shadow color);
shadow_x=argument0;
shadow_y=argument1;
shadow_text=argument2;
shadow_direction=argument3;
shadow_offset=argument4;
shadow_alpha=argument5;
shadow_text_color=argument6;
shadow_color=argument7;

scr_text_draw_shadowed(x, y, text, shadow direction, shadow offset, alpha, text color, shadow color);
var xx, yy, text, dir, offset, pcol, xoff, yoff;
xx = argument0;
yy = argument1;
text = argument2;
dir = argument3;
offset = argument4;
intensity = argument5;
pcol = argument6;
draw_set_color(argument7);
draw_set_alpha(intensity);
xoff = lengthdir_x(offset,dir);
yoff = lengthdir_y(offset,dir);
draw_text(xx+xoff,yy+yoff,text);
draw_set_color(pcol);
draw_set_alpha(1);
draw_text(xx,yy,text);

Reflect Text
(Consists of two scripts)
stp=scr_text_reflect_init(x, y, text, col1, col2, col3, col4);
reflect_text = argument2;
reflect_x = argument0;
reflect_y = argument1;
reflect_col1 = argument3;
reflect_col2 = argument4;
reflect_col3 = argument5;
reflect_col4 = argument6;
draw_set_font(font0);
var surf spr spr2 spr_de;
surf = surface_create(string_width(argument2),string_height(argument2));
surface_set_target(surf);
draw_clear_alpha(c_white,0)
draw_set_color(c_black+100)
draw_rectangle(0,0,0+string_width(argument2),0+string_height(argument2),0)
draw_set_color(c_black)
draw_text_color(0,0,argument2,c_black+100,c_black,c_black+100,
c_black,1)
surface_reset_target();
spr = sprite_create_from_surface(surf,0,0,string_width(argument2),string_height(argument2),argument0,0,0,0,0,0);
surface_free(surf);
surf = surface_create(string_width(argument2),string_height(argument2));
surface_set_target(surf);
draw_clear_alpha(c_white,1)
draw_sprite_ext(spr,0,0,0+string_height(argument2),1,-1,0,noone,1)
surface_reset_target();
spr2 = sprite_create_from_surface(surf,0,0,string_width(argument2),string_height(argument2),0,1,0,0,0,0);
surface_free(surf);
surf = surface_create(string_width(argument2),string_height(argument2));
surface_set_target(surf);
draw_clear_alpha(c_white,1);
draw_rectangle_color(0,0,0+string_width(argument2),0+string_height(argument2)*(0/100),c_white*0.6,c_white*0.6,c_white*0.6,c_white*0
.6,0);
draw_rectangle_color(0,0+string_height(argument2)*(0/100),0+string_width(argument2),0+string_height(argument2),c_white*0.6,c_white*0.6,0,0,0);
surface_reset_target();
spr_de=sprite_create_from_surface(surf,0,0,string_width(argument2),string_height(argument2),0,0,0,0,0,0);
surface_free(surf);
sprite_set_alpha_from_sprite(spr2,spr_de);
str=argument2;
strh=string_height(argument2);
return spr2

scr_text_draw_reflected(x, y, text, col1, col2, col3, col4);
var col1,col2,col3,col4,strh;
col1 = argument4;
col2 = argument5;
col3 = argument6;
col4 = argument7;
strh=string_height(argument3)/1.8
draw_text_color(argument1,argument2,argument3,col1,col2,col3,c
ol4,1);
draw_sprite(argument0,0,argument1-string_width(argument3)/2,argument2+strh)


Scrolling Banner Text
(Consists of three scripts)
scr_text_banner_init(x, y, width of banner, text,speed, col1, col2, col3, col4, alpha);
text_x = argument0;
text_y = argument1;
text_box_width = argument2;
text_input = string(argument3)+"   ";
text_output = string_copy(text_input,1,text_box_width)+"   ";
text_length = string_length(text_input);
text_char = 0;
text_scroll_speed = argument4;
text_col1 = argument5;
text_col2 = argument6;
text_col3 = argument7;
text_col4 = argument8;
text_alpha = argument9;
alarm[0]= text_scroll_speed;

scr_text_banner
(Goes in Alarm[0] event)
if (text_char < text_length)
	{ 
		text_char += 1; 
		text_output += string_char_at(text_input,text_char);
		if (string_length(text_output)>= text_box_width ) 
			{
				text_output = string_copy(text_output,2,text_length-1);
			}				
	}
if (text_char >= text_length)	   
	{ 
		text_char = 0; 
	}
alarm[0]=text_scroll_speed;

scr_text_draw_banner(x, y, width of banner, text,speed, col1, col2, col3, col4, alpha);
draw_set_halign(fa_left);
draw_set_font(font1);
draw_text_color(argument0,argument1,argument2,argument3,argume
nt4,argument5,argument6,argument7);

Stretch Text
(Consists of two scripts)
scr_text_shadowed_init(x1, y1, x2, y2, text, col1, col2, col3, col4);
stretch_x1 = argument0;
stretch_y1 = argument1;
stetch_x2 = argument2;
stretch_y2 = argument3;
stretch_text = argument4;
stretch_col1 = argument5;
stretch_col2 = argument6;
stretch_col3 = argument7;
stretch_col4 = argument8;

scr_text_draw_stretched(x1, y1, x2, y2, text, col1, col2, col3, col4);
draw_text_transformed_color(argument0,argument1,argument4,(argument2-argument0)/string_width(argument4),(argument3-argument1)/string_height(argument4),0,argument5,argument6,argument7,argument8,1);

Blur Text
(Consists of two scripts)
scr_text_blur_init(x, y, text, amount of blur, quality(1-100), color);
blur_x = argument0;
blur_y = argument1;
blur_text = argument2;
blur_amount = argument3;
blur_quality = argument4;
blur_col1 = argument5;
blur_col2 = argument6;
blur_col3 = argument7;
blur_col4 = argument8;

scr_text_draw_blur(x, y, text, amount of blur, quality(1-100), color);
var a, d;
d = 0;
a = argument3;
c = argument5;
draw_set_alpha(1/argument4*(1/a)*5);
draw_set_color(c);
repeat(a)
	{
		repeat(argument4)
			{
				draw_text(argument0+cos(degtorad(d))*a,argument1+sin(degtorad(d))*a,argument2);
				d+=360/argument4;
			}
		d=0;
		a-=1;
	}
draw_set_alpha(1);


Glow Text
(Consists of two scripts)
scr_text_glow_init(x, y, text, amount of glow, quality(1-100), text color, glow color);
glow_x = argument0;
glow_y = argument1;
glow_text = argument2;
glow_amount = argument3;
glow_quality = argument4;
glow_text_color = argument5;
glow_color = argument6;

scr_text_draw_glow(x, y, text, amount of glow, quality(1-100), text color, glow color);
var a, d;
d = 0;
a = argument3*1.5;
c = argument5; 
g = argument6;
draw_set_alpha(1/argument4*(1/a)*5);
draw_set_color(g);
repeat(a)
	{
		repeat(argument4)
			{
				draw_text(argument0+cos(degtorad(d))*a,argument1+sin(degtorad(d))*a,argument2);
				d+=360/argument4;
			}
		d=0;
		a-=1;
	}
draw_set_alpha(1);
draw_set_color(c);
draw_text(argument0,argument1,argument2);
draw_set_alpha(1);

Scrolling Text With Wordwrap
(Consists of three scripts)
scr_text_scroll_init(x, y, text, box width, speed);
width = 50;
draw_set_color(c_white);
scroll_x = argument0;
scroll_y = argument1;
scroll_input_text = argument2;
scroll_box_width = argument3;
scroll_char = 0;
scroll_char_str = string_copy(scroll_input_text,scroll_char,1);
scroll_text = "";
scroll_speed = argument4;
alarm[1] = scroll_speed;

scr_text_scroll_wordwrap(text,box width,break symbol,check(true or false))
var pos_space, pos_current, text_current, text_output, line_current;
pos_current = 1;
pos_space = -1;
text_current = argument0;
if ( is_real(argument2)) 
	{
		argument2 = "#";
	}
text_output = "";
while(string_length(text_current) >= pos_current) 
{
	if ( string_width(string_copy(text_current,1,pos_current)) > argument1 )
	{
		if ( pos_space != -1 )
		{
			text_output += string_copy(text_current,1,pos_space) + string(argument2);
			text_current = string_copy(text_current,pos_space+1,string_length(text_current)-(pos_space));
			pos_current = 1;
			pos_space = -1;
		}
		else if ( argument3 == 1 )
		{
			text_output += string_copy(text_current,1,pos_current-1) + string(argument2)
			text_current = string_copy(text_current,pos_current,string_length(text_current)-(pos_current-1))
			pos_current = 1;
			pos_space = -1;
		}
	}
	if ( string_char_at(text_current,pos_current) == " " ) { pos_space = pos_current }
	pos_current += 1;
}
if string_length(text_current) > 0
{
	text_output += text_current;
}
return text_output;

Put this in Alarm[1]
if scroll_char != string_length(scroll_input_text) then
{
scroll_char += 1;
scroll_char_str = string_copy(scroll_input_text,scroll_char,1);
scroll_text = string_insert(scroll_char_str,scroll_text,string_length(scroll_text)+1);
scroll_text = scr_text_scroll_wordwrap(scroll_text,100,"#",true);
alarm[1] = scroll_speed;
}

scr_text_draw_scroll(x, y, text);
draw_text(argument0,argument1,argument2);

Clickable Text (Link)
(Consists of three scripts)
scr_text_link_init(x, y, text, text color, mouseover color, action);
link_x = argument0;
link_y = argument1;
link_text = argument2;
link_color = argument3;
link_mouseover_color = argument4;
link_action = argument5;

scr_text_draw_link(x, y, text, text color, mouseover color, action);
if ( (mouse_x > argument0) && (mouse_x < argument0+string_width(argument2)) && (mouse_y > argument1) && (mouse_y < argument1+string_height(argument2)))
{
	draw_set_color(argument4)
	if ( mouse_check_button_released(mb_left) ) { execute_string(argument5) }
}
else { draw_set_color(argument3) }
draw_text(argument0,argument1,argument2)

Posted Image


Edited by Glen, 19 November 2009 - 02:29 AM.

  • 2
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#2 titusthreex

titusthreex

    GMC Member

  • GMC Member
  • 59 posts
  • Version:GM:Studio

Posted 21 November 2009 - 05:31 PM

Very very nice. Thank you.
  • 0
Titus 3:5 "he saved us not by works of righteousness that we have done but on the basis of his mercy"
http://www.yoyogames...142510-the-hive

#3 Topaze22

Topaze22

    GMC Member

  • GMC Member
  • 58 posts

Posted 21 November 2009 - 09:15 PM

Amazing job !
Maybe I will use it, your code are so clean :whistle: (In one year, maybe I will send your my game ^^)
  • 0
English,spanish and French
Posted Image

#4 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 21 November 2009 - 11:00 PM

I'll comment the scripts eventually to help users. There's no comments on the scripts at the moment, just on how to use them. I'll work on that. As for using them, no credit is really needed. But if you do, I'd be grateful. :whistle:
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#5 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 26 December 2009 - 05:00 AM

Hope these scripts have been helpful.
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#6 littleboyred1

littleboyred1

    GMC Member

  • New Member
  • 218 posts

Posted 08 January 2010 - 09:09 PM

wow, this opened a bunch of new possibilities for me. THANKS! 8D

i almost started crying when writing this reply since i was so happy!
  • 0

#7 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 12 January 2010 - 10:02 PM

wow, this opened a bunch of new possibilities for me. THANKS! 8D

i almost started crying when writing this reply since i was so happy!

Lol, your very welcome. I'm glad I was able to help you. B-)
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#8 David Chen

David Chen

    GMC Member

  • New Member
  • 1 posts

Posted 06 March 2010 - 04:33 AM

Good example but it can't be used more than once or for text that changes in content like a score etc. Any ideas? =/
  • 0

#9 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 25 March 2010 - 09:09 PM

Good example but it can't be used more than once or for text that changes in content like a score etc. Any ideas? =/

Which effect are you trying to achieve that must be updated?
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#10 Batch

Batch

    GMC Member

  • GMC Member
  • 728 posts

Posted 01 April 2010 - 08:28 PM

This is really good :P .
Another one for the credit list.

-CubinJ
  • 0
~spriter / programer for free~
You may have known me in my past life as CubinJ...

#11 SuperBlizHedgehog

SuperBlizHedgehog

    GMC Member

  • GMC Member
  • 17 posts

Posted 02 April 2010 - 02:53 AM

This is all great and all but here is something I was trying to do:

Okay, so I have the clickable text and all the actions and stuff. Now, how do I set the font to the outlined text?
  • 0
Posted Image

#12 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 12 April 2010 - 09:20 PM

This is all great and all but here is something I was trying to do:

Okay, so I have the clickable text and all the actions and stuff. Now, how do I set the font to the outlined text?


Just add draw_set_font(font_name); to the drawing script. Assuming that you've added a font in the font section of your game.
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#13 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 29 May 2010 - 03:47 PM

These are really good. Thanks for posting.

Glad you like them.
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#14 linus371

linus371

    Cactus Games

  • New Member
  • 574 posts

Posted 23 June 2010 - 10:00 PM

___________________________________________
COMPILATION ERROR in Script: scr_text_reflect_init
Error in code at line 18:
spr = sprite_create_from_surface(surf,0,0,string_width(argument2),string_height(argument2),argument0,0,0,0,0,0);
^
at position 112: Wrong number of arguments to function or script.
  • 0
Posted Image Posted Image
Plz give me some of these internet ^ :D

#15 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 14 July 2010 - 02:37 PM

___________________________________________
COMPILATION ERROR in Script: scr_text_reflect_init
Error in code at line 18:
spr = sprite_create_from_surface(surf,0,0,string_width(argument2),string_height(argument2),argument0,0,0,0,0,0);
^
at position 112: Wrong number of arguments to function or script.


These effects were created in GM7. GM8 modified a dew of the sprite arguments. I'm assumming you opened it up on GM8.
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies

#16 Glen

Glen

    GMC Member

  • GMC Member
  • 841 posts
  • Version:GM:Studio

Posted 12 January 2011 - 05:19 AM

I'm going to update these scripts soon so the surface issues no longer pop up on GM8 users.
  • 0
Avic Pro (Work in Progress):
Portable media manager. Just pop in your usb drive and use Avic Pro to organize and present all of your media content in categories. On top of that, it makes handling portable games, software, and other utilities a breeze. It allows you to launch just about any of your media content quickly and efficiently from your system tray. No more long paths to finding content.
Savage Defence| Text FX | Ragdoll Axe Engine | Professionalism | Online Games | Game Progression | 3D Game Development | Online Anti-Hack Strategies