HOME | DD

Published: 2009-04-26 18:10:16 +0000 UTC; Views: 3164; Favourites: 25; Downloads: 39
Redirect to original
Description
Yes I am dead xDThis is the first thing I made in actionscript, I tryed to add some of the new functions.
The source code:
import flash.display.Sprite;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
var grav:Number=0.9;
var circles:Array=[];
var bitmapdata
var bitmap
var bitmap2
var bitmap3
var bitmap4
var bitmap5
var bitmap6
var color:ColorTransform=new ColorTransform(5,5,5,0.1,0,0,0,0);
bitmap.rotationY=-90;
bitmap2.z=550;
bitmap3.x=550;
bitmap3.rotationY=-90;
bitmap4.rotationX=90
bitmap5.y=550;
bitmap5.rotationX=90
bitmap6.alpha = 0.2;
addChild(bitmap);
addChild(bitmap2);
addChild(bitmap3);
addChild(bitmap4);
addChild(bitmap5);
addChild(bitmap6);
stage.addEventListener(MouseEvent.CLICK,Create);
stage.addEventListener(Event.ENTER_FRAME,Run);
stage.addEventListener(Event.ENTER_FRAME,MoveCircle);
function Run(event:Event) {
bitmapdata.draw(bitmapdata,new Matrix(),color);
}
function MoveCircle(event:Event) {
for (var i:Number=0; i
circles[i].y+=circles[i].vy;
circles[i].vy+=grav;
var matrix:Matrix = new Matrix();
matrix.translate(circles[i].x,circles[i].y);
bitmapdata.draw(circles[i],matrix);
for (var j:Number=0; j
var dx:Number=circles[j].x-circles[i].x;
var dy:Number=circles[j].y-circles[i].y;
var dis:Number=Math.sqrt(dx*dx+dy*dy);
if (dis<30) {
var diff:Number=dis-30;
var ang:Number=Math.atan2(dy,dx);
circles[i].x=circles[j].x-Math.cos(ang)*30;
circles[i].y=circles[j].y-Math.sin(ang)*30;
circles[j].x=circles[i].x+Math.cos(ang)*30;
circles[j].y=circles[i].y+Math.sin(ang)*30;
circles[i].vx+=Math.cos(ang)*diff;
circles[i].vy+=Math.sin(ang)*diff;
}
}
}
if (circles[i].y>535) {
circles[i].y=535;
circles[i].vy=- Math.abs(circles[i].vy)*0.5;
circles[i].vx*=0.8;
}
if (circles[i].y<15) {
circles[i].y=15;
circles[i].vy=Math.abs(circles[i].vy)*0.5;
circles[i].vx*=0.8;
}
if (circles[i].x>535) {
circles[i].x=535;
circles[i].vx=- Math.abs(circles[i].vx)*0.5;
circles[i].vy*=0.8;
}
if (circles[i].x<15) {
circles[i].x=15;
circles[i].vx=Math.abs(circles[i].vx)*0.5;
circles[i].vy*=0.8;
}
}
}
function Create(event:MouseEvent) {
var cir:Circle = new Circle();
cir.x=mouseX;
cir.y=mouseY;
cir.vx=0;
cir.vy=0;
cir.visible=false;
addChild(cir);
circles.push(cir);
}
Related content
Comments: 17
Salorethefox [2009-06-10 01:34:35 +0000 UTC]
DUDE it looks like im in a tiny room and there are balls all around me!
👍: 0 ⏩: 0
PanicCloud [2009-05-07 16:43:36 +0000 UTC]
Awesome!
Just randomly click around a ton of times and it goes crazy!
👍: 0 ⏩: 1
psykopath [2009-04-27 10:20:59 +0000 UTC]
Nice I actually haven't used any of the new 3d functions yet, would I be able to see the source?
👍: 0 ⏩: 1
NinjitsuWarrior In reply to psykopath [2009-04-27 10:44:20 +0000 UTC]
Of course you are!
Ill put it in the Artist Comment.
👍: 0 ⏩: 1
psykopath In reply to NinjitsuWarrior [2009-04-27 11:10:08 +0000 UTC]
Awesome, that's way simpler than I thought. Thanks heaps
👍: 0 ⏩: 1
NinjitsuWarrior In reply to psykopath [2009-04-27 11:52:00 +0000 UTC]
Oh man no problem, never thought I could actually help YOU xD
👍: 0 ⏩: 0
roboprez [2009-04-27 10:06:30 +0000 UTC]
This is one of the coolest things I've seen in a while
👍: 0 ⏩: 1