I am learning OOP using c++ on a MicroBit by developing this simple game
Embed:
(wiki syntax)
Show/hide line numbers
game.cpp
00001 #include "Sprite.h" 00002 00003 Sprite::Sprite(){ 00004 m_x = 0; 00005 m_y = 0; 00006 } 00007 00008 Sprite::Sprite(int x, int y){ 00009 m_x = 0; 00010 m_y = 0; 00011 } 00012 00013 void Sprite::setX(int x){ 00014 m_x = x; 00015 } 00016 00017 void Sprite::setY(int y){ 00018 m_y = y; 00019 } 00020 00021 int Sprite::getX(){ 00022 return m_x; 00023 } 00024 00025 int Sprite::getY(){ 00026 return m_y; 00027 } 00028 00029 bool Sprite::hitBy(Sprite another){ 00030 return m_x == another.getX() && m_y == another.getY(); 00031 }
Generated on Sun Aug 7 2022 05:10:42 by
1.7.2