Computer Science Canada

pointless cool-looking program

Author:  Insectoid [ Wed Apr 16, 2008 4:18 pm ]
Post subject:  pointless cool-looking program

Well, I did this for fun, as an easy, cool-looking, useless thing to watch while I'm bored Very Happy
But I found some problems, and had to look up forking and processes and similar things. so, it helped me learn.
1 problem- music makes it lag. And you need a high refresh rate to see it well...

I also learned how to use music from this thing (from files and from cd's)

code:


var font : int := Font.New ("vivaldi:70")

% I'm leaving this out, as you won't have the right sound file...
%process music
%    loop
%        Music.PlayFile ("yoda.mp3")
%    end loop
%end music
%fork music



process background

    loop

        for x : 16 .. 31
            colorback (x)
            cls
            delay (100)
        end for

        for decreasing x : 31 .. 16
            colorback (x)
            cls
            delay (100)
        end for
    end loop
end background
fork background


process words
    loop
        for decreasing c : 31 .. 16
            Font.Draw ("Mellow...", 150, 200, font, c)
            delay (100)
        end for
        for c : 16 .. 31
            Font.Draw ("Mellow...", 150, 200, font, c)
            delay (100)
        end for
    end loop
end words
fork words


Author:  Sean [ Wed Apr 16, 2008 4:29 pm ]
Post subject:  RE:pointless cool-looking program

Question, why are you forking the other processes, why not make them procedures?

The forking is most efficent on music only.

Author:  Insectoid [ Wed Apr 16, 2008 4:32 pm ]
Post subject:  RE:pointless cool-looking program

Um, I haven't looked up procedures...
I asked my teacher what to use to make things run simultaneously, and he said 'fork'. Being the sub-par teacher he is, he said nothing else about it, and I had to find out for myself.

The song is actually a weird al yankovich parody called 'yoda'. Quite witty.

Author:  Sean [ Wed Apr 16, 2008 4:39 pm ]
Post subject:  RE:pointless cool-looking program

There is a tutorial available on Compsci. It's the best way to learn ahead of the class. Our school never got around to procedures.

Author:  Insectoid [ Wed Apr 16, 2008 4:57 pm ]
Post subject:  RE:pointless cool-looking program

Oh, I know, That's how I found out about processes...and music.....

Also, I read the whole 'omfg cool trippy flashes' sticky, but I maintain that this was a LEARNING EXPERIENCE in case anyone bugs me about it...

Author:  Tony [ Wed Apr 16, 2008 4:57 pm ]
Post subject:  Re: RE:pointless cool-looking program

insectoid @ Wed Apr 16, 2008 4:32 pm wrote:
he said 'fork'.

Do not use fork, it is not necessary, complicated, and often introduces bugs. Take a look through some of the tutorials available.

Author:  repsoccer16 [ Thu Apr 17, 2008 7:42 am ]
Post subject:  RE:pointless cool-looking program

this seems like a omfg cool trippy flashes but still a pretty good program.

Author:  Insectoid [ Thu Apr 17, 2008 8:23 am ]
Post subject:  RE:pointless cool-looking program

I said, it was a LEARNING EXPERIENCE!
Cut me some slack, man!

But then, it is fun to look at...

Author:  repsoccer16 [ Thu Apr 17, 2008 8:27 am ]
Post subject:  RE:pointless cool-looking program

settle down i wasn't trying to be mean or anything just making a heads up.

Author:  nastynika [ Thu Apr 17, 2008 8:35 am ]
Post subject:  Re: pointless cool-looking program

nice program good work

Author:  andrew. [ Fri Apr 18, 2008 8:53 pm ]
Post subject:  Re: pointless cool-looking program

I was bored so I redid your code to get rid of the forks. It's all in one main loop. This is what you should've done in the first place.

Turing:
setscreen ("graphics:nobuttonbar,offscreenonly")
var font : int := Font.New ("vivaldi:70")
var x, c, x_increase, c_increase : int := 1
x := 17
c := 30

% I'm leaving this out, as you won't have the right sound file...
%process music
%    loop
%        Music.PlayFile ("yoda.mp3")
%    end loop
%end music
%fork music



loop
    x += x_increase
    c += c_increase
    if x >= 30 then
        x_increase := -1
    elsif c <= 17 then
        c_increase := 1
    elsif x < 17 then
        x_increase := 1
    elsif c > 30 then
        c_increase := -1
    end if
    cls
    colorback (x)
    Font.Draw ("Mellow...", 150, 200, font, c)
    View.Update
    delay (100)
end loop

Author:  syntax_error [ Sat Apr 19, 2008 5:42 am ]
Post subject:  Re: RE:pointless cool-looking program

Sean @ Wed Apr 16, 2008 4:29 pm wrote:
Question, why are you forking the other processes, why not make them procedures?

The forking is most efficent on music only.


Correct me if I am wrong but, nowadays you do not even need forks for music there are pre-built functions for it already? no?

Author:  Sean [ Sat Apr 19, 2008 6:38 am ]
Post subject:  RE:pointless cool-looking program

You still need to fork the music if you want it to continue running. There are numerous sound inputs, his example of an .mp3 is an example of one that needs music.

Turing:

process DoMusic
    loop
       Music.PlayFile ("JumpOnIt.mp3")
    end loop
end DoMusic

fork DoMusic


As far as I know, you need to fork it if you want it to continuously play throughout the program, without forking it, it will only play the music once, and then stop. He wants it to continue, thus resulting in the Fork being added.

Author:  Nick [ Sat Apr 19, 2008 11:16 am ]
Post subject:  RE:pointless cool-looking program

not according to Turing help,

code:
        Music.PlayFileReturn ("branden3.wav")
        var x, y, clr : int
        loop
            x := Rand.Int (0, maxx)
            y := Rand.Int (0, maxy)
            clr := Rand.Int (0, maxcolor)
            Draw.FillOval (x, y, 30, 30, clr)
            exit when hasch
        end loop
        Music.PlayFileStop

Author:  chrisbrown [ Sat Apr 19, 2008 11:38 am ]
Post subject:  Re: pointless cool-looking program

An even better way:
Turing:

setscreen ("graphics;nobuttonbar;offscreenonly")
var font : int := Font.New ("vivaldi:70")
var x, c : int := 1
x := maxcolor
c := maxcolor - 1

loop
    for i : 0 .. 360
        RGB.SetColor (x, (1 + sind (i)) / 2, (1 + sind (i)) / 2, (1 + sind (i)) / 2)
        RGB.SetColor (c, (1 + cosd (i + 90)) / 2, (1 + cosd (i + 90)) / 2, (1 + cosd (i + 90)) / 2)
        cls
        colorback (x)
        Font.Draw ("Mellow...", 150, 200, font, c)
        View.Update
        delay (5)
    end for
end loop


: