Changeset 95
- Timestamp:
- 01/17/11 20:28:17 (14 years ago)
- Location:
- pycodeshooter/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/index.html
r93 r95 175 175 <li>æµ/èªæ©ã«ç»åãšã</li> 176 176 <li>ã¡ãã¥ãŒãäœãšããã</li> 177 <li> æç Ž/ãã¡ãŒãž/æ»äº¡æåäœãåã</li>177 <li>ãã¡ãŒãžæåäœãåã</li> 178 178 </ul> 179 179 -
pycodeshooter/trunk/shooter/bullet.js
r81 r95 24 24 this.draw = function(ctx) { 25 25 ctx.beginPath(); 26 ctx.fillStyle = this. color;27 ctx.arc(this.x, this.y, this. size, 0, Math.PI * 2.0, true);26 ctx.fillStyle = this.getColor(); 27 ctx.arc(this.x, this.y, this.getSize(), 0, Math.PI * 2.0, true); 28 28 ctx.fill(); 29 29 ctx.closePath(); … … 31 31 this.vanished = function(width, height) { 32 32 return (width < this.x || height < this.y || this.x < 0 || this.y < 0); 33 }; 34 this.getSize = function() { 35 return this.size; 36 }; 37 this.getColor = function() { 38 return this.color; 33 39 }; 34 40 }; -
pycodeshooter/trunk/shooter/system.js
r92 r95 25 25 "player": null, 26 26 "backgroundObject": new Array(), 27 "deathPieces": new Array(), 28 "gameOver": false, 27 29 "mainIntervalId": 0 30 }; 31 32 33 /* 34 * Tiun Tiun 35 */ 36 var DeathPiece = function(sizes, colors, x, y, dir, speed) { 37 var that = new LinerBullet(sizes[0], colors[0], x, y, dir, speed); 38 39 var sizeIdx = -1; 40 var colorIdx = -1; 41 42 that.getSize = function() { 43 if (++sizeIdx >= sizes.length) 44 sizeIdx = 0; 45 return sizes[sizeIdx]; 46 }; 47 48 that.getColor = function() { 49 if (++colorIdx >= colors.length) 50 colorIdx = 0; 51 return colors[colorIdx]; 52 }; 53 54 return that; 28 55 }; 29 56 … … 48 75 } 49 76 System.backgroundObject = newObjs; 77 } 78 79 function updateDeathPieces(ctx, width, height, x, y, sizes, colors, speed, way) { 80 if (System.deathPieces.length <= 0) { 81 if (way % 2) 82 way++; 83 84 var angle = 0; 85 var delta = 2 / way; 86 87 for(i = 0; i < way; i++) { 88 System.deathPieces.push( 89 new DeathPiece(sizes, colors, x, y, angle * Math.PI, speed)); 90 angle += delta; 91 } 92 } 93 94 var newObjs = new Array(); 95 for (i = 0; i < System.deathPieces.length; i++) { 96 System.deathPieces[i].next(); 97 System.deathPieces[i].draw(ctx); 98 if (!System.deathPieces[i].vanished(width, height)) 99 newObjs.push(System.deathPieces[i]); 100 } 101 System.deathPieces = newObjs; 102 103 return !System.deathPieces.length; 50 104 } 51 105 … … 97 151 } 98 152 153 function updateTrooper(trooper, enemy) { 154 if (System.gameOver) { 155 trooper.clearBullet(); 156 enemy.clearBullet(); 157 158 drawString( 159 System.screen.ctx, "source-over", 160 "GAME OVER", 161 System.screen.width / 2, 162 System.screen.height / 2, 163 "#ACF", "24pt monospace", "center" 164 ); 165 } 166 else if (trooper.isDead()) { 167 trooper.clearBullet(); 168 enemy.clearBullet(); 169 170 System.gameOver = updateDeathPieces( 171 System.screen.ctx, 172 System.screen.width, 173 System.screen.height, 174 trooper.x, 175 trooper.y, 176 [6, 8, 10], ["#55F", "#AAF"], 3, 8 177 ); 178 } 179 else if (enemy.isDead()) { 180 trooper.draw(System.screen.ctx); 181 } 182 else { 183 trooper.update(enemy); 184 trooper.draw(System.screen.ctx); 185 } 186 } 187 99 188 function setMessage(elem, msg) { 100 189 if (elem) … … 129 218 ); 130 219 131 // update troopers 132 System.player.update(System.boss); 133 System.boss.update(System.player); 134 135 // draw troopers 136 System.player.draw(System.screen.ctx); 137 System.boss.draw(System.screen.ctx); 220 // update/draw troopers 221 updateTrooper(System.player, System.boss); 222 updateTrooper(System.boss, System.player); 138 223 139 224 // draw player name/life … … 169 254 System.screen.width 170 255 ); 171 172 // is dead?173 if (System.player.isDead()) {174 drawString(175 System.screen.ctx, "source-over",176 "YOU LOST",177 System.screen.width / 2,178 System.screen.height / 2,179 "#FCA", "24pt monospace", "center"180 );181 clearInterval(System.mainIntervalId);182 System.mainIntervalId = 0;183 }184 185 if (System.boss.isDead()) {186 drawString(187 System.screen.ctx, "source-over",188 "YOU WON",189 System.screen.width / 2,190 System.screen.height / 2,191 "#ACF", "24pt monospace", "center"192 );193 clearInterval(System.mainIntervalId);194 System.mainIntervalId = 0;195 }196 256 } 197 257 … … 206 266 System.screen.width = System.screen.canvas.width; 207 267 System.screen.height = System.screen.canvas.height; 268 System.gameOver = false; 208 269 209 270 System.screen.ctx.globalCompositeOperation = "lighter"; -
pycodeshooter/trunk/shooter/trooper.js
r92 r95 190 190 }; 191 191 192 this.clearBullet = function() { 193 this.bullets = new Array(); 194 }; 195 192 196 this.addBomb = function() { 193 197 if (!this.bomb && this.numBombs > 0) {
Note: See TracChangeset
for help on using the changeset viewer.