Changeset 108 for pycodeshooter/trunk/shooter/action.js
- Timestamp:
- 01/17/12 01:34:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pycodeshooter/trunk/shooter/action.js
r103 r108 104 104 105 105 that.index = 0; 106 that.shot = function(trooper, enem y) {106 that.shot = function(trooper, enemies) { 107 107 if (isSetSwitch(SWITCH_BULLET)) { 108 108 if (++this.index >= trooper.barrages.length) … … 115 115 } 116 116 if (isInAction(ACTION_SHOT)) 117 trooper.barrages[this.index].update(trooper, enem y);117 trooper.barrages[this.index].update(trooper, enemies); 118 118 }; 119 119 … … 125 125 126 126 that.index = 0; 127 that.shot = function(trooper, enem y) {128 if (trooper.barrages[this.index].update(trooper, enem y))127 that.shot = function(trooper, enemies) { 128 if (trooper.barrages[this.index].update(trooper, enemies)) 129 129 this.index = Math.floor(Math.random() * trooper.barrages.length); 130 130 }; … … 140 140 141 141 that.i = 0; 142 that.shot = function(trooper, enem y) {143 if (trooper.barrages[this.index].update(trooper, enem y)) {142 that.shot = function(trooper, enemies) { 143 if (trooper.barrages[this.index].update(trooper, enemies)) { 144 144 if (++this.i > count) { 145 145 this.index++; … … 169 169 var Action = function(shot) { 170 170 this.shot = shot; 171 this.update = function(trooper, enem y) {171 this.update = function(trooper, enemies) { 172 172 if (trooper.isDead()) 173 173 return; 174 this.shot.shot(trooper, enem y);175 return this.move(trooper, enem y);176 }; 177 this.move = function(trooper, enem y) {174 this.shot.shot(trooper, enemies); 175 return this.move(trooper, enemies); 176 }; 177 this.move = function(trooper, enemies) { 178 178 return true; 179 179 }; … … 183 183 var that = new Action(shot); 184 184 185 that.move = function(trooper, enem y) {185 that.move = function(trooper, enemies) { 186 186 var x = 0; 187 187 var y = 0; … … 216 216 that.resolution = 0; 217 217 218 that.move = function(trooper, enem y) {218 that.move = function(trooper, enemies) { 219 219 if (this.count >= this.resolution) { 220 220 this.count = 0; 221 221 this.resolution = resolution / trooper.speed; 222 222 223 this.p0 = this.getPoint0(trooper, enem y);224 this.p1 = this.getPoint1(trooper, enem y);225 this.p2 = this.getPoint2(trooper, enem y);226 this.p3 = this.getPoint3(trooper, enem y);223 this.p0 = this.getPoint0(trooper, enemies); 224 this.p1 = this.getPoint1(trooper, enemies); 225 this.p2 = this.getPoint2(trooper, enemies); 226 this.p3 = this.getPoint3(trooper, enemies); 227 227 } 228 228 … … 254 254 var that = new BezierAction(shot, resolution); 255 255 256 that.getPoint0 = function(trooper, enem y) {256 that.getPoint0 = function(trooper, enemies) { 257 257 return [trooper.x, trooper.y]; 258 258 }; 259 that.getPoint1 = function(trooper, enem y) {259 that.getPoint1 = function(trooper, enemies) { 260 260 return [trooper.x - (trooper.speed * 10), 261 261 trooper.y + (trooper.speed * 10)]; 262 262 }; 263 that.getPoint2 = function(trooper, enem y) {263 that.getPoint2 = function(trooper, enemies) { 264 264 return [trooper.x + (trooper.speed * 10), 265 265 trooper.y + (trooper.speed * 10)]; 266 266 }; 267 that.getPoint3 = function(trooper, enem y) {267 that.getPoint3 = function(trooper, enemies) { 268 268 return [trooper.x, trooper.y]; 269 269 }; … … 275 275 var that = new BezierAction(shot, resolution); 276 276 277 that.getPoint0 = function(trooper, enem y) {277 that.getPoint0 = function(trooper, enemies) { 278 278 return [trooper.x, trooper.y]; 279 279 }; 280 that.getPoint1 = function(trooper, enem y) {280 that.getPoint1 = function(trooper, enemies) { 281 281 return [Math.floor(Math.random() * trooper.w), 282 282 Math.floor(Math.random() * trooper.h)]; 283 283 }; 284 that.getPoint2 = function(trooper, enem y) {284 that.getPoint2 = function(trooper, enemies) { 285 285 return [Math.floor(Math.random() * trooper.w), 286 286 Math.floor(Math.random() * trooper.h)]; 287 287 }; 288 that.getPoint3 = function(trooper, enem y) {288 that.getPoint3 = function(trooper, enemies) { 289 289 return [Math.floor(Math.random() * trooper.w), 290 290 Math.floor(Math.random() * trooper.h)]; … … 297 297 var that = new RandomAction(shot, resolution); 298 298 299 that.getPoint3 = function(trooper, enem y) {299 that.getPoint3 = function(trooper, enemies) { 300 300 return [Math.floor(Math.random() * trooper.w), trooper.y]; 301 301 }; … … 307 307 var that = new RandomAction(shot, resolution); 308 308 309 that.getPoint3 = function(trooper, enemy) { 310 return [enemy.x, Math.floor(Math.random() * trooper.h)]; 309 that.getPoint3 = function(trooper, enemies) { 310 var x = enemies.length ? enemies[0].x : 0; 311 return [x, Math.floor(Math.random() * trooper.h)]; 311 312 }; 312 313 … … 317 318 var that = new RandomAction(shot, resolution); 318 319 319 that.getPoint3 = function(trooper, enemy) { 320 return [enemy.x, trooper.y]; 320 that.getPoint3 = function(trooper, enemies) { 321 var x = enemies.length ? enemies[0].x : 0; 322 return [x, trooper.y]; 321 323 }; 322 324 … … 332 334 this.list = list; 333 335 this.index = 0; 334 this.update = function(trooper, enem y) {335 this.updateIdx(this.list[this.index].update(trooper, enem y),336 trooper, enem y);337 }; 338 this.updateIdx = function(end, trooper, enem y) {336 this.update = function(trooper, enemies) { 337 this.updateIdx(this.list[this.index].update(trooper, enemies), 338 trooper, enemies); 339 }; 340 this.updateIdx = function(end, trooper, enemies) { 339 341 this.index = 0; 340 342 }; … … 344 346 var that = new ActionList(list); 345 347 346 that.updateIdx = function(end, trooper, enem y) {348 that.updateIdx = function(end, trooper, enemies) { 347 349 if (end) 348 350 this.index = Math.floor(Math.random() * this.list.length); … … 359 361 360 362 that.i = 0; 361 that.updateIdx = function(end, trooper, enem y) {363 that.updateIdx = function(end, trooper, enemies) { 362 364 if (end) { 363 365 if (++this.i > count) { … … 385 387 386 388 that.life = 0; 387 that.updateIdx = function(end, trooper, enem y) {389 that.updateIdx = function(end, trooper, enemies) { 388 390 if (!this.life) 389 391 this.life = trooper.life; … … 402 404 403 405 that.life = 0; 404 that.updateIdx = function(end, trooper, enem y) {406 that.updateIdx = function(end, trooper, enemies) { 405 407 if (!this.life) 406 408 this.life = trooper.life;
Note: See TracChangeset
for help on using the changeset viewer.