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

Username:   Password: 
 RegisterRegister   
 matrix text
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shoobyman




PostPosted: Tue Nov 21, 2006 6:42 pm   Post subject: matrix text

some basic matrix text. I think its cool

code:

View.Set ("offscreenonly")
var symbol : array 1 .. 300 of string
var symx, symy, symspeed : array 1 .. 300 of int
var font1, font2, font3, font4, symrand : int

for i : 1 .. 300
    randint (symrand, 1, 5)
    if symrand = 1 then
        symbol (i) := "M"
    elsif symrand = 2 then
        symbol (i) := "Y"
    elsif symrand = 3 then
        symbol (i) := "Z"
    elsif symrand = 4 then
        symbol (i) := "X"
    elsif symrand = 5 then
        symbol (i) := "E"
    end if
    randint (symx (i), 1, maxx)
    randint (symy (i), maxy, maxy + maxy)
    randint (symspeed (i), 5, 10)
end for

font1 := Font.New ("Copperplate Gothic Bold:5:bold")
assert font1 > 0
font2 := Font.New ("sans serif:18:bold")
assert font2 > 0
font3 := Font.New ("mono:9")
assert font3 > 0
font4 := Font.New ("Palatino:24:bold,italic")
assert font4 > 0

loop
    View.Update
    delay (10)
    cls
    drawfillbox (0, 0, maxx, maxy, 7)
    for i : 1 .. 300
        Font.Draw (symbol (i), symx (i), symy (i), font1, 10)
        Font.Draw (symbol (i), symx (i), symy (i) + 15, font1, 2)
        if symspeed (i) > 6 then
            Font.Draw (symbol (i), symx (i), symy (i) + 30, font1, 144)
        end if
        symy (i) -= symspeed (i)
        if symy (i) < -35 then
            randint (symrand, 1, 5)
            if symrand = 1 then
                symbol (i) := "M"
            elsif symrand = 2 then
                symbol (i) := "Y"
            elsif symrand = 3 then
                symbol (i) := "Z"
            elsif symrand = 4 then
                symbol (i) := "X"
            elsif symrand = 5 then
                symbol (i) := "E"
            end if
            randint (symx (i), 1, maxx)
            randint (symy (i), maxy, maxy + maxy)
            randint (symspeed (i), 5, 10)
        end if
    end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
DKNiGHTX




PostPosted: Tue Nov 21, 2006 8:25 pm   Post subject: (No subject)

Hah! I was just making one of these in computer class, but this one totally owns mine! I never thought of doing it the way you did. Nice Wink (If you change 300 to 1000 and setscreen it to graphics:max;max its perplexing Wink)
ericfourfour




PostPosted: Tue Nov 21, 2006 8:37 pm   Post subject: (No subject)

First of all, stay away from randint. I have no clue why it is still taught in school or even included in the Turing programming language. Instead use
code:
num := Rand.Int (1, 10)


This following chunk of code is written twice. Instead put it into a procedure and call the procedure twice,
code:
for i : 1 .. 300
    randint (symrand, 1, 5)
    if symrand = 1 then
        symbol (i) := "M"
    elsif symrand = 2 then
        symbol (i) := "Y"
    elsif symrand = 3 then
        symbol (i) := "Z"
    elsif symrand = 4 then
        symbol (i) := "X"
    elsif symrand = 5 then
        symbol (i) := "E"
    end if
    randint (symx (i), 1, maxx)
    randint (symy (i), maxy, maxy + maxy)
    randint (symspeed (i), 5, 10)
end for
wtd




PostPosted: Wed Nov 22, 2006 2:54 am   Post subject: (No subject)

ericfourfour wrote:
code:
    if symrand = 1 then
        symbol (i) := "M"
    elsif symrand = 2 then
        symbol (i) := "Y"
    elsif symrand = 3 then
        symbol (i) := "Z"
    elsif symrand = 4 then
        symbol (i) := "X"
    elsif symrand = 5 then
        symbol (i) := "E"
    end if


Additionally, this conditional is utterly unnecessary. It can easily be avoided by thinking about the logic going on.

code:
var possible_letters : string := "MYZXE"
symbol (i) := possible_letters (Rand.Int (1, 5))


Or, in keeping with the conditional, but simpler, you may wish to employ a "case" statement.
Shyfire




PostPosted: Wed Nov 22, 2006 10:09 pm   Post subject: (No subject)

great job i like it
but....
wtd has a very good point
lilmizeminem




PostPosted: Thu May 24, 2007 11:03 am   Post subject: RE:matrix text

this is actually cool.
i know that no one has posted on this for a while..
but i just saw this now llol
Tallguy




PostPosted: Thu May 24, 2007 11:58 am   Post subject: Re: matrix text

DUDE,this is so tripey, its pretty cool Surprised
StealthArcher




PostPosted: Thu May 24, 2007 12:09 pm   Post subject: RE:matrix text

Major necromancy going on here...
Sponsor
Sponsor
Sponsor
sponsor
MichaelM




PostPosted: Thu Jun 07, 2007 6:33 pm   Post subject: Re: matrix text

woa Shocked
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: