加速していく
/**
* Copyright aaaaaz025 ( http://wonderfl.net/user/aaaaaz025 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/m6LP
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
private var bullets:Array;
private var frame:int = 0;
private var degree:int = 0;
public function Main()
{
graphics.beginFill(0x000000); //0xカラーコード(背景色)
graphics.drawRect(0, 0, 465, 465); //背景の幅
graphics.endFill();
bullets = new Array();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
if (frame++ % 1 == 0) //1度間隔でスピードアップ
{
var radian:Number = Math.PI * 360 * Math.PI / 180;
var bullet:Bullet = new Bullet(0xFFF8DC, 20, 232, 70, Math.cos(degree * Math.PI / 173), Math.sin(degree * Math.PI / 173),Math.PI);
addChild(bullet);
bullets.push(bullet);
degree += 7;
var radian:Number = Math.PI * 360 * Math.PI / 180;
var bullet:Bullet = new Bullet(0xDC143C, 7, 232, 70, Math.cos(degree * Math.PI / 173), Math.sin(degree * Math.PI / 173),Math.PI);
addChild(bullet);
bullets.push(bullet);
degree += 3;
var radian:Number = Math.PI * 360 * Math.PI / 180;
var bullet:Bullet = new Bullet(0xDC143C, 7, 232, 70, Math.cos(degree * Math.PI / 173), Math.sin(degree * Math.PI / 173),Math.PI);
addChild(bullet);
bullets.push(bullet);
degree += 3;
var radian:Number = Math.PI * 360 * Math.PI / 180;
var bullet:Bullet = new Bullet(0xDC143C, 7, 232, 70, Math.cos(degree * Math.PI / 173), Math.sin(degree * Math.PI / 173),Math.PI);
addChild(bullet);
bullets.push(bullet);
degree += 3;
var radian:Number = Math.PI * 360 * Math.PI / 180;
var bullet:Bullet = new Bullet(0xDC143C, 7, 232, 70, Math.cos(degree * Math.PI / 173), Math.sin(degree * Math.PI / 173),Math.PI);
addChild(bullet);
bullets.push(bullet);
degree += 3;
}
for (var i:int = 0; i < bullets.length; i++)
{
bullets[i].move();
if (bullets[i].check())
{
removeChild(bullets[i]);
bullets.splice(i--, 1);
}
}
}
}
}
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
class Bullet extends Sprite
{
public var px:Number;
public var py:Number;
public var vx:Number;
public var vy:Number;
public var speed:Number;
public function Bullet(color:int, radius:int, x:int, y:int, vx:Number, vy:Number, speed:Number)
{
graphics.beginFill(color);
graphics.drawCircle(0, 0, radius);
graphics.endFill();
this.filters = [new DropShadowFilter(2, 0, 0x0)];
this.x = this.px = x;
this.y = this.py = y;
this.vx = vx;
this.vy = vy;
this.speed = speed;
}
public function move():void
{
this.px += vx * speed;
this.py += vy * speed;
this.x = px;
this.y = py;
}
public function check():Boolean
{
if (x < -50 || stage.stageWidth + 50 < x ||
y < -50 || stage.stageHeight + 50 < y)
{
return true;
}
return false;
}
}