Rectangle class
Dependents: FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot
Fork of Rectangle by
Rectangle.cpp@1:d9c0709ba2ce, 2013-11-18 (annotated)
- Committer:
- dhamilton31
- Date:
- Mon Nov 18 21:09:00 2013 +0000
- Revision:
- 1:d9c0709ba2ce
- Parent:
- main.cpp@0:19fca77774b6
- Child:
- 2:087e0b0b526c
this class is not that great.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
projetremote | 0:19fca77774b6 | 1 | #include "mbed.h" |
projetremote | 0:19fca77774b6 | 2 | #include "Rectangle.h" |
projetremote | 0:19fca77774b6 | 3 | |
projetremote | 0:19fca77774b6 | 4 | |
dhamilton31 | 1:d9c0709ba2ce | 5 | Rectangle :: Rectangle(int x,int y, int xx, int yy){ |
dhamilton31 | 1:d9c0709ba2ce | 6 | x1 = x; |
dhamilton31 | 1:d9c0709ba2ce | 7 | x2 = xx; |
dhamilton31 | 1:d9c0709ba2ce | 8 | y1 = y; |
dhamilton31 | 1:d9c0709ba2ce | 9 | y2 = yy; |
projetremote | 0:19fca77774b6 | 10 | } |
projetremote | 0:19fca77774b6 | 11 | |
projetremote | 0:19fca77774b6 | 12 | bool Rectangle :: is_touch(int x_touch , int y_touch){ |
dhamilton31 | 1:d9c0709ba2ce | 13 | if(x_touch >= x1 && x_touch <= x2) |
dhamilton31 | 1:d9c0709ba2ce | 14 | if(y_touch >= y1 && y_touch <= y2) |
projetremote | 0:19fca77774b6 | 15 | return true; |
projetremote | 0:19fca77774b6 | 16 | return false; |
projetremote | 0:19fca77774b6 | 17 | } |
projetremote | 0:19fca77774b6 | 18 | |
projetremote | 0:19fca77774b6 | 19 | |
projetremote | 0:19fca77774b6 | 20 | int Rectangle :: getX1(){ |
dhamilton31 | 1:d9c0709ba2ce | 21 | return x1; |
projetremote | 0:19fca77774b6 | 22 | } |
projetremote | 0:19fca77774b6 | 23 | |
projetremote | 0:19fca77774b6 | 24 | int Rectangle :: getX2(){ |
dhamilton31 | 1:d9c0709ba2ce | 25 | return x2; |
projetremote | 0:19fca77774b6 | 26 | } |
projetremote | 0:19fca77774b6 | 27 | |
projetremote | 0:19fca77774b6 | 28 | int Rectangle :: getY1(){ |
dhamilton31 | 1:d9c0709ba2ce | 29 | return y1; |
projetremote | 0:19fca77774b6 | 30 | } |
projetremote | 0:19fca77774b6 | 31 | |
projetremote | 0:19fca77774b6 | 32 | int Rectangle :: getY2(){ |
dhamilton31 | 1:d9c0709ba2ce | 33 | return y2; |
projetremote | 0:19fca77774b6 | 34 | } |
projetremote | 0:19fca77774b6 | 35 | |
dhamilton31 | 1:d9c0709ba2ce | 36 | int Rectangle :: getCenterX(){ |
dhamilton31 | 1:d9c0709ba2ce | 37 | return x1 + (x2-x1)/2; |
dhamilton31 | 1:d9c0709ba2ce | 38 | } |
dhamilton31 | 1:d9c0709ba2ce | 39 | |
dhamilton31 | 1:d9c0709ba2ce | 40 | int Rectangle :: getCenterY(){ |
dhamilton31 | 1:d9c0709ba2ce | 41 | return y1 + (y2-y1)/2; |
projetremote | 0:19fca77774b6 | 42 | } |