Last active
August 24, 2021 12:46
-
-
Save juskek/2ac644d266caeefc2ce97b4df0405af3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class FlyTerminator extends Game { | |
... | |
List<Fly>? flies; | |
Random? rnd; | |
FlyTerminator() { | |
initialize(); | |
} | |
void spawnFly() { | |
double x = rnd!.nextDouble() * (screenSize!.width - tileSize!); | |
double y = rnd!.nextDouble() * (screenSize!.height - tileSize!); | |
flies!.add(Fly(this, x, y)); | |
} | |
void initialize() async { | |
// flies = List<Fly>(); // returns null | |
flies = List<Fly>.empty(growable: true); // returns [ ] | |
... | |
rnd = Random(); | |
spawnFly(); | |
} | |
void render(Canvas canvas) { | |
... | |
flies!.forEach((Fly fly) => fly.render(canvas)); | |
} | |
void update(double t) { | |
flies!.forEach((Fly fly) => fly.update(t)); | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment