// forked from mash's Splouch by Grégoire Divaret // 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.text.*; import flash.utils.*; import flash.filters.*; import flash.geom.*; public class project73 extends Sprite { public function project73() { /** * 25-Line ActionScript Contest Entry * * Project: Splouch * Author: Grégoire Divaret // grgrdvrt.com/blog // gdivaret@gmail.com * Date: Thursday, November 27 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // 3 free lines! Alter the parameters of the following lines or remove them. // Do not substitute other code for the three lines in this section [SWF(width=1000, height=500, backgroundColor=0xCCCCCC, frameRate=24)] //stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // 25 lines begins here! //use your mouse, click! var tentacles:Array = [], ran:Function = Math.random, stw:int = stage.stageWidth, r:Number, sth:int = stage.stageHeight, sh:Shape = new Shape(), bd:BitmapData = (addChild(new Bitmap(new BitmapData(stw, sth, false, 0xFFDEDEDE))) as Bitmap).bitmapData, gr:int = 25 + Math.random() * 180, gv:int = 25 + Math.random() * 180, gb:int = 25 + Math.random() * 180, hop:Boolean = true; for(var i:int = 0; i < 15; i++) tentacles.push({x:stw/2, y:sth/2, vx:(mouseX - stw/2) / 100, vy:(mouseY - sth/2) / 100, pts:[], life:35 + ran() * 15, dir:true, r:gr + ran() * 50, v: gv + ran() * 50, b:gb + ran() * 50}); stage.addEventListener(MouseEvent.CLICK, function(e:Event){hop = !hop}); addEventListener(Event.ENTER_FRAME, animate); function animate(e:Event):void { bd.lock(); bd.fillRect(bd.rect, 0xFFDEDEDE); for each (var t:Object in tentacles) { if(t.dir)t.pts.push({vx:0, vy:0, x:t.x += (t.vx = (t.vx += ran() * 4 - 2 + (mouseX - stw/2) / 2000) * 0.95), y:t.y += (t.vy = (t.vy += ran() * 4 - 2 + (mouseY - sth/2) / 2000)* 0.95)}); 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); for(var i:int = t.pts.length-1; i >= 0 ; i--) { sh.graphics.lineStyle(Math.pow((1 - (r = i / t.pts.length)) * 10, 2) * (100 - Math.abs(t.life)) / 100, (r*r * t.r) << 16 | (r * r * t.v) << 8 | (r*r * t.b) ); sh.graphics.lineTo(t.pts[i].x+= (t.pts[i].vx = (t.pts[i].vx += (hop ? r : 1-r) * (mouseX - t.pts[i].x) / 1500) * 0.95), t.pts[i].y+= (t.pts[i].vy = (t.pts[i].vy +=(hop ? r : 1-r) * (mouseY - t.pts[i].y) / 1500) * 0.95)); } bd.draw(sh); sh.graphics.clear(); if((t.life-=0.5) <= 0 && t.dir) t.dir = false; else if(!t.dir && t.pts.length <= 1) tentacles[tentacles.indexOf(t)] = {x:t.pts[0].x, y:t.pts[0].y, vx:t.pts[0].vx, vy:t.pts[0].vy, pts:[], life:35 + ran() * 15, dir:true, r:gr + ran() * 50, v: gv + ran() * 50, b:gb + ran() * 50} } bd.unlock(); } // 25 lines ends here! } } } forked from: Splouch by Grégoire Divaret