E
Enegris
Guest
Here's my problem: I created my own font in MS Paint., and want to implement it in my project. Gamemakers font options are quite confusing for me, so i looked for the easy way out (I thought) and wrote a few lines of code to iterate through the text, determine the letter and whether it's capitalized or lowercase, and then let it draw each letter i actually want to have on screen. This works BUT it is way too inefficient and with a lot of text, the framerate drops drastically. So my question would be: is there any way to improve this or do I need to approach it differently? Any help would be greatly appreciated.
Create Event:
text = "This is my little experiment. Maybe, no: hopefully it works? If not - try again!"
abc = "abcdefghijklmnopqrstuvwxyz .,:-!?";
abc2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Draw Event:
for (i = 1; i < string_length(text)+1; i++)
{
for (z = 1; z < string_length(abc)+1; z++)
{
if string_char_at(text, i) == string_char_at(abc, z)
{
var char = string_char_at(abc, z)
if (ord(char) <= 96) or (ord(char) >= 240)
{
draw_sprite(spr_font1, z-1, x+((i)*10), y);
}
if (ord(char) > 96) and (ord(char) != 240)
{
draw_sprite(spr_font2, z-1, x+((i)*10), y);
}
}
if string_char_at(text, i) == string_char_at(abc2, z)
{
var char = string_char_at(abc2, z)
draw_sprite(spr_font1, z-1, x+((i)*10), y);
}
}
}
Create Event:
text = "This is my little experiment. Maybe, no: hopefully it works? If not - try again!"
abc = "abcdefghijklmnopqrstuvwxyz .,:-!?";
abc2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Draw Event:
for (i = 1; i < string_length(text)+1; i++)
{
for (z = 1; z < string_length(abc)+1; z++)
{
if string_char_at(text, i) == string_char_at(abc, z)
{
var char = string_char_at(abc, z)
if (ord(char) <= 96) or (ord(char) >= 240)
{
draw_sprite(spr_font1, z-1, x+((i)*10), y);
}
if (ord(char) > 96) and (ord(char) != 240)
{
draw_sprite(spr_font2, z-1, x+((i)*10), y);
}
}
if string_char_at(text, i) == string_char_at(abc2, z)
{
var char = string_char_at(abc2, z)
draw_sprite(spr_font1, z-1, x+((i)*10), y);
}
}
}