ã¯ããã«
前回ãN-way å¼¾ãçºå°ããã¨ããã¾ã§ããã¾ãããä»åã¯æµã表示ããã¨ãããæ¸ãã¦ã¿ããã¨æãã¾ãã
ç¨æããç»å
æ¡å¤§
ãããªæµã®ç»åãç¨æãã¦ããã¾ãã横æ¹åã¯æéçµéã«ããã¢ãã¡ã¼ã·ã§ã³ã縦æ¹åãåãã§ãã
ã§ã¯ãã®ãããçµµããããªã«åããã¦ã¿ã¾ãããã
æ´æ°ã®ããå ´æã ã以ä¸ã«æç²ãã¾ãã
// direction const DIRECTION = { LEFT : 0, LEFT_FRONT : 1, FRONT : 2, RIGHT_FRONT : 3, RIGHT : 4, }; /* ------------------------------------------------------------------------- */ // Containers /* ------------------------------------------------------------------------- */ var Bullets = new Container(); var BulletCurtains = new Container(); var Enemies = new Container();ã// 追å /* ------------------------------------------------------------------------- */ // Enemy /* ------------------------------------------------------------------------- */ var Enemy = function(enemy) { Mover.call(this, enemy); }; Enemy.prototype = $.extend({}, Mover.prototype, { move : function() { Mover.prototype.move.apply(this); this.shot(); }, draw : function() { // direction var vx = this.vx, vy = Math.abs(this.vy); if ( vx/vy < -2 ) this.sy = this.h * DIRECTION.LEFT; else if ( vx/vy < -0.5 ) this.sy = this.h * DIRECTION.LEFT_FRONT; else if ( vx/vy > 2 ) this.sy = this.h * DIRECTION.RIGHT; else if ( vx/vy > 0.5 ) this.sy = this.h * DIRECTION.RIGHT_FRONT; else this.sy = this.h * DIRECTION.FRONT; // animation this.sx = this.w * (((this.cnt/5)|0) % 3); Mover.prototype.draw.apply(this); }, shot : function() {}, }); /* ------------------------------------------------------------------------- */ // Main /* ------------------------------------------------------------------------- */ function main() { var frame = 0; setInterval(function(){ if (frame%60 === 0) { //...(ç¥) Enemies.add( new Enemy({ x : WIDTH/2, y : -MARGIN, vx : -2.5 + Math.random()*5, vy : 1, key : 'enemy.red', }) ); } var containers = [BulletCurtains, Enemies, Bullets]; for (var i in containers) containers[i].move(); Canvas.clear(); for (var i in containers) containers[i].draw(); ++frame; }, 1000/FPS); }
é度ã«å¿ãã¦åããå¤ããããã«ãªãã¾ãã
ãã ããã®ã¾ã¾ã§ã¯æµã¨å¼¾ããã©ãã©ãªã®ã§æµããå¼¾ãçºå°ãããããã«ãã¦ã¿ã¾ããããï¼-Way å¼¾ãçºå°ããæµã¯ã©ã¹ Enemy3Way ãä½æãã¦ã¿ã¾ãã
/* ------------------------------------------------------------------------- */ // Enemy Variations /* ------------------------------------------------------------------------- */ // shooting 3-way bullets curtain var Enemy3Way = function(enemy) { Enemy.call(this, enemy); } Enemy3Way.prototype = $.extend({}, Enemy.prototype, { move : function() { this.vx = 5*Math.sin(Math.PI/30 * this.cnt); Enemy.prototype.move.call(this); }, shot : function() { if (this.cnt%60 === 1) { BulletCurtains.add( new BC_NWay({ nway : 3, x : this.x, y : this.y, v : 5, ang0 : Math.PI/2, dang : Math.PI/10, num : 8, period : 5, color : COLOR.RED, key : 'bullet.normal', }) ); } }, }); /* ------------------------------------------------------------------------- */ // Main /* ------------------------------------------------------------------------- */ function main() { var frame = 0; setInterval(function(){ if (frame%60 === 0) { Enemies.add( new Enemy3Way({ x : (Math.random() + 0.5)*WIDTH/2, y : -MARGIN, vx : -2 + Math.random()*5, vy : 2, key : 'enemy.red', }) ); } var containers = [BulletCurtains, Enemies, Bullets]; for (var i in containers) containers[i].move(); Canvas.clear(); for (var i in containers) containers[i].draw(); ++frame; }, 1000/FPS); } });
BC_NWay ã®çæå ´æã Enemy.xãEnemy.y ã«ãã¾ããããã¨ã¤ãã§ã«æµãããããåããããã«ãã¦ã¿ã¾ããããã¦ãã¦ã©ãã§ãããã
ããããªããéããæµããçºå°ããã¦ãããã«è¦ããªãã§ãããã¦ããªãã§ã§ãããï¼
ããã¯ãBC_NWay ãä½ã£ãç¬éã® Enemy.x 㨠Enemy.y ã®ä½ç½®ããå
¨å¼¾çºå°ããããã«ãªã£ã¦ããããã§ããããã§ã¯ãªãã¦ãæµã®ããå ´æãã常ã«çºå°ãããããã«ãããã§ãããã¨ãããã¨ã§ä»¥ä¸ã®ããã«å¤æ´ãã¾ãã
Enemy3Way.prototype = $.extend({}, Enemy.prototype, { //...ï¼ç¥ï¼ shot : function() { var cnt = this.cnt%180; if (cnt < 90 && cnt%5 === 0) { BulletCurtains.add( new BC_NWay({ nway : 3, x : this.x, y : this.y, v : 5, ang0 : Math.PI/2, dang : Math.PI/10, num : 1, period : 0, color : COLOR.RED, key : 'bullet.normal', }) ); } }, });
N-Way å¼¾ãåçºã§æã¤ããã«å¤æ´ãã¾ãããããã§æµã®åãã«åãã㦠sin ã«ã¼ããï¼å¨æãããã«æãããã«ãªãã¾ããï¼
ããã¾ã§ã®ã³ã¼ã
ãããã«
次ã¯èªæ©ã表示ãã¦æä½ããã¨ãããç´¹ä»ãããã¨æãã¾ãã