SpaceInvaders minor draw/collide glitches
This commit is contained in:
parent
9eb7d17d6f
commit
10e836c5f8
@ -70,8 +70,11 @@ public:
|
|||||||
void step(millis_t dt) override {
|
void step(millis_t dt) override {
|
||||||
stepRockets(dt);
|
stepRockets(dt);
|
||||||
stepInvaders(dt);
|
stepInvaders(dt);
|
||||||
collide();
|
|
||||||
stepHero(dt);
|
stepHero(dt);
|
||||||
|
|
||||||
|
draw();
|
||||||
|
|
||||||
|
collide();
|
||||||
if (invadersAlive == 0) {
|
if (invadersAlive == 0) {
|
||||||
Serial.println("WINNER!");
|
Serial.println("WINNER!");
|
||||||
reset();
|
reset();
|
||||||
@ -80,13 +83,12 @@ public:
|
|||||||
Serial.println("GAME OVER");
|
Serial.println("GAME OVER");
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
draw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepRockets(millis_t dt) {
|
void stepRockets(millis_t dt) {
|
||||||
rocketRuntime += dt;
|
rocketRuntime += dt;
|
||||||
if (rocketRuntime > 200) {
|
if (rocketRuntime > 200) {
|
||||||
rocketRuntime = 0;
|
rocketRuntime -= 200;
|
||||||
for (Rocket *rocket = rocketsBegin; rocket < rocketsEnd; rocket++) {
|
for (Rocket *rocket = rocketsBegin; rocket < rocketsEnd; rocket++) {
|
||||||
if (rocket->alive) {
|
if (rocket->alive) {
|
||||||
if (rocket->y == 0) {
|
if (rocket->y == 0) {
|
||||||
@ -108,7 +110,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (swarmRuntime >= 1000) {
|
if (swarmRuntime >= 1000) {
|
||||||
swarmRuntime = 0;
|
swarmRuntime -= 1000;
|
||||||
if (swarmLeft) {
|
if (swarmLeft) {
|
||||||
swarmX--;
|
swarmX--;
|
||||||
if (swarmX == 0) {
|
if (swarmX == 0) {
|
||||||
@ -129,7 +131,7 @@ public:
|
|||||||
void stepHero(millis_t dt) {
|
void stepHero(millis_t dt) {
|
||||||
heroRuntime += dt;
|
heroRuntime += dt;
|
||||||
if (heroRuntime >= 50) {
|
if (heroRuntime >= 50) {
|
||||||
heroRuntime = 0;
|
heroRuntime -= 50;
|
||||||
if (heroLeft) {
|
if (heroLeft) {
|
||||||
heroX--;
|
heroX--;
|
||||||
if (heroX <= 1) {
|
if (heroX <= 1) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user