
-----------------------------------
HighschoolGuy
Thu Dec 03, 2009 11:05 am

Grade 11 Pong Game
-----------------------------------
%This is my first attempt at writing a game.
%Version 1.0
%Author Justin Moen
%Datel; November 10th, 2009

%**************************************************************************************
%This is where i'll declare any global variables.
var fname : string := "Guest"
var answer : string (1)
var movepaddle : int := 165
var font := Font.New ("serif:12:bold")
var font1 := Font.New ("serif:12:italic")
%this will change font face, size and display, it also displays font as a pixel graphic.
var x : int := 70 %This is the x variable where the ball is served from.
var y : int := 175 % This is the y value the ball is served from.
var dx, dy : int := 1
var score : int := 0 %this is our hit counter
var getKey : array char of boolean

View.Set ("offscreenonly")

%*************************************************************************************
%My first task is to draw the court.
%The thing i need to remember is the screen size is 640x480, with 0,0 at the bottom left hand corner.
%My instruction screen.
procedure drawcourt
    cls
    %locatexy (2,25) %this locates the pixelon an x,y basis
    Font.Draw ("Welcome to Pong 1.0", 230, 385, font, black)
    % (text to display,xpl,ypl, font var, color)
    locate (3, 12)
    Font.Draw ("The up & down arrow control the paddle movement.", 165, 355, font1, black)
    locate (1, 60)
    put fname, "'s hits: "
    %need to add the score counter later need to declare variables
    %court
    drawfillbox (50, 5, 600, 350, black)
    %lines
    drawfillbox (590, 10, 595, 345, white)
    drawfillbox (55, 10, 590, 15, white)
    drawfillbox (55, 340, 595, 345, white)
    drawfillbox (320, 15, 323, 340, grey)
end drawcourt
%*********************************************************************************
process moveball
    randint (y, 20, 280)
    randint (x, 320, 325)
    locatexy (x, y)
    drawfilloval (x, y, 5, 5, yellow)
    loop
        delay (3)
        %this controls the ball bouncing off of the top wall
        if
                y >= 338 then
            dy := -dy
            %This controls the bouncing off the back wall
        elsif x >= 588 then
            dx := -dx
            %this controls the ball bouncing off the south wall
        elsif y = movepaddle - 2 and y 