Changeset 119 for pycodeshooter/trunk/shooter
- Timestamp:
- 01/22/12 03:41:27 (13 years ago)
- Location:
- pycodeshooter/trunk/shooter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/shooter/system.js
r117 r119 21 21 "height": 0 22 22 }, 23 "sound": {}, 23 24 "message": null, 24 25 "enemyImages": new Array(), … … 186 187 187 188 if (enemy.isDead()) { 189 playSound("se_destroy"); 190 188 191 addDeathPieces( 189 192 enemy.x, enemy.y, … … 202 205 203 206 trooper.draw(System.screen.ctx); 207 } 208 209 function toggleSound(val) { 210 for (var name in System.sound) 211 System.sound[name].muted = !val; 212 } 213 214 function registerSound(name, audio) { 215 System.sound[name] = audio; 216 } 217 218 function playSound(name) { 219 if (System.sound[name]) 220 System.sound[name].play(); 204 221 } 205 222 … … 287 304 brrgs 288 305 ); 306 enemy.registerCallback("damaged", function() {playSound("se_damage_enemy")}); 289 307 290 308 System.enemies.push(enemy); … … 415 433 ); 416 434 417 System.players.push(new Trooper(435 var trooper = new Trooper( 418 436 playerData.name, 419 437 new ActionList([new ManualAction(new ManualShot())]), … … 455 473 playerData.shotlevel + 2, 456 474 -0.5)] 457 )); 475 ); 476 trooper.registerCallback("addBomb", function() {playSound("se_bomb")}); 477 trooper.registerCallback("damaged", function() {playSound("se_damage_player")}); 478 479 System.players.push(trooper); 458 480 459 481 for (var i = 0; i < System.players.length; i++) { -
pycodeshooter/trunk/shooter/trooper.js
r114 r119 75 75 76 76 this.bullets = new Array(); 77 this.callbacks = {}; 77 78 this.bomb = null; 78 79 this.name = name; … … 172 173 173 174 // update my life 174 if (hit && this.life > 0) 175 if (hit && this.life > 0) { 175 176 this.life--; 177 178 if (this.callbacks["damaged"]) 179 this.callbacks["damaged"](this); 180 } 176 181 } 177 182 }; … … 215 220 this.bullets.push( 216 221 new bulletType(size, color, frame, this.w, this.h, this.x + x, this.y + y, dir, speed)); 222 223 if (this.callbacks["addBullet"]) 224 this.callbacks["addBullet"](this); 217 225 }; 218 226 … … 242 250 this.size * 2, 10, this.bombColors); 243 251 this.numBombs--; 244 } 252 253 if (this.callbacks["addBomb"]) 254 this.callbacks["addBomb"](this); 255 } 256 }; 257 258 this.registerCallback = function(name, callback) { 259 this.callbacks[name] = callback; 245 260 }; 246 261 }
Note: See TracChangeset
for help on using the changeset viewer.