Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411530 Posts in 69377 Topics- by 58433 Members - Latest Member: Bohdan_Zoshchenko

April 29, 2024, 02:26:42 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsDrawing Strings (Text) One Letter At A Time
Pages: [1]
Print
Author Topic: Drawing Strings (Text) One Letter At A Time  (Read 1798 times)
ink.inc
Guest
« on: December 14, 2011, 03:26:23 PM »

The following code will enable you to draw text on the screen one letter at a time. This is accomplished by having two strings- one that contains all the text, and another that only contains the text that is drawn to the screen. The original string is read, letter by letter, and copied to the second string. If certain characters are read, the system can take special action, such as making dramatic pauses, erasing the copy string (to move to the next text 'section'), and breaking lines.



CREATE:
Code:
draw_set_font(font0)
//& = pause
//~ = next text set
string_dum=
"
You can die too for all I care!~
AS... YOU... WISH! ~
Oh, my sweet Westley!##What have I done?~
"


timer=0 //measures amount of time between typing each letter
add_index=0 //the index of the current letter being added to the drawn string
string_line="" //the string being drawn
f="" //the actual letter being added
line_timer=0 //pause for moving to new text set
pause_timer=0 //pause for punctuation

STEP

Code:
timer+=1
if timer=2
    timer=0

if timer=0
and pause_timer<=0
and line_timer<=0
    {
    
    f=string_char_at(string_dum,add_index)
    if f="&"
        {
        pause_timer=20
        }
    else if f="~"
        {
        line_timer=50
        timer=0
        add_index+=1
        }
    else
        {
        if add_index>0
            string_line=string_insert(f,string_line,add_index+1)
        }
    if f="." or f="!" or f="?"
        pause_timer=15
    if f=","
        pause_timer=10
    add_index+=1
    }

pause_timer-=1
line_timer-=1
if line_timer=1
    string_line=""

DRAW
Code:
draw_text(x,y,string_line)
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile
« Reply #1 on: December 15, 2011, 03:12:24 AM »

You sexy son of a gun!
I think I'll have to get back to GM because of all your input...

Be-U-Tee-Full
Logged

Yeah.
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic