
-----------------------------------
TripleC
Thu Nov 05, 2015 11:02 am

Pong game Paddle hit detection issues
-----------------------------------
I'm making a pong game and cant for the life of me figure out why my hit detection is not working (I'm in grade ten and new to turing, and ignore all the other terrible broken stuff its heavily work in progress.  Just focusing on the important stuff first)

%---------------------------------------------------------%
% File name: pong_game_template.t                         %
% Date: 2012/11/05                                        %
% Programmers:                          %
% Description: This is a pong game for two players;       %
%               the first to score 7 goals is the winner. %
%---------------------------------------------------------%

setscreen ("graphics:800;600")
setscreen ("offscreenonly")

var border : int  %
var paddle1 : int  %Player one's paddle
var paddle2 : int %Player two's paddle
var score1 : int := 1%Determines the score of player one
var score2 : int := 1%Determines the score of player two
var ballX1 : int := 400 %
var ballX2 : int %
var ballY1 : int := 300 %
var ballY2 : int %
var shiftY : int := 5
var shiftX : int := 5
var ballPoint : int %
var pong : int
var y, y2, P2y, P2y2 : int
y := 200
y2 := 100
P2y := 200
P2y2 := 100
var scorefont : int
scorefont := Font.New ("Arial:50:bold")
var chars : array char of boolean
randint (shiftX, 4, 8)
randint (shiftY, 4, 8)



%--------------------------------------------------------------------------


procedure redrawGameField
    % pong := Window.Open ("position:top;right,graphics:800;600,nobuttonbar")
    % View.Set ("title: Pong")
    %draws game field
    drawfillbox (0, 0, 800, 600, black)
    drawfillbox (395, 0, 405, 600, white)
    %draw Paddle1
    drawfillbox (760, y, 780, y2, red)
    %Draw Paddle2
    drawfillbox (20, P2y, 40, P2y2, red)
    %Draws the ball
    drawfilloval (ballX1, ballY1, 20, 20, red)
    %Draw score
    Font.Draw ("0", 325, 500, scorefont, white)
    View.Update
if ballX1 = maxy - 110 then
        ballY2 := -1
    end if

    end redrawGameField



%--------------------------------------------------------------------------


procedure bounceBall
    if ballX1 >= 800 or ballX1 = 600 or ballY1 