
-----------------------------------
gergysun
Thu Nov 29, 2007 10:23 pm

Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
Honeslty, lol

ive been searching of how to do that for about an hour now, and i dont understand it
all i want to do is have the ball bounce off my paddle....
here is my code so far...


Code edited out at OP's request

-----------------------------------
Tony
Thu Nov 29, 2007 10:42 pm

RE:Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
It's the same way as bouncing off a wall or a ceiling, just like you're already doing

elsif bally+50>=maxy then
rise:=-1

but instead of maxy, you're checking the ball's position against that of the paddle.

-----------------------------------
gergysun
Thu Nov 29, 2007 10:50 pm

Re: Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
and how do i do that.....like what do i put

-----------------------------------
Tony
Thu Nov 29, 2007 11:19 pm

RE:Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
Well how did you figure out how to bounce the ball off the walls?

-----------------------------------
gergysun
Fri Nov 30, 2007 2:23 pm

Re: Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
well, i looked at the tutorials and managed to get something out of it, and thats how i got 2 of the sides to work, then i asked someone to help me and they gave me the answer of how it works and then i sort of understood it, then when the ball hit the bottom it didnt finish so i figured out how to make it finsih, and now i cant get the ball to bounce off the paddle

-----------------------------------
gergysun
Fri Nov 30, 2007 7:35 pm

Re: Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
WILL SOMEONE HELP ME FOR CRYING OUT LOUD...I DONT UNDERSTAND WHAT TONY IS SAYING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-----------------------------------
Nick
Fri Nov 30, 2007 7:39 pm

RE:Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
i think you just want someone to do the code for you I read through the help and its more than sufficent

-----------------------------------
gergysun
Fri Nov 30, 2007 7:42 pm

Re: Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
i have, but i dont understand it...only the stupid rectangle-ball collision thing....i just dont get it.
and what does Toney mean by

but instead of maxy, you're checking the ball's position against that of the paddle.

-----------------------------------
Clayton
Fri Nov 30, 2007 9:42 pm

RE:Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
Instead of just checking the ball's x co-ordinate and y co-ordinate against maxx and maxy respectively, you want to check within your paddle's x and y co-ordinates instead.

-----------------------------------
gergysun
Fri Nov 30, 2007 9:52 pm

Re: Ball Bounce Off Of Paddle....how!?!?!?!
-----------------------------------
ok, so what ur sayiung is instead of typing
 " elsif bally + 50 >= maxxy then
        rise := -1 "
i would type
"elsif x - 80 >= maxy then
       rise := -1"


if not, please correct me
here is my full code

drawfill (1, 399, 150, 150)
% Ball is slding across title
var font1 : int %defiing font as an integer
font1 := Font.New ("Stencil:30") % defining font size
assert font1 > 0
Font.Draw ("Greg's Ping Pong Game", 160, 325, font1, red) % Main Title
Font.Free (font1)
colorback (6) % the background color
locate (7, 30)
var title1 : int %defines title1 as an integer
title1 := 10

loop %begins title loop
    %Title wiper
    drawfilloval (title1, 335, 20, 20, 12)
    exit when title1 = 600
    delay (50)%delay's playback 50 milliseconds
    drawfilloval (title1, 335, 20, 20, 158) % draws circle and fills it
    title1 := title1 + 10
end loop %ends title loop

cls % clears the screen
colorback (12)% defining background color
put " ---The intructions are ---- " % outputs "Intructions"
put " "% skips a line
put " Move the Paddle with mouse " % outputs actual instructions
put " Each time you keep the ball up in the air you reieve a point"% outputs actual instructions
put " If you miss the ball, you lose "% outputs actual instructions
put " "% skips a line
put " "% skips a line
put " "% skips a line
put " "% skips a line
put " "% skips a line

% press any key to continue
font1 := Font.New ("Stencil:20")%defines font1 as font.new and font size
Font.Draw ("~~Press any Key to Begin~~", 90, 125, font1, red)

Input.Pause % won't continue until user presses a key

colourback (blue)% defining bacground color
cls % Clears the screen
setscreen ("offscreenonly")

var rise, run, rad, u, yy, xx : int%defiing rise,run,rad,yy,xx as integers
var bally, ballx : int := 200% defining bally,ballx as integers
rad := 10 %defines Radius of ball
rise := 2% defines where the ball starts
run := 2 % defines where the ball starts

loop%begins main loop


    var x, y, button : int %defines x,y,button as integers
    Mouse.Where (x, y, button)%indicates where the mouse is
    Draw.FillOval (ballx, bally, rad, rad, yellow)% draws pong ball
    ballx := ballx + run
    bally := bally + rise


    if ballx + 50 >= maxx then
        run := -1
    elsif ballx - 50 = maxy then
        rise := -1
    elsif bally + 50 >= 140 then
        rise := -1
        
elsif x-80 >=maxx then 
rise:=-1 
elsif x + 80 