I am learning OOP using c++ on a MicroBit by developing this simple game
gameEngine/source/game.cpp@0:17bdfb0e7069, 2020-07-08 (annotated)
- Committer:
- ahmeou
- Date:
- Wed Jul 08 16:35:55 2020 +0000
- Revision:
- 0:17bdfb0e7069
- Child:
- 1:25f13b341b11
qualified name not allowed error happened after working fine; reason: unknown
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ahmeou | 0:17bdfb0e7069 | 1 | #include "game.h" |
ahmeou | 0:17bdfb0e7069 | 2 | |
ahmeou | 0:17bdfb0e7069 | 3 | Sprite::Sprite(){ |
ahmeou | 0:17bdfb0e7069 | 4 | setX(0); |
ahmeou | 0:17bdfb0e7069 | 5 | setY(0); |
ahmeou | 0:17bdfb0e7069 | 6 | } |
ahmeou | 0:17bdfb0e7069 | 7 | |
ahmeou | 0:17bdfb0e7069 | 8 | Sprite::Sprite(int x, int y){ |
ahmeou | 0:17bdfb0e7069 | 9 | setX(x); |
ahmeou | 0:17bdfb0e7069 | 10 | setY(y); |
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 | } |