Building a pong game with circular obstacles in the middle.. need help
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
brian grove
le 13 Mai 2015
Commenté : brian grove
le 21 Mai 2015
So I have made a pong game that is shaped like an octagon and now I want to add two circular bumpers into the mix. I have the circles plotted but I am having trouble creating an if statement that properly defines the circle as a bumper. I need an if statement that will not let the ball enter the circle without triggering my bounce function. Heres the statement I have right now..
if (((newX < circleX2s) & (newX>circleX2s)) & ((newY < circleY2s)...
& (newY > circleY2s)))
plot(circleX2s,circleY2s,'b')
end
The 'plot' is just a test to see if it is registering when the ball enters the circle.
Any suggestions?
Thank you for your help.
0 commentaires
Réponse acceptée
Walter Roberson
le 13 Mai 2015
distsq1 = (Circle1CenterX - newX).^2 + (Circle1CenterY - newY).^2;
if distsq1 < Circle1Radius.^2
you are inside the circle
end
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!