Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17dg by
Diff: game/geometry.h
- Revision:
- 30:d454d0cb72bc
- Parent:
- 29:579e00b7f118
- Child:
- 31:becb8f6bf7b7
--- a/game/geometry.h Mon Apr 15 12:59:51 2019 +0000
+++ b/game/geometry.h Tue Apr 16 21:16:33 2019 +0000
@@ -5,7 +5,7 @@
////////////////////////////////////////////////////////////////////////
/**
- * A structure to represent the positions of sprites
+ * A structure to represent the positions of a sprite on the screen.
*/
struct Point {
/*@{*/
@@ -39,7 +39,8 @@
CircleBounds(Point _center, float _radius): center(_center), radius(_radius) {};
Point center;
float radius;
-};
+
+
/** @brief a function that determines whether the two sprites have collided.
* @details the function takes in the position and the bounds (center and radius)
* two sprites (x and y positions and the circle area of a sprite) then performs the
@@ -52,14 +53,14 @@
* @param bounds_b center point and radius of the second sprite. (const CircleBounds&).
* @return difference.lengthSquared() if the areas of two sprites overlap, it will return true.
*/
-inline bool circleCollideTwoObjects(
+ inline bool circleCollideTwoObjects(
const Point& pos_a, const CircleBounds& bounds_a,
- const Point& pos_b, const CircleBounds& bounds_b
-) {
+ const Point& pos_b, const CircleBounds& bounds_b) {
Point center_a = pos_a + bounds_a.center;
Point center_b = pos_b + bounds_b.center;
Point difference = center_a - center_b;
return difference.lengthSquared() <= pow(bounds_a.radius + bounds_b.radius, 2);
-}
+ }
+};
#endif
\ No newline at end of file
