diff --git a/source/Sprite.cpp b/source/Sprite.cpp index e2763fd..27882b4 100644 --- a/source/Sprite.cpp +++ b/source/Sprite.cpp @@ -27,7 +27,7 @@ void Sprite::move(float dx, float dy, bool overrideOOB) { const float newY = this->y + dy; if (!((unsigned)(newX-1) <= 398 && (unsigned)(newY-1) <= 238)) { return; - } + } } this->x += dx; diff --git a/source/main.cpp b/source/main.cpp index e91a14a..1fe35ca 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -84,6 +84,7 @@ int main(int argc, char* argv[]) { // init gravity calc vars float a = 0.4; // acceleration float v = 0; // velocity + float pipeSpeed = -1.2; // set bg properties sprites[SPR_BG].setPosition(200, 120); @@ -106,17 +107,23 @@ int main(int argc, char* argv[]) { sprites[SPR_BIRD].move(0, v); C2D_SpriteSetRotationDegrees(sprites[SPR_BIRD].spr, v*9.8); - sprites[SPR_PIPETOP].move(-3, 0, true); - sprites[SPR_PIPEBOTTOM].move(-3, 0, true); + if (kDown & KEY_A) { v = -5.5; - // moveSprite(&sprites[SPR_BIRD], 0, v); sprites[SPR_BIRD].move(0, v); // temp score = num of flaps score++; } + sprites[SPR_PIPETOP].move(pipeSpeed, 0, true); + sprites[SPR_PIPEBOTTOM].move(pipeSpeed, 0, true); + + if (sprites[SPR_PIPETOP].getPosX() < -10) { + sprites[SPR_PIPETOP].setPosition(SCREEN_WIDTH, 3); + sprites[SPR_PIPEBOTTOM].setPosition(SCREEN_WIDTH, 280); + } + // make score text char scoreString[(((sizeof score) * CHAR_BIT) + 2)/3 + 2]; sprintf(scoreString, "%d", score);