
-----------------------------------
nightfeng2
Fri Jan 07, 2011 11:37 pm

Pong game help
-----------------------------------
What is it you are trying to achieve?
Have a smooth paddle for pong game
What is the problem you are having?
I made a pong game with 1 paddle and 1 ball, but then paddle's movement is so slow, when i press up, the paddle moves a pixel up, delays and then move up continuously with lag.




Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



setscreen ("graphics:640;480,nocursor")
var ckey : string (1)

var x1, y1, x2, y2 : int %variables for left paddle
var ballx, bally, subx, suby : int %for ball
subx := -5
suby := 5
ballx := 320
bally := 240
%%%%%%%%%%%%%%%%%%left paddle
x1 := 10
y1 := 180
x2 := 30
y2 := 300
drawfillbox (x1, y1, x2, y2, 1)

%%%%%%%%%%%ball
process ball
    loop

        drawfilloval (ballx, bally, 5, 5, 4)

        delay (25)

        drawfilloval (ballx, bally, 5, 5, 0)

        if ballx = 10 then
            subx := 5

        elsif bally = 475 then
            suby := -5
        elsif ballx = 635 then
            subx := -5
        elsif bally = 5 then
            suby := 5
        elsif bally = y1 and bally 