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 / Help- Pong game- Collision

Author
Message
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 3rd Feb 2005 08:32 Edited at: 6th Feb 2005 01:55
I'm trying to make a pong game. This is my first game. I have made little madlib programs and stuff before this so I think I'm ready. The only problem is that I have no idea which type of collision detection to use for the ball and paddles.
Here's the code:

[You can Paste this code into your editor since it has no dependencies]


Maybe I should make the collision simple, like this:



Stan: OH MY GOD! THEY KILLED KENNY
Stan's Grandpa: You Bastards!
Kyle: HEY! ><
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 4th Feb 2005 09:05 Edited at: 4th Feb 2005 09:06
For 2-d, I'd do collision by detecting if the ball has gone past certain coordinates - something like this:



You'd need to fiddle a bit to get the numbers exactly right, though.


They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 6th Feb 2005 01:50 Edited at: 6th Feb 2005 01:58
Hm... but then what in the world is the Sprite Collision Command for? And how do you use it? When I use it, it doesnt detect anything and the ball just goes through it.

I'll try it to see if it works

Stan: OH MY GOD! THEY KILLED KENNY
Stan's Grandpa: You Bastards!
Kyle: HEY! ><
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Feb 2005 07:40 Edited at: 6th Feb 2005 07:45
Using sprite collision, it would be like this .....



..... although sprites have a tendency to pass through each other if they're moving too fast if you use the sprite collision command.


They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 6th Feb 2005 08:54
Buggy commands ><.
Ok I'l try it
-studies the code-

Stan: OH MY GOD! THEY KILLED KENNY
Stan's Grandpa: You Bastards!
Kyle: HEY! ><
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 6th Feb 2005 23:36 Edited at: 6th Feb 2005 23:44
Yay it worked! The ball isn't moving too fast for the paddles to hit it!

But now I want it to Bounce off the bottom and Top. Normally, it bounces off the bottom (usually) but not at the top (usually).... the logic is perfectly fine... I dont get whats wrong... Here is the Subroutine:



And here is the whole code.... I have a feeling it is conflicting with something... but I dont know why. Maybe i should put a Sync Command in the Subroutine?



Stan: OH MY GOD! THEY KILLED KENNY
Stan's Grandpa: You Bastards!
Kyle: HEY! ><
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 7th Feb 2005 00:45
Change to:




Login to post a reply

Server time is: 2024-11-27 21:40:19
Your offset time is: 2024-11-27 21:40:19