// forked from mash's Bottle Glass Mountains // package, import, class definition added by mash // others are from // http://www.25lines.com/finalists/0812/073.txt package { import flash.display.*; import flash.events.*; import flash.filters.*; import flash.geom.*; import flash.text.*; import flash.utils.*; public class Splouch extends Sprite { public function Splouch() { [SWF(width=465, height=465, backgroundColor=0, frameRate=60)] stage.scaleMode = StageScaleMode.NO_SCALE; var tentacles:Array = []; var ran:Function = Math.random; var stw:int = stage.stageWidth; var r:Number; var sth:int = stage.stageHeight; var sh:Shape = new Shape(); var bd:BitmapData =new BitmapData(stw, sth, true, 0); var bmp:Bitmap = new Bitmap(bd); var gr:int = 25 + Math.random() * 180; var gv:int = 25 + Math.random() * 180; var gb:int = 25 + Math.random() * 180; var hop:Boolean = true; addChild(bmp); for(var i:int = 0; i < 15; i++){ tentacles.push(new tenta( stw/2, sth/2, (mouseX - stw/2) / 100, (mouseY - sth/2) / 100, [], 35 + ran() * 100, true, gr + ran() * 50, gv + ran() * 50, gb + ran() * 50)); } stage.addEventListener(MouseEvent.CLICK, function(e:Event):void{hop = !hop}); addEventListener(Event.ENTER_FRAME, animate); var glow0:GlowFilter = new GlowFilter(0xffffffff, 1, 16, 8, 1, 3, false, false); var glow1:GlowFilter = new GlowFilter(0xff0000ff, 1, 8, 8, 1, 3, true, false); var dropShadow0:DropShadowFilter = new DropShadowFilter(0, 90, 0x880033FF, 1, 16, 16, 5, 3, false, false, false); //var dropShadow0:DropShadowFilter = new DropShadowFilter(); bmp.filters = [glow1,glow1,dropShadow0]; function animate(e:Event):void { bd.lock(); bd.fillRect(bd.rect, 0x00ffffff); for each (var t:tenta in tentacles) { if(t.dir){ t.vx += ran() * 4 - 2 + (mouseX - stw/2) / 2000; t.vx *= 0.95; t.vy += ran() * 4 - 2 + (mouseY - sth/2) / 2000; t.vy *= 0.95; t.x +=t.vx; t.y +=t.vy; t.pts.push(new pts(t.x,t.y,0,0)); }else { t.pts.splice(t.pts.length-1, 1); } sh.graphics.moveTo(t.pts[t.pts.length-1].x, t.pts[t.pts.length-1].y); const len:uint = t.pts.length-1; if(hop){ for(var i:int =len ; i >= 0 ; i--) { /* r = i / t.pts.length; var thick:Number = Math.pow((1 - r) * 10, 2) * (100 - Math.abs(t.life)) / 100; */ r = i; var thick:Number = Math.pow((1 - (r / t.pts.length)) * 10, 2) * (100 - Math.abs(t.life)) / 100; var color:uint = ( t.r) << 16 | ( t.g) << 8 | (t.b); sh.graphics.lineStyle(thick, color,0.2); var tmp:pts = t.pts[i]; tmp.vx += r * (mouseX - tmp.x) / 1500; tmp.vx *= 0.95; tmp.x+= tmp.vx; tmp.vy += r * (mouseY - tmp.y) / 1500; tmp.vy *= 0.95; tmp.y+= tmp.vy; sh.graphics.lineTo(tmp.x, tmp.y); } }else{ for(var i:int =len ; i >= 0 ; i--) { r = i / t.pts.length; var thick:Number = Math.pow((1 - r) * 10, 2) * (100 - Math.abs(t.life)) / 100; var color:uint = ( t.r) << 16 | ( t.g) << 8 | (t.b); sh.graphics.lineStyle(thick, color,0.2); var tmp:pts = t.pts[i]; tmp.vx += (1-r) * (mouseX - tmp.x) / 1500; tmp.vx *= 0.95; tmp.x+= tmp.vx; tmp.vy += (1-r) * (mouseY - tmp.y) / 1500; tmp.vy *= 0.95; tmp.y+= tmp.vy; sh.graphics.lineTo(tmp.x, tmp.y); } } bd.draw(sh); sh.graphics.clear(); if((t.life-=0.05) <= 0 && t.dir){ t.dir = false; }else if(!t.dir && t.pts.length <= 1){ tentacles[tentacles.indexOf(t)] = new tenta( t.pts[0].x, t.pts[0].y, t.pts[0].vx, t.pts[0].vy, [], 35 + ran() * 100, true, gr + ran() * 50, gv + ran() * 50, gb + ran() * 50); } } bd.unlock(); } } } } class pts{ public var x:Number; public var y:Number; public var vx:Number; public var vy:Number; public function pts(x:Number,y:Number,vx:Number,vy:Number){ this.x = x; this.y = y; this.vx = vx; this.vy = vy; } } class tenta{ public var x:Number; public var y:Number; public var vx:Number; public var vy:Number; public var pts:Array; public var life:int; public var dir:Boolean; public var r:uint; public var g:uint; public var b:uint; public function tenta(x:Number,y:Number,vx:Number,vy:Number, pts:Array, life:int, dir:Boolean, r:uint, g:uint, b:uint){ this.x = x; this.y = y; this.vx = vx; this.vy = vy; this.pts = pts; this.life = life; this.dir = dir; this.r = r; this.g = g; this.b = b; }; } ; forked from: forked from: Splouch by Grégoire Divaret