Skip to content

Instantly share code, notes, and snippets.

@Mikepicker
Created November 20, 2017 14:07
Show Gist options
  • Save Mikepicker/916d5b5cfb3374393287cf7caeb4b7c6 to your computer and use it in GitHub Desktop.
Save Mikepicker/916d5b5cfb3374393287cf7caeb4b7c6 to your computer and use it in GitHub Desktop.
// If survivor is alive..
if (survivor.state != "state_dead") {
...
// If survivor is stabbing..
if (survivor.state == "state_stab") {
// If we're at the third animation frame, and attack has not been delivered yet..
if (survivor.frameX / survivor.animSpeed == 2 && !survivor.stab) {
survivor.stab = true;
stabZombies(); // Call the utility function
}
// If the animation is complete..
if (survivor.animCompleted) {
survivor.frameY = 0;
survivor.state = "state_idle"; // Go back to the idle state
}
}
} else { // state dead
if (survivor.animCompleted) { // Wait for death animation to complete
survivor.alive = false; // Survivor is no more
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment