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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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