Changeset 106 for pycodeshooter/trunk
- Timestamp:
- 01/26/11 02:40:22 (14 years ago)
- Location:
- pycodeshooter/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/index.html
r97 r106 120 120 <input type="hidden" value="7" id="shotsize" /> 121 121 <input type="hidden" value="5" id="shotspeed" /> 122 <input type="hidden" value=" 10"id="shotinterval" />122 <input type="hidden" value="5" id="shotinterval" /> 123 123 <input type="hidden" value="3" id="shotlevel" /> 124 124 <input type="hidden" value="/etc/pycodebattler/?mode=json" id="api" /> -
pycodeshooter/trunk/shooter/barrage.js
r96 r106 14 14 */ 15 15 16 var Barrage = function(bullet, size, color, interval, speed, way, dir) {16 var Barrage = function(bullet, size, color, frame, interval, speed, way, dir) { 17 17 this.bullet = bullet; 18 18 this.size = size; 19 19 this.color = color; 20 this.frame = frame; 20 21 this.interval = interval; 21 22 this.speed = speed; … … 44 45 }; 45 46 46 var LinerBarrage = function(bullet, size, color, interval, speed, way, dir) {47 var that = new Barrage(bullet, size, color, interval, speed, way, dir);47 var LinerBarrage = function(bullet, size, color, frame, interval, speed, way, dir) { 48 var that = new Barrage(bullet, size, color, frame, interval, speed, way, dir); 48 49 49 50 that.state = 0; … … 55 56 56 57 trooper.addBullet(this.bullet, this.size, this.color, 57 this. posX(), this.posY(),58 this.frame, this.posX(), this.posY(), 58 59 dir * Math.PI, this.speed); 59 60 … … 62 63 63 64 trooper.addBullet(this.bullet, this.size, this.color, 64 this. posX(), this.posY(),65 this.frame, this.posX(), this.posY(), 65 66 (dir - d) * Math.PI, this.speed); 66 67 trooper.addBullet(this.bullet, this.size, this.color, 67 this. posX(), this.posY(),68 this.frame, this.posX(), this.posY(), 68 69 (dir + d) * Math.PI, this.speed); 69 70 } … … 76 77 }; 77 78 78 var ArchBarrage = function(bullet, size, color, 79 var ArchBarrage = function(bullet, size, color, frame, 79 80 interval, speed, way, dir, delta) { 80 81 81 var that = new Barrage(bullet, size, color, interval, speed, way, dir);82 var that = new Barrage(bullet, size, color, frame, interval, speed, way, dir); 82 83 83 84 that.delta = delta; 84 85 85 if ( that.way % 2)86 if (!(that.way % 2)) 86 87 that.way++; 87 88 … … 94 95 return false; 95 96 96 var angle = this.angle(trooper, enemy) - (this.delta * this.way/ 2);97 var angle = this.angle(trooper, enemy) - (this.delta * (this.way - 1) / 2); 97 98 98 99 for (var i = 0; i < this.way; i++) { 99 100 trooper.addBullet(this.bullet, this.size, this.color, 100 this. posX(), this.posY(),101 this.frame, this.posX(), this.posY(), 101 102 angle * Math.PI, this.speed); 102 103 angle += this.delta; … … 110 111 }; 111 112 112 var CircularBarrage = function(bullet, size, color, 113 var CircularBarrage = function(bullet, size, color, frame, 113 114 interval, speed, way, dir) { 114 if (way % 2) 115 way++; 116 117 var that = new ArchBarrage(bullet, size, color, 115 var that = new ArchBarrage(bullet, size, color, frame, 118 116 interval, speed, way, dir, 2 / way); 119 117 return that; 120 } 121 122 var DelayedArchBarrage = function(bullet, size, color, 118 }; 119 120 var DelayedArchBarrage = function(bullet, size, color, frame, 123 121 interval, speed, way, dir, delta) { 124 122 125 var that = new Barrage(bullet, size, color, interval, speed, way, dir);123 var that = new Barrage(bullet, size, color, frame, interval, speed, way, dir); 126 124 127 125 that.delta = delta; 128 126 129 if ( that.way % 2)127 if (!(that.way % 2)) 130 128 that.way++; 131 129 … … 143 141 if (this.curAngle == null) 144 142 this.curAngle = this.angle(trooper, enemy) - 145 this.delta * (this.way / 2);143 this.delta * (this.way - 1) / 2; 146 144 147 145 trooper.addBullet(this.bullet, this.size, this.color, 148 this. posX(), this.posY(),146 this.frame, this.posX(), this.posY(), 149 147 this.curAngle * Math.PI, this.speed); 150 151 this.curAngle += this.delta;152 148 153 149 if (--this.remain <= 0) { 154 150 return this.reset(); 155 151 } 152 153 this.curAngle += this.delta; 156 154 157 155 return false; … … 167 165 }; 168 166 169 var DelayedCircularBarrage = function(bullet, size, color, 167 var DelayedCircularBarrage = function(bullet, size, color, frame, 170 168 interval, speed, way, dir) { 171 if (way % 2) 172 way++; 173 174 var that = new DelayedArchBarrage(bullet, size, color, 169 var that = new DelayedArchBarrage(bullet, size, color, frame, 175 170 interval, speed, way, dir, 2 / way); 176 171 return that; 177 172 }; 178 173 179 var DelayedRecursiveArchBarrage = function(bullet, size, color, 174 var DelayedRecursiveArchBarrage = function(bullet, size, color, frame, 180 175 interval, speed, way, dir, cnt) { 181 176 182 var that = new DelayedArchBarrage(bullet, size, color, 177 var that = new DelayedArchBarrage(bullet, size, color, frame, 183 178 interval, speed, way, dir); 184 179 … … 204 199 }; 205 200 206 var DelayedRecursiveCircularBarrage = function(bullet, size, color, 201 var DelayedRecursiveCircularBarrage = function(bullet, size, color, frame, 207 202 interval, speed, way, dir, cnt) { 208 203 209 var that = new DelayedCircularBarrage(bullet, size, color, 204 var that = new DelayedCircularBarrage(bullet, size, color, frame, 210 205 interval, speed, way, dir); 211 206 … … 230 225 }; 231 226 232 var MultiRounderBarrage = function(bullet, size, color, 227 var MultiRounderBarrage = function(bullet, size, color, frame, 233 228 interval, speed, way, dir, 234 229 klass, radius, num) { 230 if (way < 3) 231 way = 3; 232 235 233 if (radius == null) { 236 radius = size * way ;234 radius = size * way * 3; 237 235 if (radius > 50) 238 236 radius = 50; … … 240 238 241 239 if (num == null) 242 num = Math.ceil((1 / way) * 5 0);240 num = Math.ceil((1 / way) * 5); 243 241 244 242 var start = 0.25; … … 251 249 252 250 for (var i = 0; i < num; i++) { 253 var b = new klass(bullet, size, color, 251 var b = new klass(bullet, size, color, frame, 254 252 interval, speed, w, dir); 255 253 … … 286 284 }; 287 285 288 var MultiRounderArchBarrage = function(bullet, size, color, 286 var MultiRounderArchBarrage = function(bullet, size, color, frame, 289 287 interval, speed, way, dir) { 290 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 291 way, dir, ArchBarrage); 292 return that; 293 }; 294 295 var MultiRounderCircularBarrage = function(bullet, size, color, 296 interval, speed, way, dir) { 297 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 298 way, dir, CircularBarrage); 299 return that; 300 }; 301 302 var MultiRounderDelayedArchBarrage = function(bullet, size, color, 288 var that = new MultiRounderBarrage(bullet, size, color, frame, 289 interval, speed, way, dir, ArchBarrage); 290 return that; 291 }; 292 293 var MultiRounderDelayedArchBarrage = function(bullet, size, color, frame, 303 294 interval, speed, way, dir) { 304 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 305 way, dir, DelayedArchBarrage); 306 return that; 307 }; 308 309 var MultiRounderDelayedCircularBarrage = function(bullet, size, color, 310 interval, speed, way, dir) { 311 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 312 way, dir, DelayedCircularBarrage); 313 return that; 314 }; 315 316 var MultiRounderDelayedRecursiveArchBarrage = function(bullet, size, color, 295 var that = new MultiRounderBarrage(bullet, size, color, frame, 296 interval, speed, way, dir, DelayedArchBarrage); 297 return that; 298 }; 299 300 var MultiRounderDelayedRecursiveArchBarrage = function(bullet, size, color, frame, 317 301 interval, speed, way, dir) { 318 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 319 way, dir, DelayedRecursiveArchBarrage); 320 return that; 321 }; 322 323 var MultiRounderDelayedRecursiveCircularBarrage = function(bullet, size, color, 324 interval, speed, way, dir) { 325 var that = new MultiRounderBarrage(bullet, size, color, interval, speed, 326 way, dir, DelayedRecursiveCircularBarrage); 302 var that = new MultiRounderBarrage(bullet, size, color, frame, 303 interval, speed, way, dir, DelayedRecursiveArchBarrage); 327 304 return that; 328 305 }; … … 337 314 DelayedRecursiveCircularBarrage, 338 315 MultiRounderArchBarrage, 339 MultiRounderCircularBarrage,340 316 MultiRounderDelayedArchBarrage, 341 MultiRounderDelayedCircularBarrage, 342 MultiRounderDelayedRecursiveArchBarrage, 343 MultiRounderDelayedRecursiveCircularBarrage]; 317 MultiRounderDelayedRecursiveArchBarrage] -
pycodeshooter/trunk/shooter/bullet.js
r105 r106 14 14 */ 15 15 16 var Bullet = function(size, color, x, y, dir, speed) {16 var Bullet = function(size, color, frame, x, y, dir, speed) { 17 17 this.size = size; 18 18 this.color = color; 19 this.frame = frame; 19 20 this.x = x; 20 21 this.y = y; … … 22 23 this.speed = speed; 23 24 25 this.getSize = function() { 26 return this.size; 27 }; 28 this.getColor = function() { 29 return this.color; 30 }; 31 this.next = function() { 32 var pos = this.calcNext(); 33 this.x = pos[0]; 34 this.y = pos[1]; 35 }; 36 this.vanished = function(width, height) { 37 return (width < this.x || height < this.y || this.x < 0 || this.y < 0); 38 }; 24 39 this.draw = function(ctx) { 40 if (this.frame) { 41 var pos = this.calcNext(); 42 var dir = Math.atan2(pos[0] - this.x, this.y - pos[1]); 43 44 ctx.save(); 45 46 if (this.frame.style == "rect") { 47 ctx.beginPath(); 48 ctx.strokeStyle = this.frame.color; 49 ctx.translate(this.x, this.y); 50 ctx.rotate(dir); 51 ctx.rect(-this.frame.width / 2, -this.frame.height / 2, 52 this.frame.width, this.frame.height); 53 ctx.stroke(); 54 ctx.closePath(); 55 } 56 57 ctx.restore(); 58 } 59 25 60 ctx.beginPath(); 26 61 ctx.fillStyle = this.getColor(); … … 29 64 ctx.closePath(); 30 65 }; 31 this.vanished = function(width, height) {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;39 };40 66 }; 41 67 42 var LinerBullet = function(size, color, x, y, dir, speed) {43 var that = new Bullet(size, color, x, y, dir, speed);68 var LinerBullet = function(size, color, frame, x, y, dir, speed) { 69 var that = new Bullet(size, color, frame, x, y, dir, speed); 44 70 45 71 that.deltaBaseX = Math.cos(that.dir); 46 72 that.deltaBaseY = Math.sin(that.dir); 47 73 48 that.next = function() { 49 this.x += this.getDeltaX(); 50 this.y += this.getDeltaY(); 74 that.calcNext = function() { 75 return [this.x + this.getDeltaX(), this.y + this.getDeltaY()]; 51 76 }; 52 77 that.getDeltaX = function() { … … 60 85 }; 61 86 62 var AxisExtendBullet = function(size, color, x, y, dir, speed) {63 var that = new LinerBullet(size, color, x, y, dir, speed);87 var AxisExtendBullet = function(size, color, frame, x, y, dir, speed) { 88 var that = new LinerBullet(size, color, frame, x, y, dir, speed); 64 89 65 90 that.dx = that.speed * that.deltaBaseX / 1.5; … … 80 105 }; 81 106 82 var XYExtendBullet = function(size, color, x, y, dir, speed) {83 var that = new AxisExtendBullet(size, color, x, y, dir, speed);107 var XYExtendBullet = function(size, color, frame, x, y, dir, speed) { 108 var that = new AxisExtendBullet(size, color, frame, x, y, dir, speed); 84 109 85 110 that.i = 1; … … 94 119 }; 95 120 96 var XExtendBullet = function(size, color, x, y, dir, speed) {97 var that = new AxisExtendBullet(size, color, x, y, dir, speed);121 var XExtendBullet = function(size, color, frame, x, y, dir, speed) { 122 var that = new AxisExtendBullet(size, color, frame, x, y, dir, speed); 98 123 99 124 that.i = 1; … … 108 133 }; 109 134 110 var YExtendBullet = function(size, color, x, y, dir, speed) {111 var that = new AxisExtendBullet(size, color, x, y, dir, speed);135 var YExtendBullet = function(size, color, frame, x, y, dir, speed) { 136 var that = new AxisExtendBullet(size, color, frame, x, y, dir, speed); 112 137 113 138 that.i = 1; … … 122 147 }; 123 148 124 var CurveBullet = function(size, color, x, y, dir, speed) {125 var that = new Bullet(size, color, x, y, dir, speed);149 var CurveBullet = function(size, color, frame, x, y, dir, speed) { 150 var that = new Bullet(size, color, frame, x, y, dir, speed); 126 151 127 152 that.delta = 1 / (that.speed * 100); 128 153 that.i = 1; 129 154 130 that. next = function() {131 this.x +=Math.cos(this.dir) * this.i;132 this.y +=Math.sin(this.dir) * this.i;155 that.calcNext = function() { 156 var x = this.x + Math.cos(this.dir) * this.i; 157 var y = this.y + Math.sin(this.dir) * this.i; 133 158 this.dir += (this.delta / this.i) * this.getSign(); 134 159 this.i += (this.delta / this.i); 160 return [x, y]; 135 161 }; 136 162 … … 138 164 }; 139 165 140 var LeftCurveBullet = function(size, color, x, y, dir, speed) {141 var that = new CurveBullet(size, color, x, y, dir, speed);166 var LeftCurveBullet = function(size, color, frame, x, y, dir, speed) { 167 var that = new CurveBullet(size, color, frame, x, y, dir, speed); 142 168 143 169 that.getSign = function() { … … 148 174 }; 149 175 150 var RightCurveBullet = function(size, color, x, y, dir, speed) {151 var that = new CurveBullet(size, color, x, y, dir, speed);176 var RightCurveBullet = function(size, color, frame, x, y, dir, speed) { 177 var that = new CurveBullet(size, color, frame, x, y, dir, speed); 152 178 153 179 that.getSign = function() { -
pycodeshooter/trunk/shooter/system.js
r104 r106 35 35 */ 36 36 var DeathPiece = function(sizes, colors, x, y, dir, speed) { 37 var that = new LinerBullet(sizes[0], colors[0], x, y, dir, speed);37 var that = new LinerBullet(sizes[0], colors[0], null, x, y, dir, speed); 38 38 39 39 var sizeIdx = -1; … … 64 64 var s = Math.ceil(Math.random() * 5); 65 65 System.backgroundObject.push( 66 new LinerBullet(size, color, x, 0, 0.5 * Math.PI, s));66 new LinerBullet(size, color, null, x, 0, 0.5 * Math.PI, s)); 67 67 } 68 68 … … 205 205 System.screen.ctx, 206 206 "source-over", 207 "rgba(8,8,8,0. 5)",207 "rgba(8,8,8,0.8)", 208 208 System.screen.width, 209 209 System.screen.height … … 300 300 [new LinerBarrage(YExtendBullet, 301 301 playerData.shotsize, 302 "#3FF", 302 "rgba(64,64,128,0.7)", 303 null, 303 304 playerData.shotinterval, 304 305 playerData.shotspeed, … … 307 308 new LinerBarrage(YExtendBullet, 308 309 playerData.shotsize, 309 "#3FF", 310 "rgba(64,64,128,0.7)", 311 null, 310 312 playerData.shotinterval, 311 313 playerData.shotspeed, … … 314 316 new CircularBarrage(LinerBullet, 315 317 playerData.shotsize, 316 "#3FF", 318 "rgba(64,64,128,0.7)", 319 null, 317 320 playerData.shotinterval, 318 321 playerData.shotspeed, … … 329 332 var brrgs = new Array(); 330 333 331 setMessage(System.message, "ActionsIdx:"); 334 var bulletWay = Math.ceil(bossData.concentration / 10); 335 var bulletInterval = Math.round(50 * 1 / Math.log(bossData.skillpoint + 0.1)); 336 var bulletSize = Math.round(Math.log(bossData.luck + 1)); 337 var bulletFrameWidth = (bulletSize + 5) * 2; 338 var bulletFrameHeight = (bulletSize + 5) * 4; 339 var bulletSpeed = bossData.strength / 15; 340 bulletSpeed = Math.log(bulletSpeed < 1.5 ? 1.5 : bulletSpeed); 341 342 setMessage(System.message, ""); 343 addMessage(System.message, " bulletWay:" + String(bulletWay) + "<br>"); 344 addMessage(System.message, " bulletInterval:" + String(bulletInterval) + "<br>"); 345 addMessage(System.message, " bulletSize:" + String(bulletSize) + "<br>"); 346 addMessage(System.message, " bulletSpeed:" + String(bulletSpeed) + "<br>"); 347 348 addMessage(System.message, "ActionsIdx:"); 332 349 333 350 for (var i = 0; i < numAct; i++) { … … 350 367 for (var k = 0; k < numBlt; k++) { 351 368 var iidx = (bossData.skills.length + i + k) % EnemyBullets.length; 352 var ss = Math.log(bossData.luck * 15);353 var sp = bossData.strength / 15;354 sp = sp < 1.5 ? 1.5 : sp;355 369 brrgs.push( 356 370 new brrgCls( 357 371 EnemyBullets[iidx], 358 ss < 3 ? 3 : ss,372 bulletSize, 359 373 "#FF3", 360 200 * 1 / Math.log(bossData.skillpoint + 0.1), 361 Math.log(sp), 362 Math.ceil(bossData.concentration / 5) 374 {"style": "rect", "color": "rgba(128,32,32,0.5)", 375 "width": bulletFrameWidth, "height": bulletFrameHeight}, 376 bulletInterval, 377 bulletSpeed, 378 bulletWay 363 379 ) 364 380 ); … … 370 386 } 371 387 372 var size = Math.ceil( 50* (1 / bossData.defense));388 var size = Math.ceil((System.screen.width / 2) * (1 / bossData.defense)); 373 389 size = size < playerData.size ? playerData.size : size; 374 390 System.boss = new Trooper( -
pycodeshooter/trunk/shooter/trooper.js
r103 r106 163 163 this.bomb.draw(ctx); 164 164 165 // draw bullets 166 for (var i = 0; i < this.bullets.length; i++) 167 this.bullets[i].draw(ctx); 168 165 169 // draw trooper 166 170 ctx.beginPath(); … … 177 181 ctx.closePath(); 178 182 } 179 180 // draw bullets 181 for (var i = 0; i < this.bullets.length; i++) 182 this.bullets[i].draw(ctx); 183 }; 184 185 this.addBullet = function(bulletType, size, color, x, y, dir, speed) { 183 }; 184 185 this.addBullet = function(bulletType, size, color, frame, x, y, dir, speed) { 186 186 this.bullets.push( 187 new bulletType(size, color, this.x + x, this.y + y, dir, speed));187 new bulletType(size, color, frame, this.x + x, this.y + y, dir, speed)); 188 188 }; 189 189
Note: See TracChangeset
for help on using the changeset viewer.