I am learning OOP using c++ on a MicroBit by developing this simple game
gameEngine/source/Spacecraft.cpp@3:a21366e3261e, 2020-07-09 (annotated)
- Committer:
- ahmeou
- Date:
- Thu Jul 09 06:04:17 2020 +0000
- Revision:
- 3:a21366e3261e
- Parent:
- 0:17bdfb0e7069
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ahmeou | 0:17bdfb0e7069 | 1 | #include "Spacecraft.h" |
ahmeou | 0:17bdfb0e7069 | 2 | |
ahmeou | 0:17bdfb0e7069 | 3 | Spacecraft::Spacecraft(){ |
ahmeou | 0:17bdfb0e7069 | 4 | setX(2); |
ahmeou | 0:17bdfb0e7069 | 5 | setY(4); |
ahmeou | 0:17bdfb0e7069 | 6 | } |
ahmeou | 0:17bdfb0e7069 | 7 | void Spacecraft::moveLeft(){ |
ahmeou | 0:17bdfb0e7069 | 8 | int x = getX() - 1; |
ahmeou | 0:17bdfb0e7069 | 9 | if(x < 0) x = 4; |
ahmeou | 0:17bdfb0e7069 | 10 | setX(x); |
ahmeou | 0:17bdfb0e7069 | 11 | } |
ahmeou | 0:17bdfb0e7069 | 12 | void Spacecraft::moveRight(){ |
ahmeou | 3:a21366e3261e | 13 | m_x = (m_x + 1) % 5; |
ahmeou | 0:17bdfb0e7069 | 14 | } |
ahmeou | 0:17bdfb0e7069 | 15 | bool Spacecraft::isBlinking(){ |
ahmeou | 0:17bdfb0e7069 | 16 | return blinking; |
ahmeou | 0:17bdfb0e7069 | 17 | } |
ahmeou | 0:17bdfb0e7069 | 18 | void Spacecraft::blink(){ |
ahmeou | 0:17bdfb0e7069 | 19 | blinking = true; |
ahmeou | 0:17bdfb0e7069 | 20 | } |