Created
April 8, 2015 05:57
-
-
Save snekse/c388fccb27e85e28128d to your computer and use it in GitHub Desktop.
Bitsbox App: Shoot the Alien
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
//Lower number means need to be accurate and is harder | |
explodeDistance = 50 | |
//Lower number means moves faster and is harder | |
howFastDoesUFOMove = 450 | |
fill('nightsky') | |
//You can name a variable whatever you want | |
bob = stamp('rocket2', 375, 900) | |
ufo = stamp('ufo2', 37, 120) | |
shot1 = shotInit() | |
shot2 = shotInit() | |
shot3 = shotInit() | |
shot2.rotate('northwest') | |
shot3.rotate('northeast') | |
//Sounds have issues on Android http://bit.ly/1y86Rf7 | |
song('forces', 20) | |
function tap() { | |
bob.move(x, y, 500) | |
ufo.move(random(768), 200, howFastDoesUFOMove) | |
} | |
function shoot() { | |
shotStart(shot1) | |
shotStart(shot2) | |
shotStart(shot3) | |
shot1.move(bob.x, -100, 1000) | |
shot2.move('northwest', 1000, 1000) | |
shot3.move('northeast', 1000, 1000) | |
} | |
function shotInit() { | |
shot = stamp('rayshot') | |
shot.hide() | |
return shot | |
} | |
function shotStart(shot) { | |
shot.show() | |
shot.move(bob.x, bob.y) | |
} | |
function loop() { | |
d1 = distance(ufo, shot1) | |
d2 = distance(ufo, shot2) | |
d3 = distance(ufo, shot3) | |
if (d1 < explodeDistance || d2 < explodeDistance || d3 < explodeDistance) { | |
ufo.explode() | |
silence() | |
sound('nuke', 30) | |
text('YOU WIN', 300, 800, 'white') | |
song('brothers', 30) | |
} | |
} | |
bob.tap = shoot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment