Jump to content
IGNORED

Pong bouncin'


Galaxian

Recommended Posts

Hello (once again)

I just asked to see if anyone here knows how to make a ball in pong bounce of the walls and paddles. (Flipping its direction)

 

I know that it sounds a bit unreasonable that I've asked for so much help, but hopefully, this will be the last time!

 

Thank you in advance,

Galaxian

joy_pong.bas.bin

Edited by Galaxian
Link to comment
Share on other sites

You could do something like this to use a variable to store the ball direction.

 

          dim  BallDir=a
          BallDir = 10

 

And then give the ball movement.

 

MoveBall
if BallDir = 10 then gosub moveupandright
if BallDir = 20 then gosub movedownandright
if BallDir = 30 then gosub movedownandleft
if BallDir = 40 then gosub moveupandleft

moveupandright 
ballx = ballx + 1
bally = bally + 1
return


moveupandleft
ballx = ballx - 1
bally = bally + 1
return


movedownandright
ballx = ballx + 1
bally = bally - 1
return


movedownandleft
ballx = ballx - 1
bally = bally - 1
return

 

Then you would have to do collisions with the playfield and the paddle to make the ball change directions. If you look in the code for "Bong" it is commented well and might give you some ideas on that.

Link to comment
Share on other sites

You could do something like this to use a variable to store the ball direction.

 

          dim  BallDir=a
          BallDir = 10

 

And then give the ball movement.

 

MoveBall
if BallDir = 10 then gosub moveupandright
if BallDir = 20 then gosub movedownandright
if BallDir = 30 then gosub movedownandleft
if BallDir = 40 then gosub moveupandleft

moveupandright 
ballx = ballx + 1
bally = bally + 1
return


moveupandleft
ballx = ballx - 1
bally = bally + 1
return


movedownandright
ballx = ballx + 1
bally = bally - 1
return


movedownandleft
ballx = ballx - 1
bally = bally - 1
return

 

Then you would have to do collisions with the playfield and the paddle to make the ball change directions. If you look in the code for "Bong" it is commented well and might give you some ideas on that.

Wow thanks! That should be all, but if further assistance is needed, i'll get back to you guys.

 

THANKS!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...