HOME | DD

NinjitsuWarrior — AS3 Test

Published: 2009-04-26 18:10:16 +0000 UTC; Views: 3164; Favourites: 25; Downloads: 39
Redirect to original
Description Yes I am dead xD
This 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 bitmapdataitmapData=new BitmapData(550,550,true,0xFFEEEEEE);
var bitmapitmap=new Bitmap(bitmapdata,"auto",true);
var bitmap2itmap=new Bitmap(bitmapdata,"auto",true);
var bitmap3itmap=new Bitmap(bitmapdata,"auto",true);
var bitmap4itmap=new Bitmap(bitmapdata,"auto",true);
var bitmap5itmap=new Bitmap(bitmapdata,"auto",true);
var bitmap6itmap=new Bitmap(bitmapdata,"auto",true);
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].x+=circles[i].vx;
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 if (circles[i]!=circles[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

gtamythmaster43 [2011-02-25 00:57:00 +0000 UTC]

Psycho.

👍: 0 ⏩: 0

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

Mhawley1 [2009-05-18 12:30:43 +0000 UTC]

fun stuff

👍: 0 ⏩: 1

NinjitsuWarrior In reply to Mhawley1 [2009-05-21 16:42:05 +0000 UTC]

Yeah man!

👍: 0 ⏩: 0

Irule3 [2009-05-10 21:33:11 +0000 UTC]

Ooo, nice! Now thats pritty cool!

👍: 0 ⏩: 1

NinjitsuWarrior In reply to Irule3 [2009-05-15 21:29:34 +0000 UTC]

Thank you!

👍: 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

NinjitsuWarrior In reply to PanicCloud [2009-05-15 21:29:22 +0000 UTC]

Thanks ;D

👍: 0 ⏩: 0

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

NinjitsuWarrior In reply to roboprez [2009-04-27 10:44:42 +0000 UTC]

Thanks man!

👍: 0 ⏩: 1

roboprez In reply to NinjitsuWarrior [2009-04-27 10:49:01 +0000 UTC]

no probs

👍: 0 ⏩: 0

mitomane [2009-04-26 21:22:37 +0000 UTC]

cool

👍: 0 ⏩: 1

NinjitsuWarrior In reply to mitomane [2009-04-27 10:44:47 +0000 UTC]

Thanks ;D

👍: 0 ⏩: 0