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

Username:   Password: 
 RegisterRegister   
 Ending A Process
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
josh




PostPosted: Wed Dec 29, 2004 4:39 pm   Post subject: Ending A Process

I am making a title screen for my final project (snake) and at the begining I start some music playing with this code:

code:

process music
    Music.PlayFile ("sound1.mp3")
end music
fork music


after the animation is done, I want the final screen to stay untill the user hits a key (I used Input.Pause). After the Input.Pause I want to stop the music playing, but I don't know how to end the process. I tried using Music.SoundOff but that did not work.

How can I do this?
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Wed Dec 29, 2004 6:41 pm   Post subject: (No subject)

return would work.

do something like:

if flag = true then
return
end if
josh




PostPosted: Wed Dec 29, 2004 7:11 pm   Post subject: (No subject)

where should I Put the return command.

I tried doing this:

code:

 setscreen ("graphics:800;600,offscreenonly,title:Snake Remix V1.0 Copyright 2004 by Josh Rosen,nocursor,noecho")
colourback (7)
cls

process music
    Music.PlayFile ("sound1.mp3")
end music

proc title_screen
    %Declare Variables Here
    var font1 : int %holds font1
    var font2 : int %holds font2
    var font3 : int %holds font3
    var x1, y1 : int %the x and y of the title
    var s1 : int    %holds the size of the title
    var x2, y2 : int %holds the x and y of josh's name
    var screenHist : int %holds a shot of the whole screen
    var a : int     %holds wheather or not to flash the title in the colours
    var b : boolean    %holds which message to flash
    var c : int     %holds wheather or not to change the value of d
    var d : boolean %holds wheather or not to decrease the delay
    var randx, randy : int %holds the random co-ordiantes for the flashes of the word

    %Initialize Variables and Fonts Here
    font1 := Font.New ("arial:24:bold")
    font3 := Font.New ("arial:14")
    x1 := 500
    y1 := 210
    s1 := 24
    x2 := 350
    y2 := 190
    b := true


    fork music
    %declare variables here
    var timer : int := 500

    for i : 35 .. 255
        randint (randx, 10, 750)
        randint (randy, 10, 550)
        a := i mod 5
        c := i mod 2
        if c = 0 then
            d := true
        elsif c > 0 then
            d := false
        end if
        colourback (i)
        cls
        if a = 0 then
            if b = true then
                Font.Draw ("Snake", randx, randy, font3, white)
                b := false
            elsif b = false then
                Font.Draw ("Remix", randx, randy, font3, white)
                b := true
            end if
        end if
        View.Update
        delay (timer)
        if timer > 10 and d = true then
            timer -= 10
        end if
    end for

    colourback (7)
    cls
    %loads the snake pics for a brief flash
    %loads the snake head on the right (open mouth)
    Pic.ScreenLoad ("snakehead1.1.jpg", 400, 100, picMerge)
    %loads the snake on the left (closed mouth)
    Pic.ScreenLoad ("snakehead2.1.jpg", 0, 120, picMerge)
    View.Update
    delay (10)

    %quickly flahsed the background again
    for i : 1 .. 10
        colourback (i)
        cls
        View.Update
    end for

    colourback (7)
    cls
    %loads the snake pics
    %loads the snake head on the right (open mouth)
    Pic.ScreenLoad ("snakehead1.1.jpg", 400, 100, picCopy)
    %loads the snake on the left (closed mouth)
    Pic.ScreenLoad ("snakehead2.1.jpg", 0, 120, picCopy)
    View.Update
    delay (100)
    %Make Words come out of Open Mouth
    loop
        cls
        x1 -= 10
        %loads the snake head on the right (open mouth)
        Pic.ScreenLoad ("snakehead1.1.jpg", 400, 100, picMerge)
        %loads the snake on the left (closed mouth)
        Pic.ScreenLoad ("snakehead2.1.jpg", 0, 120, picMerge)
        Font.Draw ("Snake Remix", x1, y1, font1, 9)
        View.Update
        exit when x1 = 300
    end loop

    %loads the snake head on the right (open mouth)
    Pic.ScreenLoad ("snakehead1.1.jpg", 400, 100, picMerge)
    %loads the snake on the left (closed mouth)
    Pic.ScreenLoad ("snakehead2.1.jpg", 0, 120, picMerge)
    Font.Draw ("Snake Remix", x1, y1, font1, 9)
    View.Update

    delay (200)
    %MAKE TITLE MOVE UP AND GET BIGGER
    loop
        y1 += 20
        x1 -= 15
        s1 += 3
        font2 := Font.New ("arial:" + intstr (s1) + ":bold")
        Font.Draw ("Snake Remix", x1, y1, font2, 9)
        View.Update
        Font.Free (font2)
        delay (10)
        exit when s1 = 60
    end loop
    font2 := Font.New ("arial:" + intstr (s1) + ":bold")
    Font.Draw ("Snake Remix", x1, y1, font2, 10)

    %Make Screen flash and then names appear

    %takes picture of the screen so it can be re-drawn after the flash
    screenHist := Pic.New (1, 1, 799, 599)

    cls
    View.Update
    Draw.FillBox (0, 0, 800, 600, yellow)
    View.Update
    delay (50)
    Pic.Draw (screenHist, 0, 0, picMerge)
    View.Update

    Font.Draw ("By: Josh Rosen and Misha Veprinsky", 150, 40, font1, 9)
    View.Update

    delay (2000)

    Font.Draw ("Press Enter to Continue", 300, 140, font3, 9)
    View.Update

    Input.Pause

    return
end title_screen

%call the procedure
title_screen


but it did not work, when I hit enter it still played the music, and it did not say program finished
josh




PostPosted: Wed Dec 29, 2004 7:13 pm   Post subject: (No subject)

Nevermind, I just used Music.PlayFileStop instead.
AsianSensation




PostPosted: Wed Dec 29, 2004 8:40 pm   Post subject: (No subject)

Yeah, I should have said it earlier, guess I forgot, sorry.

but things like this:
code:
var flag : boolean := false

process doSomething
    if flag = true then
        return
    end if
    put "Hello"
end doSomething

for rep : 1 .. 100
    put "Hi"
    fork doSomething
    if rep > 20 then
        flag := true
    end if
end for


return will terminates the process.
josh




PostPosted: Wed Dec 29, 2004 11:33 pm   Post subject: (No subject)

but the problem I had is it was a long audio file, so it would not finish playing the file, so it would not get to the if statement and the return for a while.

It was not looping audio, just this one long techno mix that I found.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: