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

Username:   Password: 
 RegisterRegister   
 bullet-time pong
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
do_pete




PostPosted: Wed Oct 05, 2005 11:44 am   Post subject: bullet-time pong

This is my first ever turing game. This game may not work on some computers for some strange reason. It used to have background music and sound effects but I couldn't attach those so this is just the program.
Please Tell me about any bugs, suggestion, or comments that you have.
Feel free to edit the code but please give me some credit or else...
code:

%                                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                  %%          PETER'S PONG v.1.12           %%
%                                  %%         Programed by Peter Do          %%
%                                  %%   Background Music by Aaron Liblong    %%
%                                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

const RADIUS : int := 10
const SLOWMAX : int := 500
const ACCELERATION : real := 0.2
const UP_ARROW : char := chr (200)
const LEFT_ARROW : char := chr (203)
const RIGHT_ARROW : char := chr (205)

%                                                GLOBAL VARIABLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var keys : array char of boolean
var right, left, Speed : int := 1
var RSpeed : real := 0.1
var a, b, c, d, m, s, x, y, cheats, cheats2, cheatsyes : int := 0
var rx, ry : real := 0.0
var BoxX1, BoxY1, BoxX2, BoxY2, WallPosition, Box2X1, Box2Y1, Box2X2, Box2Y2 : int := 200
var answer, answer2, answer3, answer4, Score, buttonnumber, buttonupdown : int := 0
var Score2, Score3 : string
var SlowMotion : int := 1000
var WallSpeed : int := 5
var RSlowMotion : real := 0
%                                                    FUNCTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Right (x : int) : int
    result x + Speed
end Right

function Left (x : int) : int
    result x - Speed
end Left

function Up (y : int) : int
    result y + Speed
end Up

function Down (y : int) : int
    result y - Speed
end Down

function RealRight (rx : real) : real
    result rx + 0.1
end RealRight

function RealLeft (rx : real) : real
    result rx - 0.1
end RealLeft

function RealUp (ry : real) : real
    result ry + 0.1
end RealUp

function RealDown (ry : real) : real
    result ry - 0.1
end RealDown

%                                                    PROCEDURES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

procedure CentreFont (s : string, x, y, f, clr : int)
    var w : int := Font.Width (s, f)
    Font.Draw (s, x - w div 2, y, f, clr)
end CentreFont

procedure YouLose
    var answer, AX1, AX2, BX1, BX2, Y1, Y2 : int

   

    Score2 := intstr (Score)

    Score3 := "Your score is " + Score2

    for decreasing c : 31 .. 16
        CentreFont ("YOU LOSE!", maxx div 2, maxy div 2 + 25, Font.New ("Impact:70:bold"), c)
        CentreFont (Score3, maxx div 2, maxy div 2 - 22, Font.New ("Impact:30"), c)
        View.Update
        delay (50)
    end for
    cls
    CentreFont ("YOU LOSE!", maxx div 2, maxy div 2 + 25, Font.New ("Impact:70:bold"), black)
    CentreFont (Score3, maxx div 2, maxy div 2 - 22, Font.New ("Impact:30"), black)
    View.Update

    AX1 := 275
    AX2 := 315

    BX1 := 325
    BX2 := 365

    Y1 := 115
    Y2 := 135

    delay (1000)
    for decreasing c2 : 31 .. 16
        CentreFont ("Would you like to quit?", maxx div 2, maxy div 2 + -50, Font.New ("Impact:14"), c2)
        CentreFont ("Yes        No", maxx div 2, maxy div 2 - 80, Font.New ("Impact:14"), c2)
        Draw.Box (AX1, Y1, AX2, Y2, c2)
        Draw.Box (BX1, Y1, BX2, Y2, c2)
        View.Update
        delay (50)
    end for


    Draw.Box (AX1, Y1, AX2, Y2, black)
    Draw.Box (BX1, Y1, BX2, Y2, black)
    View.Update

    loop
        var x, y, b : int := 0
        mousewhere (x, y, b)

        if x > AX1 and x < AX2 and y > Y1 and y < Y2 then
            Draw.Box (AX1, Y1, AX2, Y2, brightred)
            View.Update
            if b = 1 then
                answer3 := 1
                exit
            end if
        elsif x > BX1 and x < BX2 and y > Y1 and y < Y2 then
            Draw.Box (BX1, Y1, BX2, Y2, brightred)
            View.Update
            if b = 1 then
                answer3 := 2
                exit
            end if
        else
            Draw.Box (AX1, Y1, AX2, Y2, black)
            Draw.Box (BX1, Y1, BX2, Y2, black)
            View.Update
        end if
    end loop

    for c : 31 .. 16
        CentreFont ("YOU LOSE!", maxx div 2, maxy div 2 + 25, Font.New ("Impact:70:bold"), c)
        CentreFont (Score3, maxx div 2, maxy div 2 - 22, Font.New ("Impact:30"), c)
        CentreFont ("Would you like to quit?", maxx div 2, maxy div 2 + -50, Font.New ("Impact:14"), c)
        CentreFont ("Yes        No", maxx div 2, maxy div 2 - 80, Font.New ("Impact:14"), c)

        Draw.Box (AX1, Y1, AX2, Y2, c)
        Draw.Box (BX1, Y1, BX2, Y2, c)

        View.Update
        delay (50)

    end for



    m := 0
end YouLose

procedure SureQuit

    var answer, AX1, AX2, BX1, BX2, Y1, Y2 : int
    AX1 := 275
    AX2 := 315

    BX1 := 325
    BX2 := 365

    Y1 := 195
    Y2 := 215

    cls

    CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)

    for decreasing c : 31 .. 16
        CentreFont ("Are you sure you want to quit?", maxx div 2, maxy div 2 + +30, Font.New ("Impact:14"), c)
        CentreFont ("Yes        No", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
        Draw.Box (AX1, Y1, AX2, Y2, c)
        Draw.Box (BX1, Y1, BX2, Y2, c)
        View.Update
        delay (50)
    end for

    CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
    CentreFont ("Are you sure you want to quit?", maxx div 2, maxy div 2 + +30, Font.New ("Impact:14"), black)
    CentreFont ("Yes        No", maxx div 2, maxy div 2, Font.New ("Impact:14"), black)

    Draw.Box (AX1, Y1, AX2, Y2, black)
    Draw.Box (BX1, Y1, BX2, Y2, black)

    View.Update

    loop
        var x, y, b : int := 0
        mousewhere (x, y, b)

        if x > AX1 and x < AX2 and y > Y1 and y < Y2 then
            Draw.Box (AX1, Y1, AX2, Y2, brightred)
            View.Update
            if b = 1 then
                answer2 := 1
                exit
            end if
        elsif x > BX1 and x < BX2 and y > Y1 and y < Y2 then
            Draw.Box (BX1, Y1, BX2, Y2, brightred)
            View.Update
            if b = 1 then
                answer2 := 2
                exit
            end if
        else
            Draw.Box (AX1, Y1, AX2, Y2, black)
            Draw.Box (BX1, Y1, BX2, Y2, black)
            View.Update
        end if
    end loop
    if answer2 = 1 then
        for c : 16 .. 31
            CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), c)
            CentreFont ("Are you sure you want to quit?", maxx div 2, maxy div 2 + +30, Font.New ("Impact:14"), c)
            CentreFont ("Yes        No", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            Draw.Box (AX1, Y1, AX2, Y2, c)
            Draw.Box (BX1, Y1, BX2, Y2, c)
            View.Update
            delay (50)
        end for
    else
        for c : 16 .. 31
            CentreFont ("Are you sure you want to quit?", maxx div 2, maxy div 2 + +30, Font.New ("Impact:14"), c)
            CentreFont ("Yes        No", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            Draw.Box (AX1, Y1, AX2, Y2, c)
            Draw.Box (BX1, Y1, BX2, Y2, c)
            View.Update
            delay (50)
        end for
    end if
    m := 1
end SureQuit

procedure menu

    var X1, X2, AY1, AY2, BY1, BY2, CY1, CY2 : int
    X1 := 270
    X2 := 370

    AY1 := 225
    AY2 := 245

    BY1 := 195
    BY2 := 215

    CY1 := 185
    CY2 := 165

    cls

    if m = 0 then
        for decreasing c : 31 .. 16
            CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), c)
            CentreFont ("Play", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            View.Update
            delay (50)
        end for
    elsif m = 1 then
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
        for decreasing c : 31 .. 16
            CentreFont ("Play", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            View.Update
            delay (50)
        end for

    end if

    CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
    CentreFont ("Play", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), black)
    CentreFont ("Help", maxx div 2, maxy div 2, Font.New ("Impact:14"), black)
    CentreFont ("Quit", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), black)

    View.Update
    loop
        var x, y, button, middle : int := 0
        mousewhere (x, y, button)
        left := button mod 10             
        middle := (button - left) mod 100
        right := button - middle - left   
       
        Input.KeyDown (keys)

        if keys (RIGHT_ARROW) and keys (LEFT_ARROW) and left = 1 then
            cheats := 1
        end if

        if x > X1 and x < X2 and y > AY1 and y < AY2 then
            Draw.Box (X1, AY1, X2, AY2, brightred)
            View.Update
            if button = 1 then
                answer := 1
                exit
            end if
        elsif x > X1 and x < X2 and y > BY1 and y < BY2 then
            Draw.Box (X1, BY1, X2, BY2, brightred)
            View.Update
            if button = 1 then
                answer := 2
                exit
            end if
        elsif x > X1 and x < X2 and y < CY1 and y > CY2 then
            Draw.Box (X1, CY1, X2, CY2, brightred)
            View.Update
            if button = 1 then
                answer := 3
                exit
            end if
        elsif x >= 0 and x <= 3 and y <= 3 and y >= 0 then
            cheats2 := 1
        else
            Draw.Box (X1, AY1, X2, AY2, black)
            Draw.Box (X1, BY1, X2, BY2, black)
            Draw.Box (X1, CY1, X2, CY2, black)
            View.Update
        end if
    end loop

    if answer = 1 or answer = 2 then
        for c : 16 .. 31
            CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), c)
            CentreFont ("Play", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            View.Update
            delay (50)
        end for
        return
    else
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
        for c : 16 .. 31
            CentreFont ("Play", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            View.Update
            delay (50)
        end for
    end if
    cls
    m := 0
    cheatsyes := 1
end menu

procedure GameMenu
    var X1, X2, AY1, AY2, BY1, BY2, CY1, CY2, DY1, DY2 : int := 0
    X1 := 270
    X2 := 370

    AY1 := 225
    AY2 := 245

    BY1 := 195
    BY2 := 215

    CY1 := 185
    CY2 := 165

    DY1 := 155
    DY2 := 135

    cls

    if m = 0 then
        for decreasing c : 31 .. 16
            CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), c)
            CentreFont ("Continue", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Restart", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 60, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            Draw.Box (X1, DY1, X2, DY2, c)
            View.Update
            delay (50)
        end for
    elsif m = 1 then
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
        for decreasing c : 31 .. 16
            CentreFont ("Continue", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Restart", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 60, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            Draw.Box (X1, DY1, X2, DY2, c)
            View.Update
            delay (50)
        end for

    end if

    CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
    CentreFont ("Continue", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), black)
    CentreFont ("Restart", maxx div 2, maxy div 2, Font.New ("Impact:14"), black)
    CentreFont ("Help", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), black)
    CentreFont ("Quit", maxx div 2, maxy div 2 - 60, Font.New ("Impact:14"), black)

    View.Update
    loop
        var x, y, b : int := 0
        mousewhere (x, y, b)
        if x > X1 and x < X2 and y > AY1 and y < AY2 then
            Draw.Box (X1, AY1, X2, AY2, brightred)
            View.Update
            if b = 1 then
                answer4 := 1
                exit
            end if
        elsif x > X1 and x < X2 and y > BY1 and y < BY2 then
            Draw.Box (X1, BY1, X2, BY2, brightred)
            View.Update
            if b = 1 then
                answer4 := 2
                exit
            end if
        elsif x > X1 and x < X2 and y < CY1 and y > CY2 then
            Draw.Box (X1, CY1, X2, CY2, brightred)
            View.Update
            if b = 1 then
                answer4 := 3
                exit
            end if
        elsif x > X1 and x < X2 and y < DY1 and y > DY2 then
            Draw.Box (X1, DY1, X2, DY2, brightred)
            View.Update
            if b = 1 then
                answer4 := 4
                exit
            end if

        else
            Draw.Box (X1, AY1, X2, AY2, black)
            Draw.Box (X1, BY1, X2, BY2, black)
            Draw.Box (X1, CY1, X2, CY2, black)
            Draw.Box (X1, DY1, X2, DY2, black)
            View.Update
        end if
    end loop

    if answer4 = 1 or answer4 = 2 or answer4 = 3 then
        for c : 16 .. 31
            CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), c)
            CentreFont ("Continue", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Restart", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 60, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            Draw.Box (X1, DY1, X2, DY2, c)
            View.Update
            delay (50)
        end for
        return
    else
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2 + 70, Font.New ("Impact:20:bold,underline"), black)
        for c : 16 .. 31
            CentreFont ("Continue", maxx div 2, maxy div 2 + 30, Font.New ("Impact:14"), c)
            CentreFont ("Restart", maxx div 2, maxy div 2, Font.New ("Impact:14"), c)
            CentreFont ("Help", maxx div 2, maxy div 2 - 30, Font.New ("Impact:14"), c)
            CentreFont ("Quit", maxx div 2, maxy div 2 - 60, Font.New ("Impact:14"), c)
            Draw.Box (X1, AY1, X2, AY2, c)
            Draw.Box (X1, BY1, X2, BY2, c)
            Draw.Box (X1, CY1, X2, CY2, c)
            Draw.Box (X1, DY1, X2, DY2, c)
            View.Update
            delay (50)
        end for
    end if
    cls
    m := 0

end GameMenu

procedure Help
    var X1, X2, AY1, AY2 : int
    X1 := 270
    X2 := 370

    AY1 := 75
    AY2 := 96

    cls
    for decreasing c : 31 .. 16
        CentreFont ("Peter's Pong Help", maxx div 2, maxy div 2 + 110, Font.New ("Impact:16:bold,underline"), c)
        CentreFont ("Control the two paddles with the mouse.", maxx div 2, maxy div 2 + 90, Font.New ("Impact:12"), c)
        CentreFont ("Try to stop the ball from passing your", maxx div 2, maxy div 2 + 70, Font.New ("Impact:12"), c)
        CentreFont ("paddles. The more you hit the ball with", maxx div 2, maxy div 2 + 50, Font.New ("Impact:12"), c)
        CentreFont ("the paddle the more it speeds up. Your", maxx div 2, maxy div 2 + 30, Font.New ("Impact:12"), c)
        CentreFont ("score is the amount of times you hit", maxx div 2, maxy div 2 + 10, Font.New ("Impact:12"), c)
        CentreFont ("the ball. Pressing the left mouse button", maxx div 2, maxy div 2 - 10, Font.New ("Impact:12"), c)
        CentreFont ("makes you go into slow-motion. The green", maxx div 2, maxy div 2 - 30, Font.New ("Impact:12"), c)
        CentreFont ("bar on the right is the amount of time", maxx div 2, maxy div 2 - 50, Font.New ("Impact:12"), c)
        CentreFont ("that you can go into slow-motion. Right", maxx div 2, maxy div 2 - 70, Font.New ("Impact:12"), c)
        CentreFont ("clicking brings up the in-game menu", maxx div 2, maxy div 2 - 90, Font.New ("Impact:12"), c)
        CentreFont ("Return", maxx div 2, maxy div 2 - 120, Font.New ("Impact:14"), c)
        Draw.Box (X1, AY1, X2, AY2, c)
        delay (50)
        View.Update
    end for

    Draw.Box (X1, AY1, X2, AY2, black)

    View.Update

    loop
        var x, y, b : int := 0
        mousewhere (x, y, b)
        if x > X1 and x < X2 then
            if y > AY1 and y < AY2 then
                Draw.Box (X1, AY1, X2, AY2, brightred)
                View.Update
                if b = 1 then
                    answer := 1
                    exit
                end if
            else
                Draw.Box (X1, AY1, X2, AY2, black)
                View.Update
            end if
        end if
    end loop
    for c : 16 .. 31
        CentreFont ("Peter's Pong Help", maxx div 2, maxy div 2 + 110, Font.New ("Impact:16:bold,underline"), c)
        CentreFont ("Control the two paddles with the mouse.", maxx div 2, maxy div 2 + 90, Font.New ("Impact:12"), c)
        CentreFont ("Try to stop the ball from passing your", maxx div 2, maxy div 2 + 70, Font.New ("Impact:12"), c)
        CentreFont ("paddles. The more you hit the ball with", maxx div 2, maxy div 2 + 50, Font.New ("Impact:12"), c)
        CentreFont ("the paddle the more it speeds up. Your", maxx div 2, maxy div 2 + 30, Font.New ("Impact:12"), c)
        CentreFont ("score is the amount of times you hit", maxx div 2, maxy div 2 + 10, Font.New ("Impact:12"), c)
        CentreFont ("the ball. Pressing the left mouse button", maxx div 2, maxy div 2 - 10, Font.New ("Impact:12"), c)
        CentreFont ("makes you go into slow-motion. The green", maxx div 2, maxy div 2 - 30, Font.New ("Impact:12"), c)
        CentreFont ("bar on the right is the amount of time", maxx div 2, maxy div 2 - 50, Font.New ("Impact:12"), c)
        CentreFont ("that you can go into slow-motion. Right", maxx div 2, maxy div 2 - 70, Font.New ("Impact:12"), c)
        CentreFont ("clicking brings up the in-game menu", maxx div 2, maxy div 2 - 90, Font.New ("Impact:12"), c)
        CentreFont ("Return", maxx div 2, maxy div 2 - 120, Font.New ("Impact:14"), c)
        Draw.Box (X1, AY1, X2, AY2, c)
        View.Update
        delay (50)
    end for
    m := 0
end Help

procedure Credits
    for decreasing c : 31 .. 16
        CentreFont ("Programmed by Peter Do", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), c)
        View.Update
        delay (50)
    end for

    CentreFont ("Programmed by Peter Do", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), black)
    delay (200)

    for c : 16 .. 31
        CentreFont ("Programmed by Peter Do", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), c)
        View.Update
        delay (50)
    end for

    cls

    for decreasing c : 31 .. 16
        CentreFont ("Music by Aaron Liblong", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), c)
        View.Update
        delay (50)
    end for

    CentreFont ("Music by Aaron Liblong", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), black)
    delay (200)

    for c : 16 .. 31
        CentreFont ("Music by Aaron Liblong", maxx div 2, maxy div 2, Font.New ("Impact:20:bold"), c)
        View.Update
        delay (50)
    end for

    cls

    for decreasing c : 31 .. 16
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2, Font.New ("Impact:70:bold"), c)
        View.Update
        delay (50)
    end for

    CentreFont ("Peter's Pong", maxx div 2, maxy div 2, Font.New ("Impact:70:bold"), black)
    delay (200)

    for c : 16 .. 31
        CentreFont ("Peter's Pong", maxx div 2, maxy div 2, Font.New ("Impact:70:bold"), c)
        View.Update
        delay (50)
    end for

    cls
