Changeset 132
- Timestamp:
- 05/05/12 05:39:04 (13 years ago)
- Location:
- pycodeshooter/trunk
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/index.html
r131 r132 13 13 <script type="text/javascript" charset="UTF-8" src="shooter/system.js"></script> 14 14 <script type="text/javascript"> 15 function updateHighScore(highscore) { 16 var table = "<tr><th>Rank</th><th>Name</th><th>Score</th><th>Time</th></tr>"; 17 18 for (var i = 0; i < highscore.length; i++) { 19 var name = highscore[i].name; 20 var score = highscore[i].value; 21 var stime = highscore[i].stime; 22 var etime = highscore[i].etime; 23 var time = etime - stime; 24 var min = Math.floor(time / 60); 25 var sec = time % 60; 26 27 table += "<tr><td>" + (i+1) + "</td><td>" + name + "</td><td>" + 28 score + "</td><td>" + min + ":" + sec + "</td></tr>"; 29 } 30 31 document.getElementById("highscore").innerHTML = 32 "<table style=\"text-align:center;\">" + table + "</table>"; 33 } 34 15 35 window.onload = function () { 16 36 var req = new XMLHttpRequest(); 37 req.open("GET", document.getElementById("api_score").value, false); 38 req.send(null); 39 updateHighScore(JSON.parse(req.responseText)); 40 41 req = new XMLHttpRequest(); 17 42 req.open("GET", document.getElementById("api").value, false); 18 43 req.send(null); … … 86 111 }; 87 112 113 if (20 < player.name.length) { 114 setMessage(msg, "Name is too long"); 115 return; 116 } 117 88 118 for (var n in player) { 89 119 if (n == "name" || n == "image") … … 103 133 104 134 setTimeout(function() { 105 initGame(document.getElementById("screen"), msg, player); 135 var stime = ~~(new Date() / 1000); 136 137 initGame(document.getElementById("screen"), msg, player, function (name, value) { 138 var etime = ~~(new Date() / 1000); 139 var url = document.getElementById("api_score").value; 140 var req = new XMLHttpRequest(); 141 req.open("GET", url + "?name=" + encodeURIComponent(name) + "&value=" + 142 value + "&stime=" + stime + "&etime=" + etime , false); 143 req.send(null); 144 updateHighScore(JSON.parse(req.responseText)); 145 }); 106 146 107 147 // auto enemy encounter … … 150 190 <input type="hidden" value="1" id="shotlevel" /> 151 191 <input type="hidden" value="/etc/pycodebattler/?mode=json" id="api" /> 192 <input type="hidden" value="score/score.cgi" id="api_score" /> 152 193 <img src="images/logo.png" style="visibility: hidden;" id="logoimg" /> 153 194 … … 239 280 </dl> 240 281 282 <p>ãã€ã¹ã³ã¢</p> 283 <span id="highscore" style="font-size: small;">Now loading...</span> 284 241 285 <p>ã·ã¹ãã ã¡ãã»ãŒãž</p> 242 286 <span id="message" style="font-size: small;">Now loading...</span> -
pycodeshooter/trunk/shooter/system.js
r131 r132 595 595 * Initializer 596 596 */ 597 function initGame(canvas, msg, playerData ) {597 function initGame(canvas, msg, playerData, scoreCallback) { 598 598 System.screen.canvas = canvas; 599 599 System.message = msg; … … 681 681 -0.5) 682 682 ]; 683 684 if (trooper.isDead() && scoreCallback) { 685 scoreCallback(trooper.name, System.score[trooper.name]); 686 } 683 687 }); 684 688
Note: See TracChangeset
for help on using the changeset viewer.