From 2f851f87849cda44cac0ff7c1fe51a9e7fb13c0e Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Tue, 10 Jul 2018 16:24:18 +0100 Subject: [PATCH 1/3] Add constructors to Rect --- src/Arduboy2.cpp | 9 +++++++++ src/Arduboy2.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index 5d59b55..40869e7 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -8,6 +8,15 @@ #include "ab_logo.c" #include "glcdfont.c" +//================================ +//========== class Rect ========== +//================================ + +Rect::Rect(int16_t x, int16_t y, uint8_t width, uint8_t height) + : x(x), y(y), width(width), height(height) +{ +} + //======================================== //========== class Arduboy2Base ========== //======================================== diff --git a/src/Arduboy2.h b/src/Arduboy2.h index b7405a1..71a0c46 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -104,6 +104,10 @@ struct Rect int16_t y; /**< The Y coordinate of the top left corner */ uint8_t width; /**< The width of the rectangle */ uint8_t height; /**< The height of the rectangle */ + + Rect() = default; /**< The default constructor of the point */ + + Rect(int16_t x, int16_t y, uint8_t width, uint8_t height); /**< The fully initialising constructor of the point */ }; /** \brief From 2427e7c86b95b96bc9cf7d90fa1aa140fff29a24 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Tue, 10 Jul 2018 16:25:33 +0100 Subject: [PATCH 2/3] Add constructors to Point --- src/Arduboy2.cpp | 9 +++++++++ src/Arduboy2.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index 40869e7..d6cdcd4 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -17,6 +17,15 @@ Rect::Rect(int16_t x, int16_t y, uint8_t width, uint8_t height) { } +//================================= +//========== class Point ========== +//================================= + +Point::Point(int16_t x, int16_t y) + : x(x), y(y) +{ +} + //======================================== //========== class Arduboy2Base ========== //======================================== diff --git a/src/Arduboy2.h b/src/Arduboy2.h index 71a0c46..735e592 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -122,6 +122,10 @@ struct Point { int16_t x; /**< The X coordinate of the point */ int16_t y; /**< The Y coordinate of the point */ + + Point() = default; /**< The default constructor of the point */ + + Point(int16_t x, int16_t y); /**< The fully initialising constructor of the point */ }; //================================== From 25932d4adb05a4d0d641a06802b99e0ceaae5cc4 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Tue, 10 Jul 2018 16:41:23 +0100 Subject: [PATCH 3/3] Make both collide functions static --- src/Arduboy2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Arduboy2.h b/src/Arduboy2.h index 735e592..a569a6b 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -1027,7 +1027,7 @@ class Arduboy2Base : public Arduboy2Core * * \see Point Rect */ - bool collide(Point point, Rect rect); + static bool collide(Point point, Rect rect); /** \brief * Test if a rectangle is intersecting with another rectangle. @@ -1044,7 +1044,7 @@ class Arduboy2Base : public Arduboy2Core * * \see Rect */ - bool collide(Rect rect1, Rect rect2); + static bool collide(Rect rect1, Rect rect2); /** \brief * Read the unit ID from system EEPROM.