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.
Point.cpp@4:f1e33a234a74, 2015-05-12 (annotated)
- Committer:
- tyleralt
- Date:
- Tue May 12 16:21:33 2015 +0000
- Revision:
- 4:f1e33a234a74
- Parent:
- 1:bb1507f0bb64
- Child:
- 5:d7d16cb9c974
Working for the demo. Points come back around to center after exiting edge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tyleralt | 0:ded79d89abdf | 1 | |
tyleralt | 0:ded79d89abdf | 2 | #include "Point.h" |
tyleralt | 0:ded79d89abdf | 3 | //*********************point class************************// |
tyleralt | 0:ded79d89abdf | 4 | |
tyleralt | 0:ded79d89abdf | 5 | Point :: Point (void){ |
tyleralt | 0:ded79d89abdf | 6 | positionRadian = 180; |
tyleralt | 0:ded79d89abdf | 7 | positionHeight = 4; |
tyleralt | 0:ded79d89abdf | 8 | positionDistance = 8; |
tyleralt | 0:ded79d89abdf | 9 | //int offAngles [8] = {-3, 174, 44, 228, 90, 270, 135, 315}; |
tyleralt | 1:bb1507f0bb64 | 10 | offAngles[0] = -6; |
tyleralt | 0:ded79d89abdf | 11 | offAngles[1] = 174; |
tyleralt | 0:ded79d89abdf | 12 | offAngles[2] = 44; |
tyleralt | 0:ded79d89abdf | 13 | offAngles[3] = 228; |
tyleralt | 0:ded79d89abdf | 14 | offAngles[4] = 90; |
tyleralt | 0:ded79d89abdf | 15 | offAngles[5] = 270; |
tyleralt | 0:ded79d89abdf | 16 | offAngles[6] = 135; |
tyleralt | 1:bb1507f0bb64 | 17 | offAngles[7] = 323; |
tyleralt | 0:ded79d89abdf | 18 | } |
tyleralt | 0:ded79d89abdf | 19 | |
tyleralt | 0:ded79d89abdf | 20 | Point :: Point (int posRadian, int posHeight, int posDistance){ |
tyleralt | 0:ded79d89abdf | 21 | positionRadian = posRadian; |
tyleralt | 0:ded79d89abdf | 22 | positionHeight = posHeight; |
tyleralt | 0:ded79d89abdf | 23 | positionDistance = posDistance; |
tyleralt | 1:bb1507f0bb64 | 24 | offAngles[0] = -6; |
tyleralt | 0:ded79d89abdf | 25 | offAngles[1] = 174; |
tyleralt | 0:ded79d89abdf | 26 | offAngles[2] = 44; |
tyleralt | 0:ded79d89abdf | 27 | offAngles[3] = 228; |
tyleralt | 0:ded79d89abdf | 28 | offAngles[4] = 90; |
tyleralt | 0:ded79d89abdf | 29 | offAngles[5] = 270; |
tyleralt | 0:ded79d89abdf | 30 | offAngles[6] = 135; |
tyleralt | 1:bb1507f0bb64 | 31 | offAngles[7] = 323; |
tyleralt | 0:ded79d89abdf | 32 | } |
tyleralt | 0:ded79d89abdf | 33 | int Point :: getArraySlice (void){ |
tyleralt | 0:ded79d89abdf | 34 | return (int) (positionRadian + (offAngles[positionHeight]))%360; |
tyleralt | 0:ded79d89abdf | 35 | } |
tyleralt | 0:ded79d89abdf | 36 | char Point :: getIdentifyingChar(void){ |
tyleralt | 0:ded79d89abdf | 37 | return 0x01 << positionHeight; |
tyleralt | 0:ded79d89abdf | 38 | } |
tyleralt | 0:ded79d89abdf | 39 | int Point :: getPositionDistance(void){ |
tyleralt | 4:f1e33a234a74 | 40 | return positionDistance; |
tyleralt | 0:ded79d89abdf | 41 | } |
tyleralt | 0:ded79d89abdf | 42 | void Point :: moveUp(){ |
tyleralt | 0:ded79d89abdf | 43 | if (positionHeight < 7){ |
tyleralt | 0:ded79d89abdf | 44 | positionHeight ++; |
tyleralt | 0:ded79d89abdf | 45 | } |
tyleralt | 0:ded79d89abdf | 46 | } |
tyleralt | 0:ded79d89abdf | 47 | void Point :: moveDown(){ |
tyleralt | 0:ded79d89abdf | 48 | if(positionHeight > 0){ |
tyleralt | 0:ded79d89abdf | 49 | positionHeight --; |
tyleralt | 0:ded79d89abdf | 50 | } |
tyleralt | 0:ded79d89abdf | 51 | } |
tyleralt | 0:ded79d89abdf | 52 | void Point :: rotateRight(){ |
tyleralt | 0:ded79d89abdf | 53 | positionRadian = (positionRadian + 1) % 360; |
tyleralt | 0:ded79d89abdf | 54 | } |
tyleralt | 0:ded79d89abdf | 55 | void Point :: rotateLeft(){ |
tyleralt | 0:ded79d89abdf | 56 | positionRadian = (positionRadian - 1) % 360; |
tyleralt | 0:ded79d89abdf | 57 | } |
tyleralt | 0:ded79d89abdf | 58 | void Point :: moveIn(){ |
tyleralt | 0:ded79d89abdf | 59 | if (positionDistance > 0){ |
tyleralt | 0:ded79d89abdf | 60 | positionDistance --; |
tyleralt | 0:ded79d89abdf | 61 | } |
tyleralt | 0:ded79d89abdf | 62 | } |
tyleralt | 0:ded79d89abdf | 63 | void Point :: moveOut(){ |
tyleralt | 0:ded79d89abdf | 64 | if (positionDistance < 15){ |
tyleralt | 0:ded79d89abdf | 65 | positionDistance ++; |
tyleralt | 0:ded79d89abdf | 66 | } |
tyleralt | 0:ded79d89abdf | 67 | } |