
-----------------------------------
recyclebin123
Sun May 08, 2005 11:38 am

help with buttons
-----------------------------------
can some1 plz help.....i cant get my buttons to workout rite...when u click stop on the second one it doesnt work and when u click next on the second one it does not move onto the third one

-----------------------------------
jamonathin
Sun May 08, 2005 1:17 pm


-----------------------------------
Here it is, just press and hold for a second to get to the next step.  The programming isn't pretty (that's your job) I just fixed it for you, now just organize it.

And for the record, process and proc's are very different.  (one works)

setscreen ("graphics")
var font1 : int := Font.New ("Arial:12")
var finished1, finished2, stopall : boolean := false
var mouse_x, mouse_y, button : int


process DoMusic
    loop
        exit when finished1 or finished2 or stopall
        Music.PlayFile ("123.MP3")
    end loop
end DoMusic

procedure bar
    drawbox (0, 0, 50, 25, black)
    Font.Draw ("Stop", 10, 6, font1, 16)
    drawline (0, 30, maxx, 30, black)
    drawbox (590, 0, 639, 25, black)
    Font.Draw ("Next", 598, 6, font1, 16)
end bar

proc one_theme
    var touch, cont : int := 0
    colorback (10)
    cls
    bar
    loop
        mousewhere (mouse_x, mouse_y, button)
        locate (1, 1)
        put mouse_x, " ", mouse_y ..
        if (button = 1) and (mouse_x > 0) and (mouse_x < 50)
                and (mouse_y > 0) and (mouse_y < 25) then
            stopall := true % set finished to true
            Music.PlayFileStop % stop the music
            exit
        elsif (button = 1) and (mouse_x > 590) and (mouse_x < 639)
                and (mouse_y > 0) and (mouse_y < 25) then
            finished1 := true
            cls
            bar
            exit
        end if
        if (touch = 0) then
            drawline (640 div 2, 480 div 2, Rand.Int (1, 640), Rand.Int (30, 480), red)
            cont += 1
            if cont = 50000 then
                touch := 1
                cont := 0
            end if
        elsif (touch = 1) then
            drawline (640 div 2, 480 div 2, Rand.Int (1, 640), Rand.Int (30, 480), green)
            cont += 1
            if cont = 50000 then
                touch := 2
                cont := 0
            end if
        elsif (touch = 2) then
            drawline (640 div 2, 480 div 2, Rand.Int (1, 640), Rand.Int (30, 480), blue)
            cont += 1
            if cont = 50000 then
                touch := 3
                cont := 0
            end if
        elsif (touch = 3) then
            drawline (640 div 2, 480 div 2, Rand.Int (1, 640), Rand.Int (30, 480), yellow)
            cont += 1
            if cont = 50000 then
                touch := 0
                cont := 0
            end if
        end if
    end loop
end one_theme
proc second_theme
    colorback (yellow)
    cls
    bar
    drawfillbox (0, 40, 640, 490, 43)
    delay (500)
    loop
        mousewhere (mouse_x, mouse_y, button)
        if (button = 1) and (mouse_x > 0) and (mouse_x < 50)
                and (mouse_y > 0) and (mouse_y < 25) then
            stopall := true % set finished to true
            Music.PlayFileStop % stop the music
            exit
        elsif (button = 1) and (mouse_x > 590) and (mouse_x < 639)
                and (mouse_y > 0) and (mouse_y < 25) then
            finished2 := true
            cls
            bar
            exit
        end if
        drawfilloval (400, 200, 80, 80, white)
        drawoval (400, 200, 80, 80, black)
        drawfilloval (450, 200, 30, 30, black)
        for c : 0 .. 200
            drawfillbox (680 - c, 180, 680 - c, 210, 89)
            delay (5)
        end for
        drawfilloval (490, 250, 5, 5, blue)
        drawfilloval (490, 150, 5, 5, blue)
        drawfilloval (500, 130, 5, 5, blue)
        drawfilloval (500, 280, 5, 5, blue)
        drawfilloval (510, 265, 5, 5, blue)
        drawfilloval (510, 140, 5, 5, blue)
        for c : 0 .. 200
            drawfillbox (680 - 200 + c, 180, 680 - 200 + c, 210, 43)         %....finger
            delay (2)
        end for
        drawfilloval (490, 250, 5, 5, 43)
        drawfilloval (490, 150, 5, 5, 43)
        drawfilloval (500, 130, 5, 5, 43)
        drawfilloval (500, 280, 5, 5, 43)
        drawfilloval (510, 265, 5, 5, 43)
        drawfilloval (510, 140, 5, 5, 43)
    end loop
end second_theme

