javascript - How to detect collision -


i doing small game based on tutorial http://code.tutsplus.com/tutorials/learn-createjs-by-building-an-html5-pong-game--active-11845

i made changes line buggy

if(ball.x <= player.x + 22 && ball.x > player.x && ball.y >= player.y && ball.y < player.y + 75) 

whenever user hit fast left or right ball keep bouncing in tutorial, bug there, can me ?

thanks

i think easiest solution add direction variable ball , test it. if it's towards player check you've coded, else ignore. if check passes, change direction when player intercepts it. when bounces back, change direction again. simplify code lot , reduce number of checks going on.


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -