Created
April 20, 2015 04:32
-
-
Save Softwave/e61e98a84382876bcd5e to your computer and use it in GitHub Desktop.
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
Config.title = ['BANANA', 'WARFARE'] | |
Config.backgroundColor = '#fe7777' | |
#'#7109aa' | |
window.initialize = -> | |
Sound.setSeed 1248 | |
@drums = [] | |
@drums.push Game.newSound().setDrum().setDrumPattern() for i in [1..4] | |
window.begin = -> | |
drum.playPattern() for drum in @drums | |
new Player if Game.isBeginning | |
Game.stage = 0 | |
Game.newFiber() | |
.doOnce -> | |
Game.stage++ | |
ev = (0.01.rr 0.02) * Game.getDifficulty() | |
for y in [1..6] | |
new BadGuy -y * 0.1, ev | |
.doRepeat -> | |
@next() if (Actor.s BadGuy).length == 0 | |
window.update = -> | |
class Player extends Actor | |
initialize: -> | |
Player.sndKilled = @newSound().setVolume(3).setDrum() | |
begin: -> | |
@drawing | |
.setColor '#ffff00' | |
.addRect 0.01, 0.03, 0.01, -0.01 | |
.addRect 0.02, 0.05, 0, -0.01 | |
.addRect 0.02, 0.02, -0.01, -0.03 | |
.addRect 0.02, 0.02, -0.01, 0.02 | |
.addRect 0.015, 0.015, -0.02, -0.04 | |
.addRect 0.015, 0.015, -0.02, 0.03 | |
.setColor '#000000' | |
.addRect 0.015, 0.015, -0.025, -0.045 | |
.addRect 0.015, 0.015, -0.025, 0.035 | |
@newFiber() | |
.doOnce => | |
new Shot @pos if Mouse.ip | |
.wait 6 | |
update: -> | |
@pos.setValue Mouse.pos | |
@destroy() if @onCollision BadGuy | |
destroy: -> | |
@newParticle() | |
.setColor '#ffff00' | |
.setSize 0.02 | |
.setNumber 15 | |
.setSpeed 0.05 | |
@newParticle() | |
.setColor '#000000' | |
.setSize 0.02 | |
.setNumber 5 | |
.setSpeed 0.05 | |
Player.sndKilled.playNow() | |
@remove() | |
Game.end() | |
class Shot extends Actor | |
begin: (p) -> | |
@drawing | |
.setColor "#0000ff" | |
.addRect 0.02, 0.02, 0, 0 | |
@pos.setValue p | |
@vel.y = -0.03 | |
update: -> | |
@remove() if [email protected]() | |
class BadGuy extends Actor | |
initialize: -> | |
BadGuy.sndKilled = @newSound().setDrum() | |
begin: (y, vy) -> | |
@drawing | |
.setColor "#eeeeee" | |
.addRect 0.05, 0.01, 0, 0 | |
.setColor "#eeeeee" | |
.addRect 0.05, 0.01, 0, 0.02 | |
.setColor "#aa00ff" | |
.addRect 0.08, 0.02, 0, 0.01 | |
@pos.setXy (0.1.rr 0.9), y | |
@vel.y = vy | |
if Math.random()<.5 | |
@vel.x = 0.002 | |
else | |
@vel.x = -0.002 | |
update: -> | |
if @onCollision Shot, ((shot) -> shot.remove()) | |
BadGuy.sndKilled.play() | |
if Game.isBeginning | |
score = Game.stage * 10 | |
@newText "+#{score}" | |
.setVelocity 0, -0.1 | |
.setDuration 30 | |
Game.score += score | |
@newParticle() | |
.setColor "#eeeeee" | |
.setNumber 2 | |
@newParticle() | |
.setColor "#aa00ff" | |
.setNumber 3 | |
@remove() | |
@remove() if @pos.y > 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment