All pastes #193063 Raw Edit

Something

public text v1 · immutable
·published 2006-10-06 15:07 UTC
rendered paste body
View.Set ("graphics:max,max")
View.Set ("offscreenonly")
var size : int := 50
var mx, my, mb : int
var collidex, collidey : int := 0
var ballx, bally : int := 200
var dirx, diry : int := 0
var ballSpeed : int := 4
var hit : string := "no"
var ballcount := 5
var over : int := 0
var hitcount : int := 0
var col : int



% Ball direction after it hits paddle
% Change ball Speed
% Levels ??
% balls left
% Paddle size
% Score...box count
%  Obsticles  (Difficult)

dirx := ballSpeed    %dirx moves the ball left or right   -  ballspeed is the number of pixels it moves
diry := ballSpeed    %diry moves the ball up or down   -  ballspeed is the number of pixels it moves

loop
    randint (col, 1, maxcol)

    drawfillbox (maxx, 1, 1, maxy, col)



    for x : 100 .. 800 by 100 %  draws the bricks every 100 pixels
        for y : 300 .. 600 by 100
            drawfillbox (x, y, x + 50, y + 30, red) %  the bricks are 50 pixels wide  by 30 pixels high
        end for
    end for

    for x : 100 .. 800 by 200 %  draws the bricks every 100 pixels
        drawfillbox (x, 200, x + 50, 210, yellow)   %  the bricks are 50 pixels wide  by 30 pixels high
    end for


    loop

        locate (1, 60)
        put "Your hit count is ", hitcount
        if over = 1 then
            exit
        end if
        locate (2, 1)
        put "You Have ", ballcount - 1, " Balls Left."
        if hitcount = 32 then
            exit
        end if
        %delay (3)
        mousewhere (mx, my, mb)
        drawfillbox (mx - size, 0, mx + size, 15, black) % draws the paddle
        drawfillbox (mx - size - 1, 0, 0, 50, col)   % erases where the paddle used to be
        drawfillbox (maxx, 0, mx + size + 1, 50, col) % erases where the paddle used to be
        drawfilloval (ballx, bally, 15, 15, col) % erases where the ball used to be
        ballx += dirx %current x location of the ball...the ball is being moved left or right depending on the value of dirx
        bally += diry %current y location of the ball...the ball is being moved up or down depending on the value of diry
        drawfilloval (ballx, bally, 15, 15, blue) % draws the ball
        if ballx >= maxx then % right wall - ball will travel left after it gets to the edge of the screen
            dirx := - (dirx)
        elsif bally >= maxy then % top wall - ball will travel down after it gets to the edge of the screen
            diry := - (diry)
        elsif ballx <= 0 then % left wall- ball will travel right after it gets to the edge of the screen
            dirx := - (dirx)
        elsif bally <= 0 then % bottom of screen  --Life is lost
            diry := - (diry)
            locate (1, 20)
            put "You Lost A Ball!"
            sound (250, 200)
            ballcount -= 1
            if ballcount = 0 then
                over += 1
                exit
            end if
            ballx := 200 % resets starting location of ball
            bally := 200
            loop
                mousewhere (mx, my, mb) % doesnt restart until mouse is clicked
                exit when mb = 1
            end loop
        end if
        %paddle collision - ball bounces up when it hits paddle
        if ballx > mx - size and ballx < mx + size and bally <= 30 then
            sound (700, 10)
            diry := - (diry)

        end if

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %  The following for loop checks to see if the ball touches any of the bricks.  It checks all four   %
        %  'sides' of the circle.  If the circle touches a brick the current x and y location of the ball    %
        %  is divided by 100 then multiplied by 100 in order to draw a box over the brick hit.               %
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        for i : 1 .. 30 % top of ball

            if whatdotcolour (ballx - 15 + i, bally - 16) = yellow then
                sound (400, 10)
                for x : 100 .. 800 by 200 %  draws the bricks every 100 pixels
                    drawfillbox (x, 200, x + 50, 210, yellow)
                end for
                diry := - (diry) %top
                exit
            end if
            if whatdotcolour (ballx - 15 + i, bally + 16) = yellow then
                sound (400, 10)
                for x : 100 .. 800 by 200 %  draws the bricks every 100 pixels
                    drawfillbox (x, 200, x + 50, 210, yellow)
                end for
                diry := - (diry) %top
                exit
            end if

            if whatdotcolour (ballx + 16, bally - 15 + i) = yellow then
                sound (400, 10)
                for x : 100 .. 800 by 200 %  draws the bricks every 100 pixels
                    drawfillbox (x, 200, x + 50, 210, yellow)
                end for
                dirx := - (dirx) %top
                exit
            end if
            if whatdotcolour (ballx - 16, bally - 15 + i) = yellow then
                sound (400, 10)
                for x : 100 .. 800 by 200 %  draws the bricks every 100 pixels
                    drawfillbox (x, 200, x + 50, 210, yellow)
                end for
                dirx := - (dirx) %top
                exit
            end if




            if whatdotcolour (ballx - 15 + i, bally + 16) = red then
                collidex := (ballx - 15 + i) div 100
                collidey := (bally + 16 + diry) div 100
                collidex := collidex * 100
                collidey := collidey * 100
                drawfillbox (collidex, collidey, collidex + 50, collidey + 30, col)
                diry := - (diry) %top
                locate (1, 1)
                put "Hit Top"
                hitcount += 1
                sound (500, 10)
                exit
            end if
            if whatdotcolour (ballx - 15 + i, bally - 16) = red then
                collidex := (ballx - 15 + i) div 100
                collidey := (bally - 16 - diry) div 100
                collidex := collidex * 100
                collidey := collidey * 100
                drawfillbox (collidex, collidey, collidex + 50, collidey + 30, col)
                diry := - (diry) % bottom
                locate (1, 1)
                put "Hit Bottom"
                hitcount += 1
                sound (500, 10)
                exit
            end if
            if whatdotcolour (ballx + 16, bally - 15 + i) = red then
                collidex := (ballx + 16 + dirx) div 100
                collidey := (bally - 15 + i) div 100
                collidex := collidex * 100
                collidey := collidey * 100
                drawfillbox (collidex, collidey, collidex + 50, collidey + 30, col)
                dirx := - (dirx) % Right
                locate (1, 1)
                put "Hit Right"
                hitcount += 1
                sound (500, 10)
                exit
            end if
            if whatdotcolour (ballx - 16, bally - 15 + i) = red then
                collidex := (ballx - 16 - dirx) div 100
                collidey := (bally - 15 + i) div 100
                collidex := collidex * 100
                collidey := collidey * 100
                drawfillbox (collidex, collidey, collidex + 50, collidey + 30, col)
                dirx := - (dirx) % left
                locate (1, 1)
                put "Hit Left"
                hitcount += 1
                sound (500, 10)
                exit
            end if
        end for
        View.Update
    end loop
            if over = 1 then
            exit
        end if
                if hitcount = 32 then
            exit
        end if
end loop
cls
locate (24, 50)
if hitcount = 32 then
    put "You Won!!"
else
    put "Game Over"
end if