PDA

View Full Version : Atomic!


stealthelephant
02-05-2004, 10:49 AM
i have been thinking about this for ages now and have a nice idea layed out & came in here by mistake 1 day and was very impressed with the flower posts :) and want to see what the gurus are capable of with this 1, wont have anything posted for a while (aprox 3 weeks) cos i'm waiting for my powerbook to arrive :)
Theme is Atomic!
normal rules
happy flashing

stealthelephant
02-15-2004, 09:31 AM
i feel like i cheated ;)
this is an alpha sample :p


//fps = 50
Mouse.hide();
_root.createEmptyMovieClip("centre_mc", 1);
centre_mc._x = 100;
centre_mc._y = 100;
centre_mc.lineStyle(10, 0x123443, 100);
centre_mc.lineTo(1, 0);

_root.createEmptyMovieClip("electron_mc",2);
electron_mc.lineStyle(5,0xFF0000,100);
electron_mc.moveTo(100,100);
electron_mc.lineTo(100,101);

onEnterFrame = function(){
electron_mc._rotation += 5;
electron_mc._x = centre_mc._x = _xmouse;
electron_mc._y = centre_mc._y = _ymouse;
}


hope u guys dont find this challenge too easy :(

stealthelephant
02-15-2004, 04:12 PM
_root.createEmptyMovieClip("centre_mc", 1);
centre_mc.lineStyle(10, 0x123443, 100);
centre_mc.lineTo(1, 0);
_root.createEmptyMovieClip("innerelectron_mc", 2);
innerelectron_mc.lineStyle(5, 0xFF0000, 100);
innerelectron_mc.moveTo(25, 30);
innerelectron_mc.lineTo(24, 30);
innerelectron_mc.moveTo(-25, -30);
innerelectron_mc.lineTo(-25, -29);
_root.createEmptyMovieClip("outerelectrons_mc", 3);
outerelectrons_mc.lineStyle(5, 0xff0101, 100);
outerelectrons_mc.moveTo(0, 100);
outerelectrons_mc.lineTo(0, 101);
outerelectrons_mc.moveTo(100, 0);
outerelectrons_mc.lineTo(100, 1);
outerelectrons_mc.moveTo(0, -100);
outerelectrons_mc.lineTo(0, -99);
outerelectrons_mc.moveTo(-100, 0);
outerelectrons_mc.lineTo(-100, -1);
onEnterFrame = function () {
innerelectron_mc._rotation += 15;
outerelectrons_mc._rotation += 5;
outerelectrons_mc._x = innerelectron_mc._x=centre_mc._x=_xmouse;
outerelectrons_mc._y = innerelectron_mc._y=centre_mc._y=_ymouse;
};

thats the last of it with cheating, going to do a 3d version using vectors (which is was i was thinking of first :) )

splict
02-16-2004, 04:12 PM
okay, not exactly Atomic Kitten, but here's my first entry. Its a little messy 'cause I cut out some features and some cheating to get it properly at 25 lines. I will probably mess with it some more (add color changing effects), but I'm gonna eat dinner now. :)

The idea started as "splitting atoms." Roll your mouse over my very crude atom to split it in two. you may repeat this until you get bored. comment out the specified line to allow the original atom to be split again before it has come to a complete rest (makes for faster mayhem :rolleyes: ) Valentine's Day themed.

part = _root.createEmptyMovieClip("part0", i++);
part.beginFill(0xcd185c, 100);
part.curveTo(10, 0, 10, 10);
part.curveTo(10, 2 * 10, 0, 2 * 10);
part.curveTo(-10, 2 * 10, -10, 10);
part.curveTo(-10, 0, 0, 0);
part.endFill();
split = function () {
delete this.onRollOver; // comment me out to allow multiple splits
newpart = part.duplicateMovieClip("part" + i++, i);
newpart.xdist = Math.random() * 300 - 150;
newpart.ydist = Math.random() * 300 - 150;
newpart.startx = newpart._x = this._x;
newpart.starty = newpart._y = this._y;
newpart.friend = this;
newpart.onEnterframe = function() {
if (Math.abs(this._x - this.startx) < Math.abs(this.xdist)) {
this._x += this.xdist / 10;
this._y += this.ydist / 10;
this.friend._x -= this.xdist / 10;
this.friend._y -= this.ydist / 10;
} else {
delete this.onEnterFrame;
this.friend.onRollOver = this.onRollOver = split;
}
};
};
part.onRollOver = split;

McGiver
02-16-2004, 04:33 PM
I nominate my cells from the AI thread
http://www.actionscript.org/forums/showthread.php3?s=&threadid=29533&perpage=15&pagenumber=1
and declare them as ... err ... growing instable atoms? ;)

btw.: nice codes both :)
I will make an own if I find the time and interest

stealthelephant
02-16-2004, 05:11 PM
Originally posted by McGiver
I nominate my cells from the AI thread
http://www.actionscript.org/forums/showthread.php3?s=&threadid=29533&perpage=15&pagenumber=1
and declare them as ... err ... growing instable atoms? ;)

btw.: nice codes both :)
I will make an own if I find the time and interest

i accept, have a nice idea for that one too :)

will not be doing any coding until m'puter arrives, but will have to do some AI research and some recursion techniques research!!
[death voice]
U must challenge me to a duel heh? Nobody has ever won [/death voice]

stealthelephant
02-28-2004, 10:20 AM
this 1 is a side on view


_root.createEmptyMovieClip("electron_mc", 1);
electron_mc.lineStyle(10, 0x123443, 100);
electron_mc.lineTo(1, 0);
_root.createEmptyMovieClip("centre_mc", 2);
centre_mc.lineStyle(10, 0x123443, 100);
centre_mc.lineTo(1, 0);
electron_mc.theta = 50;
electron_mc.radius = 100;
x = setInterval(spin, 1);

function spin() {
var x = electron_mc;
x._y =x._x = x.radius * Math.cos(x.theta) ;

x.theta+=.05;


updateAfterEvent();
}


variation

_root.createEmptyMovieClip("electron_mc", 1);
drawElection(electron_mc);
_root.createEmptyMovieClip("electron2_mc", 4);
drawElection(electron2_mc);
_root.createEmptyMovieClip("electron1_mc", 3);
drawElection(electron1_mc);
_root.createEmptyMovieClip("centre_mc", 2);
drawElection(centre_mc);
electron_mc.theta = 0;
electron_mc.radius = 30;
electron1_mc.theta = 3.14127;
electron1_mc.radius = 30;
electron2_mc.theta = -1.6;
electron2_mc.radius = 70;
x = setInterval(run, 10);
function run() {

electron_mc._y = electron_mc._x = electron_mc.radius * Math.cos(electron_mc.theta) ;
electron1_mc._y = electron1_mc._x = electron1_mc.radius * Math.cos(electron1_mc.theta) ;
electron2_mc._y = electron2_mc._x = electron2_mc.radius * Math.cos( electron2_mc.theta) ;
electron_mc.theta+=.09;
electron1_mc.theta+=.09;
electron2_mc.theta+=.045;
updateAfterEvent();
}
function drawElection(elec_mc){
elec_mc.lineStyle(10, 0x123443, 100);
elec_mc.lineTo(1, 0);
}

stealthelephant
02-28-2004, 10:23 AM
frontal view

_root.createEmptyMovieClip("electron_mc", 1);
electron_mc.lineStyle(10, 0x123443, 100);
electron_mc.lineTo(1, 0);
_root.createEmptyMovieClip("centre_mc", 2);
centre_mc.lineStyle(10, 0x123443, 100);
centre_mc.lineTo(1, 0);
electron_mc.theta = 0;
electron_mc.radius = 100;
x = setInterval(run, 10);
i = 0;
function run() {


var x = electron_mc;
x._x = x.radius * Math.cos(x.theta) ;
x._y = x.radius * Math.sin(x.theta) ;
x.theta+=.05;

updateAfterEvent();
}

stealthelephant
02-29-2004, 10:05 AM
shot way over on the number of lines thought


i = 0;
_root.createEmptyMovieClip("centre_mc", 2);
drawElection(centre_mc);
_root.createEmptyMovieClip("electron_mc", 1);
drawElection(electron_mc);
_root.createEmptyMovieClip("electron2_mc", 4);
drawElection(electron2_mc);
_root.createEmptyMovieClip("electron1_mc", 3);
drawElection(electron1_mc);
_root.createEmptyMovieClip("electron3_mc", 5);
drawElection(electron3_mc);
electron_mc.theta = electron_mc.phi = 0;
electron_mc.radius = 60;
electron1_mc.theta = electron_mc1.phi = 3.14127;
electron1_mc.radius = 60;
electron2_mc.theta = electron_mc2.phi = 3.14127;
electron2_mc.radius = 130;
electron3_mc.theta = electron_mc3.phi = 0;
electron3_mc.radius = 130;
x = setInterval(run, 10);
function run() {
var x = electron_mc;
var x1 = electron1_mc;
var x2 = electron2_mc;
var x3 = electron3_mc;
//calculate vectors
x._x = x.radius * Math.sin(x.phi) * Math.cos(x.theta);
x._y = x.radius * Math.sin(x.phi) * Math.sin(x.theta);
x._xscale = x._yscale = (130 - (x.radius * Math.cos(x.phi)) / 2) ;
x1._x = x1.radius * Math.sin(x1.phi) * Math.cos(x1.theta);
x1._y = x1.radius * Math.sin(x1.phi) * Math.sin(x1.theta);
x1._xscale = x1._yscale = (130 - (x1.radius * Math.cos(x1.phi)) / 2) ;
x2._x = x2.radius * Math.sin(x2.phi) * Math.cos(x2.theta);
x2._y = x2.radius * Math.sin(x2.phi) * Math.sin(x2.theta);
x2._xscale = x2._yscale = (130 + (x2.radius * Math.cos(x2.phi)) / 2) ;
x3._x = x3.radius * Math.sin(x3.phi) * Math.cos(x3.theta);
x3._y = x3.radius * Math.sin(x3.phi) * Math.sin(x3.theta);
x3._xscale = x3._yscale = (130 - (x3.radius * Math.cos(x3.phi)) / 2) ;
x.theta += .07;
x.phi += .03;
x1.theta +=.08;
x1.phi += .3;
x2.theta +=.001;
x2.phi += .05;
x3.theta+=.01;
x3.phi += .05;

updateAfterEvent();
}
function drawElection(elec_mc){
if(i == 0){elec_mc.lineStyle(30, 0x777777, 100);
i++;}
else elec_mc.lineStyle(5, 0x111111, 100);
elec_mc.lineTo(1, 0);
elec_mc._xscale = elec_mc._yscale = 100;
}

stealthelephant
02-29-2004, 05:22 PM
variation

i = 0;
mouse.hide();
_root.createEmptyMovieClip("Atomic_mc", 1);
Atomic_mc.createEmptyMovieClip("centre_mc", 2);
drawElection ( Atomic_mc.centre_mc );
Atomic_mc.createEmptyMovieClip("electron_mc", 1);
drawElection ( Atomic_mc.electron_mc );
Atomic_mc.createEmptyMovieClip("electron2_mc", 4);
drawElection ( Atomic_mc.electron2_mc );
Atomic_mc.createEmptyMovieClip("electron1_mc", 3);
drawElection ( Atomic_mc.electron1_mc );
Atomic_mc.createEmptyMovieClip("electron3_mc", 5);
drawElection ( Atomic_mc.electron3_mc );
Atomic_mc.electron_mc.theta = Atomic_mc.electron_mc.phi = 0;
Atomic_mc.electron_mc.radius = 60;
Atomic_mc.electron1_mc.theta = Atomic_mc.electron_mc1.phi = 3.14127;
Atomic_mc.electron_mc1.phi = 0;
Atomic_mc.electron1_mc.radius = 60;
Atomic_mc.electron2_mc.theta = Atomic_mc.electron_mc2.phi = 3.14127;
Atomic_mc.electron_mc2.phi = 0;
Atomic_mc.electron2_mc.radius = 130;
Atomic_mc.electron3_mc.theta = Atomic_mc.electron_mc3.phi = 0;
Atomic_mc.electron_mc3.phi = 0;
Atomic_mc.electron3_mc.radius = 130;
x = setInterval ( run, 10 );
function run() {
var x = Atomic_mc.electron_mc;
var x1 = Atomic_mc.electron1_mc;
var x2 = Atomic_mc.electron2_mc;
var x3 = Atomic_mc.electron3_mc;
//calculate vectors
x._x = x.radius * Math.sin ( x.phi ) * Math.cos( x.theta );
x._y = x.radius * Math.sin ( x.phi ) * Math.sin( x.theta );
var temp = rotateX (10, x._y, ( x.radius * Math.cos( x.phi ) ) );
x._y = temp.y;
x._xscale = x._yscale = temp.z + 130;
x1._x = x1.radius * Math.sin (x1.phi) * Math.cos(x1.theta);
x1._y = x1.radius * Math.sin (x1.phi) * Math.sin(x1.theta);
temp = rotateX ( 10, -x1._y, x1.radius * Math.cos ( x1.phi ) );
x1._y = -temp.y;
x1._xscale = x1._yscale = temp.z - 130;
x2._x = x2.radius * Math.sin( x2.phi ) * Math.cos ( x2.theta );
x2._y = x2.radius * Math.sin( x2.phi )* Math.sin (x2.theta );
temp = rotateX (10, x2._y, (x2.radius * Math.cos (x2.phi ) ) );
x2._y = temp.y;
x2._xscale = x2._yscale = temp.z + 130;
x3._x = x3.radius * Math.sin ( x3.phi ) * Math.cos ( x3.theta );
x3._y = x3.radius * Math.sin ( x3.phi ) * Math.sin ( x3.theta );
var temp = rotateX (10, -x3._y, ( x3.radius * Math.cos (x3.phi) ) );
x3._y = -temp.y;
x3._xscale = x3._yscale = temp.z - 130;
x.theta += .016;
x.phi += .05;
x1.theta += .016;
x1.phi += .05;
x2.theta += .009;
x2.phi += .05;
x3.theta += .009;
x3.phi += .05;
Atomic_mc._x = _xmouse;
Atomic_mc._y = _ymouse;
updateAfterEvent ();
}
function drawElection(elec_mc) {
if (i == 0) {
elec_mc.lineStyle ( 30, 0x777777, 100 );
i++;
} else elec_mc.lineStyle ( 5, 0x111111, 100 );
elec_mc.lineTo ( 1, 0 );
elec_mc._xscale = elec_mc._yscale = 100;
}
function rotateX(angle, inY, inZ) {
var ca = Math.cos ( angle );
var sa = Math.sin ( angle );
var tempY = (inY * ca) - (inZ * sa);
var tempZ = (inY * sa) - (inZ * cs);
return { y:tempY, z:tempZ };
}

