1// Generated by CoffeeScript 1.9.3 2(function() { 3 var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 4 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 5 hasProp = {}.hasOwnProperty; 6 7 this.Bowser = (function(superClass) { 8 extend(Bowser, superClass); 9 10 function Bowser(position) { 11 var next_fireball; 12 this.position = position; 13 this.die = bind(this.die, this); 14 this.attack_loop = bind(this.attack_loop, this); 15 this.dive_bomb = bind(this.dive_bomb, this); 16 this.air_attack = bind(this.air_attack, this); 17 this.throw_fireburst = bind(this.throw_fireburst, this); 18 this.throw_fireball = bind(this.throw_fireball, this); 19 this.name = "bowser"; 20 this.img_src = "./stick_figures/bowser.png"; 21 this.num_frames = 121; 22 Bowser.__super__.constructor.call(this, this.name, this.position, this.img_src, this.num_frames); 23 this.num_animations = 2; 24 this.frame_factor = 1; 25 this.is_squashed = false; 26 next_fireball = 1000; 27 this.is_moving_left = false; 28 this.is_moving_right = false; 29 this.creature_changes_direction = false; 30 this.fireball_fall_speed = -10; 31 this.fireball_player_speed = 5; 32 this.fireball_gravity_factor = 0.5; 33 this.is_invicible = true; 34 this.jump_speed = 0.0; 35 this.jump_force = 7; 36 this.terminal_jump_speed = 10; 37 this.terminal_velocity = 30; 38 this.terminal_upward_velocity = 20; 39 this.energy = 10; 40 } 41 42 Bowser.prototype.throw_fireball = function() { 43 var fireball, next_fireball; 44 fireball = new Fireball([this.position[0], this.position[1] + 20]); 45 fireball.fall_speed = this.fireball_fall_speed; 46 fireball.player_speed = this.fireball_player_speed; 47 fireball.direction = this.direction; 48 fireball.gravity_factor = this.fireball_gravity_factor; 49 fireball.die_in(10000); 50 creatures.push(fireball); 51 next_fireball = Math.random() * 10000; 52 return setTimeout(this.throw_fireball, next_fireball); 53 }; 54 55 Bowser.prototype.throw_fireburst = function() { 56 var fireball, fireballs, i, num_fireballs, x_offset; 57 num_fireballs = 10; 58 fireballs = []; 59 i = 0; 60 x_offset = (this.direction === 1) && 40 || -100; 61 while (i < 10) { 62 fireball = new Fireball([this.position[0] + x_offset, this.position[1] + 20]); 63 fireball.fall_speed = this.fireball_fall_speed + i * Math.random(); 64 fireball.player_speed = this.fireball_player_speed + i; 65 if (this.is_moving_right) { 66 fireball.direction = -1; 67 fireball.is_moving_right = true; 68 fireball.is_moving_left = false; 69 } else { 70 fireball.direction = 1; 71 fireball.is_moving_left = true; 72 fireball.is_moving_right = false; 73 } 74 fireball.gravity_factor = this.fireball_gravity_factor; 75 fireball.die_in(2000); 76 fireballs.push(fireball); 77 i += 1; 78 } 79 window.creatures = window.creatures.concat(fireballs); 80 if (this.attack_loop_enabled) { 81 return setTimeout(this.attack_loop, 1000); 82 } 83 }; 84 85 Bowser.prototype.air_attack = function() { 86 var d; 87 d = this.position[0] - stickman.position[0]; 88 if (d > 0) { 89 this.set_direction('right'); 90 } else { 91 this.set_direction('left'); 92 } 93 this.player_speed = 20 * (Math.abs(d)) / 600; 94 this.gravity_factor = 0.5; 95 this.jump(); 96 return setTimeout(this.dive_bomb, 500); 97 }; 98 99 Bowser.prototype.dive_bomb = function() { 100 this.gravity_factor = 10; 101 this.player_speed = 0; 102 return this.collision_callback = (function(_this) { 103 return function() { 104 var explosion; 105 explosion = new Explosion([_this.position[0] + 100, _this.position[1] - 100], 150); 106 explosion.dont_kill_owner = true; 107 explosion.owner = _this; 108 window.creatures.push(explosion); 109 world.shake(explosion.kill_victims); 110 if (_this.position[0] > stickman.position[0]) { 111 _this.set_direction('right'); 112 } else { 113 _this.set_direction('left'); 114 } 115 _this.player_speed = 1; 116 if (_this.attack_loop_enabled) { 117 return setTimeout(_this.attack_loop, 1000); 118 } 119 }; 120 })(this); 121 }; 122 123 Bowser.prototype.attack_loop = function() { 124 var attack, time; 125 this.attack_loop_enabled = true; 126 if (Math.random() > 0.5) { 127 attack = this.air_attack; 128 } else { 129 attack = this.throw_fireburst; 130 } 131 time = Math.random() * 2000; 132 return setTimeout(attack, time); 133 }; 134 135 Bowser.prototype.die = function() { 136 this.attack_loop_enabled = false;
137 this.is_dead = true; 138 Bowser.__super__.die.apply(this, arguments); 139 return world.end_scene(); 140 }; 141 142 return Bowser; 143 144 })(this.Creature); 145 146}).call(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.