Last active
June 23, 2019 14:26
-
-
Save canadaduane/86906a28f88b71cd3790a642d331fec9 to your computer and use it in GitHub Desktop.
Generate Wave card for Game Builder
This file contains 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
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to fix bug where non-
wave
actors entering or leaving the overlapSphere could cause somewave
objects to get double-boosted.