Skip to content

Instantly share code, notes, and snippets.

@Mikepicker
Last active November 18, 2017 14:03
Show Gist options
  • Save Mikepicker/6de2c1a30f7fc1cab7a42371769a695e to your computer and use it in GitHub Desktop.
Save Mikepicker/6de2c1a30f7fc1cab7a42371769a695e to your computer and use it in GitHub Desktop.
int randInRange(int min, int max) {
return rand() % (max + 1 - min) + min;
}
void spawnZombie() {
for (int i = 0; i < ZOMBIE_COUNT; i++) {
if (!zombies[i].alive) {
zombies[i].frameX = 0;
zombies[i].frameY = 0;
zombies[i].x = randInRange(platform.x, platform.x + platform.w - zombieWidth);
zombies[i].dir = survivor.x - zombies[i].x > 0 ? 1 : -1;
zombies[i].y = 0;
zombies[i].alive = true;
zombies[i].state = "state_walk";
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment