Thursday, 13 June 2013

June 12-Success!

Today was very fruitful. I had fixed my second level code with the help with Mr. Van Rooyen.  I learned that  I need to change the vector of the ball that bounces first; the numball. After it bounces off the right wall, that ball as well as the new ball has different vectors so that it maintains its bouncing.
I need to now incorporate it into my overall game code.
I must think about making a boolean that will cover all levels and make the overall code more effecient.
Next Step is to make a 3rd level.
My Code View.Set ("graphics,offscreenonly")
var NumBall2 : int
NumBall2 := 1
var Ballx : array 1 .. 1000 of int
var Bally : array 1 .. 1000 of int
randint (Ballx (NumBall2), 0, maxx)
randint (Bally (NumBall2), 0, maxy)
var Balldirx : array 1 .. 1000 of int
var Balldiry : array 1 .. 1000 of int
Balldirx (1) := -1
Balldiry (1) := 1
loop
    cls
    for d : 1 .. NumBall2
        drawfilloval (Ballx (d), Bally (d), 9, 9, green)
        Ballx (d) := Ballx (d) + Balldirx (d)
        if Ballx (d) - 9 = 9 then
            Balldirx (d) := Balldirx (d) * -1
        elsif Ballx (d) + 9 >= maxx - 9
                then
            Balldirx (d) := -1 * Balldirx (d)
            NumBall2 := NumBall2 + 1
            randint (Ballx (NumBall2), 0, maxx)
            randint (Bally (NumBall2), 0, maxy)
            Balldirx (NumBall2) := -1
            Balldiry (NumBall2) := 1
   
             end if
        Bally (d) := Bally (d) + Balldiry (d)
        if Bally (d) >= maxy - 9
                then
            Balldiry (d) := -1 * Balldiry (d)
        elsif Bally (d) <= 9
                then
            Balldiry (d) := 1
        end if
    end for
    View.Update
  delay (5)
end loop

No comments:

Post a Comment