the one pipe now moves independantly
This commit is contained in:
parent
9ccb5007af
commit
a3dc058f99
@ -27,7 +27,7 @@ void Sprite::move(float dx, float dy, bool overrideOOB) {
|
|||||||
const float newY = this->y + dy;
|
const float newY = this->y + dy;
|
||||||
if (!((unsigned)(newX-1) <= 398 && (unsigned)(newY-1) <= 238)) {
|
if (!((unsigned)(newX-1) <= 398 && (unsigned)(newY-1) <= 238)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->x += dx;
|
this->x += dx;
|
||||||
|
@ -84,6 +84,7 @@ int main(int argc, char* argv[]) {
|
|||||||
// init gravity calc vars
|
// init gravity calc vars
|
||||||
float a = 0.4; // acceleration
|
float a = 0.4; // acceleration
|
||||||
float v = 0; // velocity
|
float v = 0; // velocity
|
||||||
|
float pipeSpeed = -1.2;
|
||||||
|
|
||||||
// set bg properties
|
// set bg properties
|
||||||
sprites[SPR_BG].setPosition(200, 120);
|
sprites[SPR_BG].setPosition(200, 120);
|
||||||
@ -106,17 +107,23 @@ int main(int argc, char* argv[]) {
|
|||||||
sprites[SPR_BIRD].move(0, v);
|
sprites[SPR_BIRD].move(0, v);
|
||||||
C2D_SpriteSetRotationDegrees(sprites[SPR_BIRD].spr, v*9.8);
|
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) {
|
if (kDown & KEY_A) {
|
||||||
v = -5.5;
|
v = -5.5;
|
||||||
// moveSprite(&sprites[SPR_BIRD], 0, v);
|
|
||||||
sprites[SPR_BIRD].move(0, v);
|
sprites[SPR_BIRD].move(0, v);
|
||||||
// temp score = num of flaps
|
// temp score = num of flaps
|
||||||
score++;
|
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
|
// make score text
|
||||||
char scoreString[(((sizeof score) * CHAR_BIT) + 2)/3 + 2];
|
char scoreString[(((sizeof score) * CHAR_BIT) + 2)/3 + 2];
|
||||||
sprintf(scoreString, "%d", score);
|
sprintf(scoreString, "%d", score);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user