I am learning OOP using c++ on a MicroBit by developing this simple game
gameEngine/source/game.cpp@3:a21366e3261e, 2020-07-09 (annotated)
- Committer:
- ahmeou
- Date:
- Thu Jul 09 06:04:17 2020 +0000
- Revision:
- 3:a21366e3261e
- Parent:
- 1:25f13b341b11
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ahmeou | 1:25f13b341b11 | 1 | #include "Sprite.h" |
ahmeou | 0:17bdfb0e7069 | 2 | |
ahmeou | 0:17bdfb0e7069 | 3 | Sprite::Sprite(){ |
ahmeou | 1:25f13b341b11 | 4 | m_x = 0; |
ahmeou | 1:25f13b341b11 | 5 | m_y = 0; |
ahmeou | 0:17bdfb0e7069 | 6 | } |
ahmeou | 0:17bdfb0e7069 | 7 | |
ahmeou | 0:17bdfb0e7069 | 8 | Sprite::Sprite(int x, int y){ |
ahmeou | 1:25f13b341b11 | 9 | m_x = 0; |
ahmeou | 1:25f13b341b11 | 10 | m_y = 0; |
ahmeou | 0:17bdfb0e7069 | 11 | } |
ahmeou | 0:17bdfb0e7069 | 12 | |
ahmeou | 0:17bdfb0e7069 | 13 | void Sprite::setX(int x){ |
ahmeou | 0:17bdfb0e7069 | 14 | m_x = x; |
ahmeou | 0:17bdfb0e7069 | 15 | } |
ahmeou | 0:17bdfb0e7069 | 16 | |
ahmeou | 0:17bdfb0e7069 | 17 | void Sprite::setY(int y){ |
ahmeou | 0:17bdfb0e7069 | 18 | m_y = y; |
ahmeou | 0:17bdfb0e7069 | 19 | } |
ahmeou | 0:17bdfb0e7069 | 20 | |
ahmeou | 0:17bdfb0e7069 | 21 | int Sprite::getX(){ |
ahmeou | 0:17bdfb0e7069 | 22 | return m_x; |
ahmeou | 0:17bdfb0e7069 | 23 | } |
ahmeou | 0:17bdfb0e7069 | 24 | |
ahmeou | 0:17bdfb0e7069 | 25 | int Sprite::getY(){ |
ahmeou | 0:17bdfb0e7069 | 26 | return m_y; |
ahmeou | 0:17bdfb0e7069 | 27 | } |
ahmeou | 0:17bdfb0e7069 | 28 | |
ahmeou | 0:17bdfb0e7069 | 29 | bool Sprite::hitBy(Sprite another){ |
ahmeou | 0:17bdfb0e7069 | 30 | return m_x == another.getX() && m_y == another.getY(); |
ahmeou | 0:17bdfb0e7069 | 31 | } |