
-----------------------------------
PrinceCooper
Tue Jun 14, 2011 12:47 pm

High Score Table: Paddle Ball Game?
-----------------------------------
Problem:
Me and my friend are currently working on a ball and paddle type game and have run into a issue. We want to add a high score table option to the menu to keep track of the top scores.

Issue:
We currently have a score system in place so everytime the ball hits the paddle your score increases by 1 ponit. We want to be able have that score stored in a separate txt file or something so when the high score option is chosen from the menu the Top 10 Scores are set in place. As a bonus we want to be able to store names as well so we can tell who got which score.

Current Code:


% VARIABLES
var x1, x2, x3, x4, x5 : int     % Lengths, X-Axis
var xdir, ydir : int             % Keeps Track of Speed of Ball
var y1 : int                     % Height,Y-axis
var key : string (1)             % Key Board Character
var num : int                    % Stores ASCII Numbers
var count : int                  % Keeps Track of Score
var choice : string (1)          % Choice for menu
var name : string                % Name for Highscore
var font1 : int
font1 := Font.New ("Agency FB:30")

% MENU
drawfill (10, 10, 225, 225)
locate (10, 24)
colorback (225)
Font.Draw ("WELCOME TO RYAN'S PADDLEBALL GAME!", 90, 320, font1, 31)
locate (11, 30)
color (31)
put "Created By: Ryan Covell" ..
locate (13, 28)
color (31)
put "PRESS (1) TO START A NEW GAME" ..
locate (15, 28)
color (31)
put "PRESS (2) TO SEE HIGH-SCORE TABLE" ..
locate (17, 28)
color (31)
put "PRESS (3) TO QUIT GAME" ..
color (31)
locate (20, 2)
put "Use the left () arrows to direct the paddle. The point of the game is to try and keep the ball moving and stop it from hitting the ground!"

getch (choice)
case choice of

        % MAIN GAME
    label "1" :
        cls
        View.Set ("offscreenonly")
        loop
            cls
            count := 0                    %Setting the values for the variables
            num := 0
            x1 := 110
            xdir := 3
            ydir := 3
            y1 := 110
            x4 := 110
            x5 := 160
            x2 := 110
            x3 := 160


            loop
                drawfill (10, 10, 225, 225) % Background Colour
                locate (10, 2)
                colorback (225)
                color (31)
                put "SCORE ", count ..
                drawbox (110, -100, 635, 389, 31) % Background
                drawfillbox (x4, 0, x5, 10, 31) % Paddle
                drawfilloval (x1, y1, 5, 5, 31) % Ball
                delay (10)
                View.Update
                exit when y1 = -10
                drawfilloval (x1, y1, 5, 5, 225) % Erasing Ball Trail
                drawfillbox (x4, 0, x5, 10, 225) % Erasing Paddle Trail

                if hasch then
                    getch (key) % Get Key Pressed
                    num := ord (key) % Find ASCII number for key
                end if

                if num = 203 and x4 >= 120 then % Left arrow
                    x4 := x4 - 25
                    x5 := x5 - 25
                elsif num = 205 and x5 = 10 and y1 = x4 and x1 = 380 then % makes ball not go past 380 on y axis
                    ydir := -3
                elsif y1 