Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Another pong question

Author
Message
sgalland
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 20th Nov 2002 11:24
Hello,

I have implemented a vector and I think its still not working correctly since the program does odd things. For one it does not bounce off the walls right, when it hits the bottom of the screen the ball heads straight down the Y axis, rather than going back up the y axis and having a bounce effect. Here is the code for the ball:

MoveBall:
REM Figure out the slope and multiply that into the BALLX and BALLY
SLOPEX = OLDX - BALLX
SLOPEY = OLDY - BALLY

REM Detect Paddle hitting the ball
IF SPRITE HIT(2,1) = 0
OLDX = SPRITE X(2)
XDIRECTION = XDIRECTION * -1
ENDIF

REM Detect the ball leaving the screen over the x axis
IF BALLX > (SCREEN WIDTH() - BALLXBOTTOM) OR BALLX (SCREEN HEIGHT() - BALLYBOTTOM) OR BALLY
sgalland
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 20th Nov 2002 11:25
Here is the code again...

Login to post a reply

Server time is: 2024-03-28 15:51:30
Your offset time is: 2024-03-28 15:51:30