Skip to content

Instantly share code, notes, and snippets.

@canadaduane
Last active June 23, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canadaduane/86906a28f88b71cd3790a642d331fec9 to your computer and use it in GitHub Desktop.
Save canadaduane/86906a28f88b71cd3790a642d331fec9 to your computer and use it in GitHub Desktop.
Generate Wave card for Game Builder
// User-editable properties for this card:
export const PROPS = [
propNumber('range', 10)
];
// Make surrounding things tagged with "wave" do The Wave
export function onTick() {
card.cycle = (card.cycle || 0) + 1;
let actors = overlapSphere(getPos(), props.range);
actors = actors.filter(function(a) { return hasTag("wave", a); });
actors.sort(function(a1, a2) {
if (getDistanceTo(a1) < getDistanceTo(a2)) {
return 1;
} else {
return -1;
}
});
// Find all the ones tagged "wave", and make them oscillate
for (let i = 0; i < actors.length; i++) {
let actor = actors[i];
let mag = (card.cycle + i * 10) % 100 == 0 ? 5 : 0;
push(actor, getUp(mag, actor));
}
}
export function onResetGame() {
card.cycle = 0;
}
@canadaduane
Copy link
Author

Updated to fix bug where non-wave actors entering or leaving the overlapSphere could cause some wave objects to get double-boosted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment