Changeset 123 for pycodeshooter/trunk/shooter
- Timestamp:
- 01/22/12 20:21:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/shooter/system.js
r122 r123 27 27 "players": new Array(), 28 28 "score": {}, 29 "stage": -1, 29 30 "backgroundObject": new Array(), 30 31 "deathPieces": new Array(), … … 207 208 } 208 209 209 function switchStage Bgm() {210 var s um = 0;211 var s tage = 1;212 var stages = new Array();213 var base = 50000;214 var s core = 0;215 var s cores = Object.keys(System.score);210 function switchStage(base) { 211 var scores = Object.keys(System.score); 212 var sum = 0; 213 var stages = new Array(); 214 var score = 0; 215 var stage = 1; 216 var switched = false; 216 217 217 218 for (var i = 0; i < scores.length; i++) { 218 219 sum += System.score[scores[i]]; 219 220 } 220 score = Math.round(sum / scores.length);221 221 222 222 for (var name in System.sound) { … … 224 224 stages.push(name); 225 225 } 226 stage = Math.floor((score % (stages.length * base)) / base) + 1; 227 228 for (var i = 0; i < stages.length; i++) { 229 if (("bgm_stage" + stage) == stages[i]) { 230 playSound(stages[i]); 231 } 232 else { 233 pauseSound(stages[i], true); 234 } 226 227 score = Math.round(sum / scores.length); 228 stage = Math.floor((score % (stages.length * base)) / base) + 1; 229 switched = System.stage != stage; 230 System.stage = stage; 231 232 return switched; 233 } 234 235 function switchBgm(stage) { 236 for (var name in System.sound) { 237 if (!name.match(/^bgm_stage/)) 238 continue; 239 if (("bgm_stage" + stage) == name) 240 playSound(name); 241 else 242 pauseSound(name, true); 235 243 } 236 244 } … … 368 376 ); 369 377 370 switchStageBgm(); 378 // switch stage 379 if (switchStage(50000)) 380 switchBgm(System.stage); 371 381 372 382 // draw score
Note: See TracChangeset
for help on using the changeset viewer.