
-----------------------------------
orangelover55
Wed Dec 02, 2009 7:01 pm

make thing go up and down. make programs less glitchy.
-----------------------------------
kay so i have this program. and i'am wondering how to make the balls that go sideways to go up and down and i was wondering how to make this program less glitchy.

here is the program:


import GUI
var row : int
var picnum : int
row := 19
setscreen ("graphics : 720;450")
var x1 := 300
var y1 := 1
var x2 := 290
var x3 := 310
var x4 := 300
var y2 := 20
var y3 := 19
var y4 := 18
var y5 := 17
var y11 := 16
var y12 := 15
var y13 := 14
var y14 := 13
var y15 := 12
var y16 := 11
var y17 := 10
var x6 := 600
var x7 := 700
var x8 := 800
var y6 := 200
var y7 := 0
var y8 := 300
var y9 := 0
var y10 := 400
var Yb :int
var getkey : array char of boolean
var answer : string
var count : int := 3
procedure oval
    x6 := x6 - 10
    delay (10)

end oval



loop

    x1 := 300
    y1 := 1
    x2 := 290
    x3 := 310
    x4 := 300
    y2 := 20
    y3 := 19
    y4 := 18
    y5 := 17
    y11 := 16
    y12 := 15
    y13 := 14
    y14 := 13
    y15 := 12
    y16 := 11
    y17 := 10
    x6 := 600
    x7 := 700
    x8 := 800
    y6 := 900
    y7 := 0
    y8 := 300
    y9 := 0
    y10 := 400
    Yb := 399
    count := count
    loop

        drawfillbox (0, 900, 800, 1, 176)
        drawfillbox (0, 70, 800, 1, 10)
        drawfilloval (400, 350, 50, 50, 18)
        drawfilloval (350, 350, 50, 50, 18)
        drawfilloval (300, 350, 50, 50, 18)
        drawfilloval (250, 350, 50, 50, 18)
        drawfilloval (200, 350, 50, 50, 18)
        drawfilloval (150, 350, 50, 50, 18)
        drawfilloval (100, 350, 50, 50, 18)
        drawfilloval (50, 350, 50, 50, 18)
        drawfilloval (450, 350, 50, 50, 18)
        drawfilloval (500, 350, 50, 50, 18)
        drawfilloval (550, 350, 50, 50, 18)
        drawfilloval (600, 350, 50, 50, 18)
        drawfilloval (650, 350, 50, 50, 18)
        drawfilloval (0, 350, 50, 50, 18)


        drawfillarc (x1, y1, 30, 30, 360, 180, 0)
        drawfilloval (x2, y2, 5, 5, white)
        drawfilloval (x2, y2, 3, 3, black)
        drawfilloval (x3, y2, 5, 5, white)
        drawfilloval (x3, y2, 3, 3, black)
        drawfilloval (x4, y3, 3, 3, 42)
        drawfilloval (x4, y4, 3, 3, 42)
        drawfilloval (x4, y5, 3, 3, 42)
        drawfilloval (x4, y11, 3, 3, 42)
        drawfilloval (x4, y12, 3, 3, 42)
        drawfilloval (x4, y13, 3, 3, 42)
        drawfilloval (x4, y14, 3, 3, 42)
        drawfilloval (x4, y15, 3, 3, 42)
        drawfilloval (x4, y16, 3, 3, 42)
        drawfilloval (x4, y17, 3, 3, 42)




        drawfilloval (x6, y6, 20, 20, grey)
        delay (1)
        drawfilloval (x6, y8, 20, 20, grey)
        delay (1)

        if x6 = 10 then
            randint (y7, 125, 225)
            randint (y9, 225, 325)
%balls
            x6 := 700
            y6 := y7
            y8 := y9
            

        end if

        oval
        drawfillbox (0, 900, 800, 1, 176)
        drawfillbox (0, 70, 800, 1, 10)
        drawfilloval (400, 350, 50, 50, 18)
        drawfilloval (350, 350, 50, 50, 18)
        drawfilloval (300, 350, 50, 50, 18)
        drawfilloval (250, 350, 50, 50, 18)
        drawfilloval (200, 350, 50, 50, 18)
        drawfilloval (150, 350, 50, 50, 18)
        drawfilloval (100, 350, 50, 50, 18)
        drawfilloval (50, 350, 50, 50, 18)
        drawfilloval (450, 350, 50, 50, 18)
        drawfilloval (500, 350, 50, 50, 18)
        drawfilloval (550, 350, 50, 50, 18)
        drawfilloval (600, 350, 50, 50, 18)
        drawfilloval (650, 350, 50, 50, 18)
        drawfilloval (0, 350, 50, 50, 18)



        Input.KeyDown (getkey)
        if getkey (KEY_UP_ARROW) then
            y1 := y1 + 5
            y2 := y2 + 5
            y3 := y3 + 5
            y4 := y4 + 5
            y5 := y4 + 5
            y11 := y11 + 5
            y12 := y12 + 5
            y13 := y13 + 5
            y14 := y14 + 5
            y15 := y15 + 5
            y16 := y16 + 5
            y17 := y17 + 5

        end if
        if getkey (KEY_DOWN_ARROW) then
            y1 := y1 - 5
            y2 := y2 - 5
            y3 := y3 - 5
            y4 := y4 - 5
            y5 := y5 - 5
            y11 := y11 - 5
            y12 := y12 - 5
            y13 := y13 - 5
            y14 := y14 - 5
            y15 := y15 - 5
            y16 := y16 - 5
            y17 := y17 - 5
        end if
        if getkey (KEY_LEFT_ARROW) then
            x1 := x1 - 5
            x2 := x2 - 5
            x3 := x3 - 5
            x4 := x4 - 5


        end if
        if getkey (KEY_RIGHT_ARROW) then
            x1 := x1 + 5
            x2 := x2 + 5
            x3 := x3 + 5
            x4 := x4 + 5

        end if


        drawfillbox (0, 900, 800, 1, 176)
        drawfillbox (0, 70, 800, 1, 10)
        drawfilloval (400, 350, 50, 50, 18)
        drawfilloval (350, 350, 50, 50, 18)
        drawfilloval (300, 350, 50, 50, 18)
        drawfilloval (250, 350, 50, 50, 18)
        drawfilloval (200, 350, 50, 50, 18)
        drawfilloval (150, 350, 50, 50, 18)
        drawfilloval (100, 350, 50, 50, 18)
        drawfilloval (50, 350, 50, 50, 18)
        drawfilloval (450, 350, 50, 50, 18)
        drawfilloval (500, 350, 50, 50, 18)
        drawfilloval (550, 350, 50, 50, 18)
        drawfilloval (600, 350, 50, 50, 18)
        drawfilloval (650, 350, 50, 50, 18)
        drawfilloval (0, 350, 50, 50, 18)









      
        if x6 = x4 and y6 = y3 then
            count := count - 1
            exit
        elsif x6 = x4 and y6 = y4 then
            count := count - 1
            exit
        elsif x6 = x4 and y8 = y3 then
            count := count - 1
            exit
        elsif x6 = x4 and y8 = y4 then
            count := count - 1
            exit




        elsif x6 = x4 and y6 = y5 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y5 then
            count := count - 1
            exit

        elsif x6 = x4 and y6 = y11 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y11 then
            count := count - 1
            exit

        elsif x6 = x4 and y6 = y12 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y12 then
            count := count - 1
            exit

        elsif x6 = x4 and y6 = y13 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y13 then
            count := count - 1
            exit

        elsif x6 = x4 and y6 = y14 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y14 then
            count := count - 1

            exit

        elsif x6 = x4 and y6 = y15 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y15 then
            count := count - 1

            exit

        elsif x6 = x4 and y6 = y16 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y16 then
            count := count - 1

            exit

        elsif x6 = x4 and y6 = y17 then
            count := count - 1
            exit

        elsif x6 = x4 and y8 = y17 then
            count := count - 1
            exit
        end if


    end loop

    put "Play Again? y/n"
    put "Lives:", count
    get answer

    if answer = "n" then

        exit
    end if
    cls
    if count = 0 then
        cls
        delay (500)
        locate (10, 40)
        put "OH NO!!!"
        delay (1000)
        cls
        locate (10, 40)
        put "GAME OVER!!!!!!!!!!!!!!!!!!!"
        delay (1000)
        exit
    end if
end loop

procedure ending
    cls
    delay (1000)
    locate (10, 33)
    put "THANK YOU FOR PLAYING SULLY'S ADVENTURE!"

    delay (1500)
    cls
    locate (10, 33)
    put "SEE YOU NEXT TIME!!"
    delay (1000)

    drawfillarc (300, 1, 30, 30, 360, 180, 120)
    drawfilloval (290, 20, 5, 5, white)
    drawfilloval (290, 20, 3, 3, black)
    drawfilloval (310, 20, 5, 5, white)
    drawfilloval (310, 20, 3, 3, black)
    delay (2000)
    cls
    locate (10, 35)
    put "THE END"
    drawfillarc (300, 1, 30, 30, 360, 180, 120)
    drawfilloval (290, 20, 5, 5, white)
    drawfilloval (290, 20, 3, 3, black)
    drawfilloval (310, 20, 5, 5, white)
    drawfilloval (310, 20, 3, 3, black)


end ending

var end1 : int := GUI.CreateButtonFull (300, 210, 0, "END GAME", ending, 0, '^D', true)
loop
    exit when GUI.ProcessEvent
end loop
 
PLEASE HELP!!!

-----------------------------------
Zren
Wed Dec 02, 2009 7:24 pm

RE:make thing go up and down. make programs less glitchy.
-----------------------------------
First let's get rid of the flickering. Read up on View.Update: http://compsci.ca/v3/viewtopic.php?t=12533

-----------------------------------
Tony
Wed Dec 02, 2009 8:57 pm

RE:make thing go up and down. make programs less glitchy.
-----------------------------------
I'd suggest investing some time into getting to know [tdoc]array[/tdoc]s and [tdoc]for[/tdoc] loops instead.
