Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Explain this code to me please!!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Angel




PostPosted: Sun Jan 04, 2004 8:56 pm   Post subject: Explain this code to me please!!!!

code:
var word := "W E L C O M E  T O  M O V I E  T R I V I A"
var height := 24
var font1 := Font.New ("raavi:" + intstr (height))
var x := (maxx - Font.Width (word, font1)) div 2
var y := (maxy - height) div 2
for rep : 1 .. length (word)
    delay (100)
    Draw.FillBox (x, y, x + Font.Width (word (rep), font1), y + height, black)
    Font.Draw (word (rep), x, y, font1, 13)
    x += (Font.Width (word (rep), font1))
end for


Please explain this? And how do I increase the size of the boxes? What do I have to alter?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Jan 04, 2004 10:29 pm   Post subject: (No subject)

you just expand the box... such as change
code:

Draw.FillBox (x, y, x + Font.Width (word (rep), font1), y + height, black)

to
code:

Draw.FillBox (x-5, y-5, x + Font.Width (word (rep), font1)+5, y + height +5, black)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dan




PostPosted: Sun Jan 04, 2004 10:35 pm   Post subject: (No subject)

code:

%%a basick string
var word := "W E L C O M E  T O  M O V I E  T R I V I A"

%% the high of the next
var height := 24

%% this is the font for Font.Draw, see turing docs for more info
var font1 := Font.New ("raavi:" + intstr (height))

%% this finds the center of the screen minuse the width of the string, see Font.Width
var x := (maxx - Font.Width (word, font1)) div 2

%% this finds the center of the screen minuse the hight of the text
var y := (maxy - height) div 2

%% a for loop that will go once for each char in the string
for rep : 1 .. length (word)

    %%bacik dealy
    delay (100)

    %%this draws a box from the vaule x and y (see above) to x plus the width
    %%of the substrinng word(rep) and y. rep is the index of the for loop so every time
    %%it runs it adds a char of the string word to the value. so the box gets biger
    Draw.FillBox (x, y, x + Font.Width (word (rep), font1), y + height, black)

    %%this wroks like the above where it uses substrings to draw more and more letters.
    %%word(1) whould be "W", word(5) whoudl be "W E L" and so on.
    %%so it draws one more char of the sting each time.
    Font.Draw (word (rep), x, y, font1, 13)

    %%this adds the length of the char that was added to x so the box will be biger next
    %%time round
    x += (Font.Width (word (rep), font1))

end for
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Angel




PostPosted: Mon Jan 05, 2004 10:46 pm   Post subject: (No subject)

Thank you! Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: