Changeset 119 for pycodeshooter/trunk/index.html
- Timestamp:
- 01/22/12 03:41:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/index.html
r118 r119 14 14 <script type="text/javascript"> 15 15 window.onload = function () { 16 // load enemies17 16 var req = new XMLHttpRequest(); 18 17 req.open("GET", document.getElementById("api").value, false); … … 23 22 var msg = document.getElementById("message"); 24 23 var screen = document.getElementById("screen"); 24 var soundCheck = document.getElementById("sound"); 25 25 var ctx = screen.getContext("2d"); 26 26 var enemyList = JSON.parse(req.responseText).result; 27 27 28 registerSound("bgm_title", document.getElementById("bgm_title")); 29 registerSound("bgm_stage1", document.getElementById("bgm_stage1")); 30 registerSound("se_start", document.getElementById("se_start")); 31 registerSound("se_encounter", document.getElementById("se_encounter")); 32 registerSound("se_damage_enemy", document.getElementById("se_damage_enemy")); 33 registerSound("se_damage_player", document.getElementById("se_damage_player")); 34 registerSound("se_bomb", document.getElementById("se_bomb")); 35 registerSound("se_destroy", document.getElementById("se_destroy")); 28 36 setMessage(msg, "<br />"); 29 37 38 // sound on/off 39 soundCheck.onclick = function() { 40 toggleSound(soundCheck.checked); 41 }; 42 soundCheck.click(); 43 30 44 // title screen set 45 var titlebgm = document.getElementById("bgm_title"); 31 46 var logoimg = document.getElementById("logoimg"); 32 47 var x = (screen.width - logoimg.width) / 2; … … 49 64 }, 20); 50 65 66 playSound("bgm_title"); 67 51 68 // start game 52 69 screen.onclick = function() { … … 55 72 } 56 73 57 clearInterval(titleIntervalId); 58 titleIntervalId = 0; 59 60 var player = { 61 "name": document.getElementById("name").value, 62 "image": document.getElementById("p_img0"), 63 "size": parseInt(document.getElementById("size").value), 64 "hitsize": parseInt(document.getElementById("hitsize").value), 65 "speed": parseInt(document.getElementById("speed").value), 66 "hitpoint": parseInt(document.getElementById("hitpoint").value), 67 "shotsize": parseInt(document.getElementById("shotsize").value), 68 "shotinterval": parseInt(document.getElementById("shotinterval").value), 69 "shotspeed": parseInt(document.getElementById("shotspeed").value), 70 "shotlevel": parseInt(document.getElementById("shotlevel").value), 71 "numbombs": parseInt(document.getElementById("numbombs").value) 72 }; 73 74 for (var n in player) { 75 if (n == "name") 76 continue; 77 if (!player[n] || player[n] < 0) { 78 setMessage(msg, "Invalid Input Data"); 79 return; 74 titlebgm.pause(); 75 playSound("se_start"); 76 77 setTimeout(function() { 78 clearInterval(titleIntervalId); 79 titleIntervalId = 0; 80 81 var player = { 82 "name": document.getElementById("name").value, 83 "image": document.getElementById("p_img0"), 84 "size": parseInt(document.getElementById("size").value), 85 "hitsize": parseInt(document.getElementById("hitsize").value), 86 "speed": parseInt(document.getElementById("speed").value), 87 "hitpoint": parseInt(document.getElementById("hitpoint").value), 88 "shotsize": parseInt(document.getElementById("shotsize").value), 89 "shotinterval": parseInt(document.getElementById("shotinterval").value), 90 "shotspeed": parseInt(document.getElementById("shotspeed").value), 91 "shotlevel": parseInt(document.getElementById("shotlevel").value), 92 "numbombs": parseInt(document.getElementById("numbombs").value) 93 }; 94 95 for (var n in player) { 96 if (n == "name") 97 continue; 98 if (!player[n] || player[n] < 0) { 99 setMessage(msg, "Invalid Input Data"); 100 return; 101 } 80 102 } 81 } 82 83 var imgs = document.getElementsByTagName("img");84 for (var i = 0; i < imgs.length; i++) {85 if (imgs[i].getAttribute("id").match(/^e_img/)) {86 addEnemyImage(imgs[i]);103 104 var imgs = document.getElementsByTagName("img"); 105 for (var i = 0; i < imgs.length; i++) { 106 if (imgs[i].getAttribute("id").match(/^e_img/)) { 107 addEnemyImage(imgs[i]); 108 } 87 109 } 88 } 89 90 document.onkeydown = function (ev) { setKeyDown(ev.keyCode); }; 91 document.onkeyup = function (ev) { setKeyUp(ev.keyCode); }; 92 document.onkeypress = function (ev) { setKeyPress(ev.charCode); }; 93 94 initGame(document.getElementById("screen"), msg, player); 95 96 var enemyIntervalId = setInterval(function() { 97 if (numEnemies() < parseInt(document.getElementById("numenemies").value)) { 98 var ids = Object.keys(enemyList); 99 var id = ids[Math.floor(Math.random() * ids.length)]; 100 addEnemy(enemyList[id]); 101 } 102 }, 1500); 110 111 document.onkeydown = function (ev) { setKeyDown(ev.keyCode); }; 112 document.onkeyup = function (ev) { setKeyUp(ev.keyCode); }; 113 document.onkeypress = function (ev) { setKeyPress(ev.charCode); }; 114 115 playSound("bgm_stage1"); 116 initGame(document.getElementById("screen"), msg, player); 117 118 var enemyIntervalId = setInterval(function() { 119 if (numEnemies() < parseInt(document.getElementById("numenemies").value)) { 120 var ids = Object.keys(enemyList); 121 var id = ids[Math.floor(Math.random() * ids.length)]; 122 playSound("se_encounter"); 123 addEnemy(enemyList[id]); 124 } 125 }, 1500); 126 }, 1400); 103 127 }; 104 128 }; … … 126 150 æ§: <input type="text" value="5" size="3" id="hitpoint" /> 127 151 ãã æ°: <input type="text" value="2" size="3" id="numbombs" /> 152 é³æ¥œ: <input type="checkbox" checked="checked" id="sound" /> 128 153 <br /> 129 154 <canvas id="screen" width="320" height="480"></canvas> … … 138 163 <input type="hidden" value="/etc/pycodebattler/?mode=json" id="api" /> 139 164 <img src="images/logo.png" style="visibility: hidden;" id="logoimg" /> 165 166 <audio src="sounds/bgm_sht_a01.mp3", id="bgm_title" loop="true" preload="auto" /> 167 <audio src="sounds/bgm_sht_a02.mp3", id="bgm_stage1" loop="true" preload="auto" /> 168 <audio src="sounds/se_coinin_1.mp3", id="se_start" preload="auto" /> 169 <audio src="sounds/se_denshion_1.mp3", id="se_encounter" preload="auto" /> 170 <audio src="sounds/se_pyuun.mp3", id="se_damage_player" preload="auto" /> 171 <audio src="sounds/se_click_2.mp3", id="se_damage_enemy" preload="auto" /> 172 <audio src="sounds/se_zusyunzusyun.mp3", id="se_bomb" preload="auto" /> 173 <audio src="sounds/se_zugan.mp3", id="se_destroy" preload="auto" /> 140 174 141 175 <img src="images/ma1s.gif" style="visibility: hidden;" id="p_img0" /> … … 210 244 <li>ãã¯ãŒã¢ããã¢ã€ãã </li> 211 245 <li>åäœãåã</li> 212 <li>é³ã鳎ãã</li>213 246 </ul> 214 247 … … 221 254 <ul style="font-size: small;"> 222 255 <li><a href="http://www.civillink.net/">ããªãŒçŽ æã®æ¥å€¢æ¥äºº</a></li> 256 <li><a href="http://www.skipmore.com/sound/">ãŠãŠã©ã8bitãµãŠã³ãå·¥æ¿</a></li> 223 257 </ul> 224 258 </div>
Note: See TracChangeset
for help on using the changeset viewer.