the number lines can be reduced by bout 20 i think,

anyone else wanna give it a shot?

CnD
03-29-2004, 01:06 AM
Hi. I just started working in flash few weeks ago, so I am a begginer in Action scripts. Only worked in VB and Delphi.

[as]
_root.createEmptyMovieClip("centre_mc", 1);
centre_mc._x = 100;
centre_mc._y = 100;
centre_mc.lineStyle(50, 0x125543, 100);
centre_mc.lineTo(1, 0);
_root.createEmptyMovieClip("electron_mc", 2);
electron_mc._x = 150;
electron_mc._y = 100;
electron_mc.lineStyle(20, 0xe23443, 100);
electron_mc.lineTo(1, 0);
_root.createEmptyMovieClip("electron2_mc", 3);
electron2_mc._x = 150;
electron2_mc._y = 100;
electron2_mc.lineStyle(15, 0x1234e1, 100);
electron2_mc.lineTo(1, 0);
_root.createEmptyMovieClip("electron3_mc", 4);
electron3_mc._x = 150;
electron3_mc._y = 100;
electron3_mc.lineStyle(8, 0x123443, 100);
electron3_mc.lineTo(1, 0);

var cntr:Number=1;
var cntr2:Number=1;
var spd:Number;
onEnterFrame = function()
{
spd=Math.sqrt(Math.pow(_xmouse-centre_mc._x,2)+Math.pow(_ymouse-centre_mc._y,2))/20;
if (_xmouse > centre_mc._x) centre_mc._x+=spd;
if (_xmouse < centre_mc._x) centre_mc._x-=spd;
if (_ymouse > centre_mc._y) centre_mc._y+=spd;
if (_ymouse < centre_mc._y) centre_mc._y-=spd;

electron_mc._x=centre_mc._x + Math.sin(cntr)*100;
electron_mc._y=centre_mc._y + Math.cos(cntr)*100;
electron2_mc._x=electron_mc._x - Math.sin(cntr)*50;
electron2_mc._y=electron_mc._y + Math.cos(cntr)*50;
electron3_mc._x=electron2_mc._x - Math.sin(cntr*2)*30;
electron3_mc._y=electron2_mc._y + Math.cos(cntr*2)*30;
cntr2+=Math.sin(random(2)/3);
cntr+=Math.sin(cntr2/20)/Math.abs (Math.exp(cntr/10)+.1);
}
[as]

So please dont flame if you find this code totally stupid.
:rolleyes:


Cole

stealthelephant
03-29-2004, 07:23 AM
So please dont flame if you find this code totally stupid.
:rolleyes:


Cole
i think that looks good :D