end Credits

procedure Restart
    %These randint statements randomize the direction(a and b) and the location (x and y)
    randint (x, 220, 420)
    randint (y, 1, 200)
    randint (a, 0, 1)
    randint (b, 0, 1)

    rx := x
    ry := y
    c := 1
    s := 0
    Speed := 1
    RSpeed := 1
    SlowMotion := SLOWMAX
    RSlowMotion := SLOWMAX
end Restart


procedure CheckHit1
    if y >= 400 - RADIUS then
        b := 0
        c := (c + 1) mod 15
    elsif y <= RADIUS then
        b := 1
        c := (c + 1) mod 15
    end if
end CheckHit1

procedure CheckHit2
    if x <= RADIUS + BoxX2 + 1 then
        if y <= BoxY2 + RADIUS and y >= BoxY1 - RADIUS then
            a := 0
            Score += 1
            c := (c + 1) mod 15
            if Speed <= 2 then
                RSpeed += ACCELERATION
                Speed := round (RSpeed)
            end if
        end if
    end if
end CheckHit2

procedure CheckHit3
    if x >= maxx - 3 - RADIUS then
        if y <= Box2Y2 + RADIUS and y >= Box2Y1 - RADIUS then
            a := 1
            Score += 1
            c := (c + 1) mod 15
            if Speed <= 2 then
                RSpeed += ACCELERATION
                Speed := round (RSpeed)
            end if
        end if
    end if
end CheckHit3

procedure MoveWall
    var x, y, button, middle : int
    Input.KeyDown (keys)
    mousewhere (x, y, button)
    left := button mod 10                 % left = 0 or 1
    middle := (button - left) mod 100     % middle = 0 or 10
    right := button - middle - left       % right = 0 or 100
    if left = 1 and cheats = 1 and cheats2 = 1 then
        SlowMotion := SLOWMAX
        WallSpeed := 2
        Speed := 0
        s := 1
    elsif left = 1 and SlowMotion > 0 then
        RSlowMotion := RSlowMotion - 2
        SlowMotion := round (RSlowMotion)
        WallSpeed := 2
        Speed := 0
        s := 1
    elsif left = 0 or SlowMotion <= 0 then
        WallSpeed := 5
        Speed := round (RSpeed)
        s := 0
    end if

    if y < WallPosition - 2 or y > WallPosition + 2 then
        if y > WallPosition then
            WallPosition := WallPosition + WallSpeed
        elsif y < WallPosition then
            WallPosition := WallPosition - WallSpeed
        end if
    end if
    if WallPosition >= maxy - 50 then
        WallPosition := maxy - 50
    end if
    if WallPosition <= 50 then
        WallPosition := 50
    end if
end MoveWall

%                                                    MAIN BODY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



setscreen ("offscreenonly, nobuttonbar,nocursor")
buttonchoose ("multibutton")

Credits
loop
    loop
        menu

        if answer = 1 then
            exit
        elsif answer = 2 then
            Help
        elsif answer = 3 then
            SureQuit
            if answer2 = 1 then
                quit
            end if
        end if

    end loop

    Restart

    loop

        if right = 100 then
            loop
                GameMenu
                if answer4 = 1 then
                    exit
                elsif answer4 = 2 then
                    Restart
                    exit
                elsif answer4 = 3 then
                    Help
                elsif answer4 = 4 then
                    SureQuit
                    if answer2 = 1 then
                        quit
                    end if
                end if
                answer4 := 0
            end loop
        end if

        %This regenerates the slow motion bar if the player is not in slow motion and the slow motion is not full
        if left not= 1 and SlowMotion < SLOWMAX then
            RSlowMotion += 0.5
            SlowMotion := round (RSlowMotion)
        end if
        MoveWall


        %This checks if the player is in slow motion and if he isn't then it makes real x become x and
        %real y become y
        if s not= 1 then
            rx := x
            ry := y
        end if

        %This draws the ball
        Draw.FillOval (x, y, RADIUS, RADIUS, c)

        %This positions the left paddle
        BoxX1 := 3
        BoxY1 := WallPosition - 50
        BoxX2 := 6
        BoxY2 := WallPosition + 50

        %This positions the right paddle
        Box2X1 := maxx - 3
        Box2Y1 := WallPosition - 51
        Box2X2 := maxx
        Box2Y2 := WallPosition + 51

        %This draws the left paddle
        Draw.FillBox (BoxX1, BoxY1, BoxX2, BoxY2, black)

        %This draws the right paddle
        Draw.FillBox (Box2X1, Box2Y1, Box2X2, Box2Y2, black)

        %This draws the slow motion bar
        Draw.FillBox (0, 0, 2, round (SlowMotion * 0.8), green)

        %This draws a grey line between the slow motion bar and
        Draw.Line (3, 0, 3, 400, grey)
        View.Update

        %This checks if the ball hit the wall
        CheckHit1

        %This checks if the ball hit the left paddle
        CheckHit2

        %This checks if the ball hit the right paddle
        CheckHit3

        %This checks if the player is in slow motion
        if s = 1 then
            %This makes the  ball move left in  slow motion
            if a = 1 then
                rx := RealLeft (rx)
                x := round (rx)
            else
                %This makes the ball move right in slow motion
                rx := RealRight (rx)
                x := round (rx)
            end if
        else
            %This makes the ball move left normally
            if a = 1 then
                x := Left (x)
            else
                %This makes the ball move right normally
                x := Right (x)
            end if
        end if

        %This checks if the player is in slow motion
        if s = 1 then
            %This makes the ball move up in slow motion
            if b = 1 then
                ry := RealUp (ry)
                y := round (ry)
            else
                %This makes the ball move down in slow motion
                ry := RealDown (ry)
                y := round (ry)
            end if
        else
            %This makes the ball move up normally
            if b = 1 then
                y := Up (y)
            else
                %This makes the ball move down normally
                y := Down (y)
            end if
        end if

        %This makes sure the colour of the ball is not white
        if c = 0 then
            c := 1
        end if

        %This erases everything but the ball on the screen so that the ball leaves a trail behind it
        if s not= 1 then
            cls
        else
            Draw.FillBox (BoxX1, BoxY1, BoxX2, BoxY2, white)
            Draw.FillBox (Box2X1, Box2Y1, Box2X2, Box2Y2, white)
            Draw.FillBox (0, 0, 2, round (SlowMotion * 1.6), white)
        end if

        %This checks if the ball hit the wall
        if x <= RADIUS + 3 then
           
            cls
            YouLose
            Score := 0
            Speed := 1
            RSpeed := 0
            cheats := 0
            cheats2 := 0
            if answer3 = 1 then
                quit
            else
                exit
            end if
            exit
        end if

        %This checks if the ball hit the wall
        if x >= maxx - RADIUS then
           
            cls
            YouLose
            Score := 0
            Speed := 1
            RSpeed := 0
            cheats := 0
            cheats2 := 0
            if answer3 = 1 then
                quit
            else
                exit
            end if
            exit
        end if
    end loop
end loop
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: