J
JohnSebek
Guest
So I was making and dialogue system by Diest link here. And I´ve run into several issues I wasn't able to fix. There are many of my issues:
Text is drawn in a very weird way so you are not able to see the modifiers and things will go insane
1. The text will display in a very weird way, it's hard to describe so I uploaded a link to a gif showing this
2. Frames will drop tremendously
3. The text will not disappear after being done(It's weird because it was happening before.)
Visualisation of the madness
Here is the code of my dialogue system and object calling it.
o_dialog
And finally, the object creating the text.
o_npc
Text is drawn in a very weird way so you are not able to see the modifiers and things will go insane
1. The text will display in a very weird way, it's hard to describe so I uploaded a link to a gif showing this
2. Frames will drop tremendously
3. The text will not disappear after being done(It's weird because it was happening before.)
Visualisation of the madness
Here is the code of my dialogue system and object calling it.
o_dialog
Code:
//CREATE EVENT
message_current = 0;
timer = 0;
cutoff = 0;
portrait = "portraitt";
t = 0;
amplitude = 3;
freq = 2;
done = false;
//DRAW GUI EVENT
draw_set_font(f_dialouge);
draw_set_colour(c_white);
t++;
//how many mesages are in array
message_end = array_length_1d(message);
if (message_end > 0)
{
//variables
var charWidth = 20;
var lineEnd = 35;
var line = 0;
var space = 0;
var i = 1;
var delay = 2;
//text position
var tY = view_hview[0]-55
if (portrait == "none") var tX = 5;
else var tX = 60;
//next message
if (keyboard_check_pressed(ord("E")))
{
//if still some messages,go to next
if (message_current < message_end-1)
{
message_current++;
cutoff = 0;
}
//if ve dont,we re done
else
{
done = true;
instance_destroy();
}
}
//typewriter
if (cutoff < string_length(message[message_current]))
{
if (timer >= delay)
{
cutoff++;
timer = 0;
}
else timer++;
}
//draw text
while(i <= string_length(message[message_current]) && i <= cutoff)
{
//check for modifier
if (string_char_at(message[message_current], i) == "\")
{
modifier = real(string_char_at(message[message_current], ++i));
++i;
}
{
//go to next line
var length = 0;
while (string_char_at(message[message_current], i) != " " && i <= string_length(message[message_current]))
{
i++;
length++;
}
if (space+length > lineEnd)
{
space = 0;
line++;
}
i -= length;
draw_text(tX+(space*charWidth), tY+(20*line), string_char_at(message[message_current], i));
space++;
i++;
}
//text
switch(modifier)
{
case 0: //normal
{
draw_set_colour(c_white);
draw_text(tX+(space*charWidth), tY+(13*line), string_char_at(message[message_current], i))
break;
}
case 1: //shake
{
draw_set_colour(c_white)
draw_text(tX+(space*charWidth)+random_range(-1, 1), tY+(13*line)+random_range(-1, 1), string_char_at(message[message_current], i))
break;
}
case 2: //wave
{
draw_set_colour(c_white)
var so = t + i;
var shift = sin(so*pi*freq/room_speed)*amplitude;
draw_text(tX+(space*charWidth), tY+(13*line)+shift, string_char_at(message[message_current], i));
break;
}
case 3: //gradient
{
var col = make_colour_hsv(t+i, 255, 255);
var col2 = make_colour_hsv(t+i+75, 255, 255);
draw_text_transformed_colour(tX+(space*charWidth), tY+(13*line), string_char_at(message[message_current], i), 1, 1 ,0, col, col, col2, col2, 1);
break;
}
//draw portait
switch(portrait)
{
case "none":
{
break;
}
case "portraitt":
{
draw_sprite(spr_dialogBASE, 0, 5,view_hview[0]-55);
break;
}
}
}
}
}
o_npc
Code:
//CREATE EVENT
message[0] = "\0Hello \1World\0!";
message[1] = "\3Goodbye \3World!\0";
//STEP EVENT
Dialouge(message,"none");