Eamonn wrote:Sam Storms wrote:Very nice, I'm starting on a platformer, I'm gonna use typo on it

Awesome! Glad to see it's useful. I hope to add more to it eventually (such as being able to get certain properties)
Trying to figure out how to do the string parsing, but I'll get there. I want to write it myself, so that typo has 0 external dependencies (except for Lua and LÖVE, of course

). Then you can add some more colorful things to your text.
I don't know how much this would help you, but this is my old code for a textbox dialogue system for game maker that I wrote quite awhile ago.
Create Event:
Code: Select all
textbox_surface = surface_create(256,224);
surface_set_target(textbox_surface);
draw_clear_alpha(0,0);
surface_reset_target();
text_entire = line_break_support(global.textbox_text);
text_letter = "";
draw_x = 0;
draw_y = 0;
current_position = 1;
max_position = string_length(text_entire) + 1;
color_1 = c_white;
color_2 = c_white;
global.cur_pos = current_position;
global.max_pos = max_position;
keyboard_clear(vk_space);
Step:
Code: Select all
if(current_position <= max_position) {
if(draw_y <= 30) {
text_letter = string_copy(text_entire,current_position,1);
switch(text_letter) {
case "]":
color_1 = c_aqua;
color_2 = c_blue;
break;
case "^":
color_1 = c_red;
color_2 = c_dkred;
break;
case "~":
color_1 = c_lime;
color_2 = c_green;
break;
case "`":
color_1 = c_white;
color_2 = c_white;
break;
case "#":
draw_x = 0;
draw_y += 15;
break;
default:
surface_set_target(textbox_surface);
draw_set_font(global.textbox_letters);
draw_text_color(view_xport+draw_x+28,view_yport+draw_y+161,text_letter,color_1,color_1,color_2,color_2,1);
surface_reset_target();
draw_x += string_width(text_letter);
draw_set_font(-1);
if(draw_x >= 195) {
draw_x = 0;
draw_y += 15;
}
}
current_position += 1;
}
}
// setup continue cursor
if(current_position >= max_position) {
current_position = max_position;
draw_x = 0;
draw_y = 0;
if (keyboard_check(vk_space)) {
instance_destroy();
}
}
Draw:
Code: Select all
draw_surface(textbox_surface,view_xview[0],view_yview[0]);
draw_set_font(global.textbox_letters);
draw_set_color(c_ltgray);
if(current_position >= max_position) {
draw_sprite(spr_block,-1,view_xport+draw_x+113,view_yport+draw_y+175);
}
draw_text(x,y,draw_x);
Destroy:
Code: Select all
draw_surface(textbox_surface,view_xview[0],view_yview[0]);
draw_set_font(global.textbox_letters);
draw_set_color(c_ltgray);
if(current_position >= max_position) {
draw_sprite(spr_block,-1,view_xport+draw_x+113,view_yport+draw_y+175);
}
draw_text(x,y,draw_x);
Keyboard Press Space:
Code: Select all
if(draw_y >= 45) {
instance_destroy();
textbox(string_copy(text_entire,current_position,string_length(text_entire)-current_position+1),color_1,color_2);
}
Demo Object:
Create:
Code: Select all
global.textbox_letters = font_add_sprite(spr_letters,ord('!'),1,1);
global.textbox_text = "";
Press Enter:
Code: Select all
textbox("Testing a very long text message, maybe the pointer will get a ~hint?");