proc third_theme
    colorback (grey)
    cls
    bar
    delay (500)
    loop
        mousewhere (mouse_x, mouse_y, button)
        if (button = 1) and (mouse_x > 0) and (mouse_x < 50)
                and (mouse_y > 0) and (mouse_y < 25) then
            Music.PlayFileStop             % stop the music
            exit
        elsif (button = 1) and (mouse_x > 590) and (mouse_x < 639)
                and (mouse_y > 0) and (mouse_y < 25) then
            exit
        end if
        Draw.Dot ((Rand.Int (0, maxx)), (Rand.Int (30, maxx)), white)
        Draw.Dot ((Rand.Int (0, maxx)), (Rand.Int (30, maxx)), green)
        Draw.Dot ((Rand.Int (0, maxx)), (Rand.Int (30, maxx)), 144)
    end loop
end third_theme

fork DoMusic

%i think procedure and process are the same, i'm not sure : wrong - jamonathin
one_theme
if stopall = false then
    second_theme
end if
if stopall = false then
    third_theme
end if


-----------------------------------
recyclebin123
Sun May 08, 2005 2:32 pm


-----------------------------------
wow..thanks a bunch =)......also i got another problem....when u click next on the last theme it ends...i need it to loop back to the first theme which i do not know how..also i just remembered that i needed a different music for each theme which i also do not know how to add in

-----------------------------------
mercuryy
Sun May 08, 2005 4:25 pm


-----------------------------------
I am doing a program that has the similar structure. I want to put a menu in front of the first screensaver. and is there anyway that i can use the mouse to click back to the menu after I view all the screensaver?

-----------------------------------
jamonathin
Sun May 08, 2005 7:13 pm


-----------------------------------
This should answer all of your questions.  This program can be easily edited, so make more slides and add them on. :idea:  

setscreen ("graphics:500;400,nobuttonbar,position:center;center,offscreenonly,title:Remember - Jamonathin Made This . . .    :P")
colorback (black)
cls
var mx, my, mz : int %Mouse Variables
var a, b, c, d : array 1 .. 4 of int
for i : 1 .. 4
    a (i) := 100 + ((i - 1) * 80) %Lower Left Hand Corner Of Button - X
    b (i) := 20 %Lower Left Hand Corner Of Button - Y
    c (i) := 150 + ((i - 1) * 80) %Top Right Hand Corner Of Button - X
    d (i) := 50 %Top Right Hand Corner Of Button - Y
end for
var font : int := Font.New ("Comic Sans MS:12:bold")
var text : array 1 .. 4 of string := init ("Back", "Pause", "Exit", "Next")
var text_x : array 1 .. 4 of int := init (105, 185, 270, 345)

%Used To Determine Which Screen Saver is Shown
var selection : int := 1
%Used To Determine Which Option Is Made
var option : int := 0
%Used To Tell Computer The Max Amount Of Screen Savers
var maxslide : int := 3

% SCREEN SAVER 1
procedure screensaver_1
    drawline (maxx div 2, maxy div 2, Rand.Int (0, maxx), Rand.Int (55, maxy), Rand.Int (1, maxcolor))
end screensaver_1

%SCREEN SAVER 2
var box : int := maxx - 50
var q : int := -1
procedure screensaver_2
    drawfillbox (0, 55, maxx, maxy, black) %Instead of doing cls
    drawfilloval (100, 200, 80, 80, white) %The Eye (you made it so figure it out :P)
    drawoval (100, 200, 80, 80, black)
    drawfilloval (150, 200, 30, 30, black)
    if box - 20  maxx - 50 then %Reversing Direction Of Finger
        q *= -1
    end if
    box += q * 3 %Always Moving Finger
    drawfillbox (box, 185, box + 200, 215, 89) %Drawing Finger/Hand
    drawfillbox (box + 120, 125, maxx + 5, 225, 89)
    drawfilloval (box + 120, 170, 15, 15, 89)
    drawfilloval (box + 120, 140, 15, 15, 89)
    drawfilloval (box + 120, 210, 15, 15, 89)
    drawfilloval (box, 200, 20, 15, 89)
    if box  0 then
        drawfillbox (0, 55, maxx, maxy, black)
        selection *= -1
    end if
    %Screen Saver 2
    if selection = -1 then
        screensaver_1
        delay (5)
    end if
    %Screen Saver 2
    if selection = -2 then
        screensaver_2
        delay (10)
    end if
    %Screen Saver 3
    if selection = -3 then
        screensaver_3
        delay (5)
    end if
    %Finding out Which Option Is Made
    for i : 1 .. 4
        Font.Draw (text (i), text_x (i), 30, font, 10) %Drawing All 4 texts
        drawbox (a (i), b (i), c (i), d (i), white) %Drawing All 4 Boxes
        if mx >= a (i) and my >= b (i) and mx = a (i) and my >= b (i) and mx 