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 Professional Discussion / Pong Game - Sprite Collision Problems

Author
Message
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 14th Aug 2012 11:45 Edited at: 14th Aug 2012 11:46
I have been playing with a pong game made of sprites and I reached a certain point which does not make any sense.
The problem is this.

I have two if statements that check to see if the ball collided with P1 and P2 paddles.



The problem is in the second if statement. If the second if statement is omitted, everything works fine. The code runs through the first if statement once check and if it is a hit it changes the BallSpeedY to the negative. No problems
If however the second if statement that checks the P2 collision, the the code runs through the first statement, changes the ballspeed, however, during the second, third, fourth ... it still detects a collision.

With both sprite hit checks it looks like this
http://www.youtube.com/watch?v=0Xy0pJjf4Fc

With only the first sprite check it looks like this
http://www.youtube.com/watch?v=0Xy0pJjf4Fc

It is obvious that if both sprite checks are there the first sprite check is run through continuously. But why? It does not make any sense at all!
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 14th Aug 2012 13:04
I seemed to have resolved my problem.

I replaced this:



with this:



Any ideea though what happend in the first place? Sprite Hit command does not work when you check separately for different sprites?

Login to post a reply

Server time is: 2026-07-21 20:34:35
Your offset time is: 2026-07-21 20:34:35