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.

Newcomers DBPro Corner / Bat and Ball question

Author
Message
Jac
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 13th Jan 2004 22:25
Hi,

I can get the bat to move towards the Bat and the ball to stop at the bat but it doesn't move in the opposite direction.

Would be very greatful if anyone could help.



Thanks,

HeadlessJC
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 13th Jan 2004 22:56
change:


that bit with this bit:



then it does what you want, now you've gotta work out collision with the players pad


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Jan 2004 04:26
I'm guessing this is either a pong game or breakout game?


bx# is the ball's x position
x# is the bat's position.
The IF statement is merely a check for collision, so yours would most likely be different numbers. Its the stuff inside the IF statement you should look at. If the ball hits the bat, then reflect the ball's angle based on how close to the middle of the bat the ball hits. If the ball hits in the center of the bat, it reflects off perpendicular to the bat.



"eureka" - Archimedes
Jac
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 14th Jan 2004 22:22
ReD_eYe

That's great the ball bounce back first time. It took me a couple of steps of working through the code that you gave but I've managed to get the ball bouncing back and fourth.

Phaelax

Pong, its my first game, I wounder how you guest. Your codes a little more complex though I like what it does and will work through, learn what it does and why.

General

When looking at a couple of example codes of pong They all have different ways to making the ball bounce back and fourth, made it hare to work out so thanks for the help.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Jan 2004 05:40
You'll have to adjust the angle in my code then for pong. Since my code was written for a breakout game, the paddle was at the bottom of the screen, knocking the ball up into the air, instead of sideways like in pong.

"eureka" - Archimedes
Jac
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 1st Feb 2004 13:05
So I've been working on my bat hitting ball code and this is what I have so far. though it's not working



I'm wanting the ball to keep the same speed but changing the angle depending on where it hits the bat.

I'd be greatful for any pointer in whats wrong.
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 2nd Feb 2004 00:44 Edited at: 2nd Feb 2004 00:45
you don't have to use a wall sprite






Hope this help

Is just of those days when you don't wanna wake up everything is *****, everybody sucks you really don't know why, but you wanna justify rippin' someone head off!

Login to post a reply

Server time is: 2024-11-26 03:52:04
Your offset time is: 2024-11-26 03:52:04