Making a pong game shaped like a octagon, need help!
Ältere Kommentare anzeigen
I am trying to make a pong game in matlab that has an octagon shaped court to learn about the math of billiards.
At this point I have the goals working and I have the ball bouncing for every case except for the diagonals of the octagon.
The top, bottom and sides are easy because I just test if the new x and y vectors I'm creating are > or < then the values I have set for the walls. The diagonals are a bit tricky because I need to test the x and y vectors of the ball for every single point of the diagonal line.
I created the polygon using
POLY = [1 75; 1 25; 75 5; 175 5; 250 25; 250 75; 175 96; 75 96];
POLYG = [POLY; POLY(1,:) ]; %repeat first row at the end
plot(POLYG(:,1),POLYG(:,2))
axis equal %same scale on both axes
I need a way to create a set of points between the points that draw the diagonal line so that I can test the balls path against those points. E.g. if one diagonal is the line between (1,25) and (75,5) on my plot how do I get all of the sets of points between them into a matrix?
Thank you for your help
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Number games finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!