flash on 2014-10-3
♥0 |
Line 83 |
Modified 2014-10-03 01:25:32 |
MIT License
archived:2017-03-30 11:54:01
ActionScript3 source code
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zyVV
*/
package {
import flash.display.Shape;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
canvas = new BitmapData(450,450, false, 0);
map = new BitmapData(1024,1024, false, 0xFFffFFff);
//make random map
graphics.clear();
var i:int;
for (i =0; i < 64; i++)
{
graphics.beginFill(0+(Math.random()*64), 1);
graphics.drawEllipse(256+Math.random()*512,Math.random()*256+512,Math.random()*256+32, Math.random()*256+32);
}//nexti
map.draw(this);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var canvas:BitmapData;
public var map:BitmapData;
public var camx:Number = 0;
public var camy:Number = 0;
//bullet
public var cx:Number = 0;
public var cy:Number = 1024;
//explosion
public var px:Number = 0;
public var py:Number = 0;
public var pr:Number = 0;
public var tempShape:Shape = new Shape();
public var tempMat:Matrix = new Matrix();
public function onEnter(e:Event):void
{
var mx:Number;
var my:Number;
mx = stage.mouseX;
my = stage.mouseY;
camx = mx*(1024/450) - 225;
camy = my*(1024/450) - 225;
if (camx < 0) { camx = 0; }
if (camy < 0) { camy = 0; }
if (camx >= 1024-450) { camx = 1024-450;}
if (camy >= 1024-450) { camy = 1024-450;}
tempMat.identity();
tempMat.translate(-camx, -camy);
canvas.draw(map, tempMat);
tempShape.graphics.clear();
tempShape.graphics.beginFill(0, 1);
tempShape.graphics.drawCircle(cx-camx,cy-camy,8);
tempShape.graphics.endFill();
canvas.draw(tempShape);
if (pr > 0)
{
tempShape.graphics.clear();
tempShape.graphics.beginFill(0xFFFF0000, 1);
tempShape.graphics.drawCircle(px-camx,py-camy,pr);
tempShape.graphics.endFill();
canvas.draw(tempShape);
pr *=0.85;
if (pr < 4) { pr = -1;}
}//endif
graphics.clear();
graphics.beginBitmapFill(canvas);
graphics.drawRect(0,0,450,450);
graphics.endFill();
cy += 16;
if (cy >= 1024)
{ cy = 0; cx = Math.random()*512+256; }
if (map.getPixel(cx,cy) < 0xFF)
{
px = cx; py = cy; pr = 32+Math.random()*32;
tempShape.graphics.clear();
tempShape.graphics.beginFill(0x00ffFFff, 1);
tempShape.graphics.drawCircle(cx,cy,pr);
tempShape.graphics.endFill();
map.draw(tempShape);
cy = 0; cx = Math.random()*512+256;
}//endif
}//onenter
}//classend
}