PDA

View Full Version : Actionscript Tennis



pom
July 13th, 2003, 02:48 PM
All right, we tried that some time ago, and unfortunately it didn't work because out, but I'm confident this time =) Anybody wants to collaborate with me?

mlk
July 13th, 2003, 05:37 PM
whaaaaaaa ?

what's an actionscipt tennis ???

someone who codes the best looking tennis match ???

teed
July 13th, 2003, 07:11 PM
naaaa its when one person starts of a peice of code say 4 lines then passes to the next person who will code 4 lines and so on until the script is complete.



i would enter but i am only starting out in actionscript and im not to good at it :/

ahmed
July 13th, 2003, 07:30 PM
hmm.. what's the theme? =)

pom
July 14th, 2003, 04:21 AM
Could be anything :) How about "space"?

ahmed
July 15th, 2003, 03:26 AM
uh, when do we start? :)

pom
July 15th, 2003, 04:54 AM
Shall I? Or do you want to start? :)

ahmed
July 15th, 2003, 04:57 AM
I would :)

What are the rules by the way? How is it gonna go? :)

pom
July 15th, 2003, 05:32 AM
Let's say each one of us adds from 5 to 10 lines at a time, function headers, comments and brackets not included. I don't know if we should discuss what we are doing though...

JK87
July 15th, 2003, 05:53 AM
It would be cool if you could discuss it or at least place clear commenting because I'm starting to get to grips with ActionScript and I'm always happy to learn more :).

senocular
July 15th, 2003, 09:25 AM
Originally posted by JK87
It would be cool if you could discuss it or at least place clear commenting because I'm starting to get to grips with ActionScript and I'm always happy to learn more :).

Thats a good idea. Shouldnt be hard considering there arent many lines involved. It may take a while to get something fully developed - a couple of volleys.

There is also the issue of movieclips. Are these going to be using the drawing API? or can we add make new ones by drawing them? or have a specific set of usable, non-editable library items to work from? ... like a line, square, cirlce or whatever? The drawing API would be cool (and help other people understand it more) but 5-10 lines is pretty much right there just the function for drawing a circle. Then again, it wouldnt be a big deal if the volleys go fast enough.

Also, handing off. Should that be in order? or take it as it comes. Setting an order is "fair" but it can also lead to delays and whatnot. "Taking it as it comes" is alot faster - basically thats just saying, someone declares that they have the 'ball' and will then post it. Next, whoever gets to it first takes it next (i.e. whoever is online). If two people are both after it, courtesy goes to the person with the least amount of go-at-its already. Just making sure whoever has it declares it in a post so theres no crossovers.

pom
July 15th, 2003, 11:12 AM
Let's say: drawing API only, and "taking it as it comes". Those who take it as it comes will have to post something like "File checked out" (I'm polluted by VSS, I know...).

All right? btw, are you participating, Sen? :)

senocular
July 15th, 2003, 12:26 PM
yeah ;)

ahmed
July 15th, 2003, 02:28 PM
ah... ok.. i hope this is good to begin with, with the 'space' theme in mind =)

Stage = {width:Stage.width, height:Stage.height}
container = [];
createCircle = function(num) {
clip = _root.createEmptyMovieClip("mc"+i, i)
clip.lineStyle(10+Math.random()*60, Math.random()*0x0000FF,10+Math.random()*50);
clip.lineTo(.15,.45);
clip._x = Math.random()*Stage.width
clip._y = Math.random()*Stage.height
container.push(clip)
}
for(i=0; i<15; i++) createCircle(i) 9 lines (excluding function headers) =)


*edit*

FLA (http://24.141.60.208/astennis.fla)

senocular
July 15th, 2003, 03:05 PM
I have a small question ahmed :)

... why did you redefine Stage to be an object which is itself minus all its properties other than height and width :q:

ahmed
July 15th, 2003, 03:39 PM
ah, that... for some reason, when you run the movie in the Flash IDE, stage.width and stage.height return odd values, and by redefining it, it returns the correct values... it happens often, but not always :)

In the browser though this 'bug' doesn't exist =)

senocular
July 15th, 2003, 06:26 PM
This isnt going as fast as I thought ;) Ill step in for a swing:

-FLA CHECKED OUT!-

ok, added a spaceship (or the start of one atleast ;)

ahmed
July 15th, 2003, 06:37 PM
haha, awesome sen =)

line #28 is ingeniuos, never thought of that :beam:



p.s. thanks for commenting the code too :)

senocular
July 15th, 2003, 06:40 PM
go for it! :beam:

pom
July 16th, 2003, 06:03 AM
Can you guys post the code please? I'm at work, and I don't have Flash here (obviously...).

senocular
July 16th, 2003, 06:33 AM
so far:

/****************\
* Volley #1
* Author: Ahmed
* Date: 7/15
\****************/

StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
container = []; // contains circles created by createCircle
createCircle = function(i){
clip = _root.createEmptyMovieClip("mc"+i, i); // create an empty clip to contain the circle
clip.lineStyle(10+Math.random()*60, Math.random()*0x0000FF,10+Math.random()*50); // define random linestyle
clip.lineTo(.15,.45); // draw circle (a very fat line)
clip._x = Math.random()*StageDim.width; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
}
for(i=0; i<15; i++) createCircle(i); // create 15 circles


/****************\
* Volley #2
* Author: Senocular
* Date: 7/15
\****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

pom
July 16th, 2003, 06:35 AM
:beam:

thoriphes
July 16th, 2003, 06:38 AM
mind if i join? :)

senocular
July 16th, 2003, 06:38 AM
jump on in! :beam:

thoriphes
July 16th, 2003, 06:39 AM
k, let me get to work and i'll start on a starfield.

pom
July 16th, 2003, 06:43 AM
You need to "Check out" the file, Thor :) and the starField is already there... :)

thoriphes
July 16th, 2003, 07:25 AM
doh! gotcha. i haven't downloaded the FLA yet. i'll see what i can do.

thoriphes
July 16th, 2003, 10:27 AM
Here's what I have so far. I wasn't really pleased with how this turned out. Hopefully I was able to start what someone else can finish. I'm having a hard time working on this while at the same time Alt+Tabbing to dodge my boss.

and for ilyas, here's the code:
/****************\
* Volley #1
* Author: Ahmed
* Date: 7/15
\****************/
StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
container = []; // contains circles created by createCircle
createCircle = function(i){
clip = _root.createEmptyMovieClip("mc"+i, i); // create an empty clip to contain the circle
clip.lineStyle(10+Math.random()*60, Math.random()*0x0000FF,10+Math.random()*50); // define random linestyle
clip.lineTo(.15,.45); // draw circle (a very fat line)
clip._x = Math.random()*StageDim.width; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
}
for(i=0; i<15; i++) createCircle(i); // create 15 circles


/****************\
* Volley #2
* Author: Senocular
* Date: 7/15
\****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************\
* Volley #3
* Author: thoriphes
* Date: 7/16
\****************/

// I can make really long lines of code too ;)
with (ship) {accel = 1.01; decel = 0.99; maxvel = 10; vx = vy = 0; onEnterFrame = function(){this._x = -(_x += this.vx); this._y = -(_y += this.vy);};}
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
with (ship) {
down = true;
vx = Key.isDown(Key.RIGHT) ? vx + (vx <= maxvel ? accel : 0) : Key.isDown(Key.LEFT) ? vx - (vx >= -maxvel ? decel : 0) : vx;
vy = Key.isDown(Key.DOWN) ? vy + (vy <= maxvel ? accel : 0) : Key.isDown(Key.UP) ? vy - (vy >= -maxvel ? decel : 0) : vy;
}
}

pom
July 16th, 2003, 11:07 AM
OK, let's clear up the rules. Putting several commands in the same line will not be admitted, because it ofuscates the code, and this completely defeats the whole line limitation thing. Everybody OK with that?

thoriphes
July 16th, 2003, 11:14 AM
Originally posted by Ilyas
OK, let's clear up the rules. Putting several commands in the same line will not be admitted, because it ofuscates the code, and this completely defeats the whole line limitation thing. Everybody OK with that? ...that said. here it is again.

/****************\
* Volley #1
* Author: Ahmed
* Date: 7/15
\****************/
StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
container = []; // contains circles created by createCircle
createCircle = function(i){
clip = _root.createEmptyMovieClip("mc"+i, i); // create an empty clip to contain the circle
clip.lineStyle(10+Math.random()*60, Math.random()*0x0000FF,10+Math.random()*50); // define random linestyle
clip.lineTo(.15,.45); // draw circle (a very fat line)
clip._x = Math.random()*StageDim.width; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
}
for(i=0; i<15; i++) createCircle(i); // create 15 circles


/****************\
* Volley #2
* Author: Senocular
* Date: 7/15
\****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************\
* Volley #3
* Author: thoriphes
* Date: 7/16
\****************/

with (ship) {
accel = 1.01;
decel = 0.99;
maxvel = 10;
vx = vy = 0;
onEnterFrame = function(){
this._x = -(_x += this.vx);
this._y = -(_y += this.vy);};}
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
with (ship) {
vx = Key.isDown(Key.RIGHT) ? vx + (vx <= maxvel ? accel : 0) : Key.isDown(Key.LEFT) ? vx - (vx >= -maxvel ? decel : 0) : vx;
vy = Key.isDown(Key.DOWN) ? vy + (vy <= maxvel ? accel : 0) : Key.isDown(Key.UP) ? vy - (vy >= -maxvel ? decel : 0) : vy;
}
}

pom
July 17th, 2003, 05:12 AM
All righty, I'll be checking out the file tonight :beam:

pom
July 17th, 2003, 05:13 PM
I had to edit Ahmed's createCircle function, it was a bit too specific... Am I allowed to do that?

pom
July 17th, 2003, 05:37 PM
Pas de nouvelles, bonnes nouvelles :evil:
/****************
* Volley #1
* Author: Ahmed
* Edit: pom ( makeCircle proto) 7/17
* Date: 7/15
****************/
StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
container = []; // contains circles created by createCircle
MovieClip.prototype.makeCircle = function ( size, col, alpha ) {
this.moveTo ( 0, 0 ) ;
this.lineStyle ( size, col, alpha ) ;
this.lineTo ( .45, .15 ) ;
}
for(i=0; i<15; i++) {
clip = _root.createEmptyMovieClip("mc"+i, i);// create an empty clip to contain the circle
clip.makeCircle (10+Math.random()*60, Math.random()*0x0000FF,10+Math.random()*50); // define random linestyle
clip._x = Math.random()*StageDim.width; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
}

/****************
* Volley #2
* Author: Senocular
* Date: 7/15
****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************
* Volley #3
* Author: thoriphes
* Date: 7/16
****************/

with (ship) {
accel = 1.01;
decel = 0.99;
maxvel = 10;
vx = vy = 0;
onEnterFrame = function(){
this._x = -(_x += this.vx);
this._y = -(_y += this.vy);
};
}
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
with (ObjectLayer) {
vx = Key.isDown(Key.RIGHT) ? vx + (vx <= maxvel ? accel : 0) : Key.isDown(Key.LEFT) ? vx - (vx >= -maxvel ? decel : 0) : vx;
vy = Key.isDown(Key.DOWN) ? vy + (vy <= maxvel ? accel : 0) : Key.isDown(Key.UP) ? vy - (vy >= -maxvel ? decel : 0) : vy;
}
}

/****************
* Volley #4
* Author: pom
* Date: 7/17
****************/
afterBurner = ship.createEmptyMovieClip("Afterburner",99); // container clip
col = 0xff0000 ; // base color of the flame
for ( var i = 0; i < 20 ; i++ ) {
// We make a bunch of small clips that get red little by little
var clip = afterBurner.createEmptyMovieClip ( "b" + i, i ) ;
clip.makeCircle ( size = 5 + 10*Math.cos ( a+= .15 ), col += 0x001000, 20 ) ;
clip.makeCircle ( size + 10, 0xffff00, 10 ) ;
clip._x = -90 -3 * i ;
clip._y = 5 ;
}
afterBurner.onEnterFrame = function () {
// The afterburner is visible only when a key is pressed
this._visible = Key.isDown(Key.UP) + Key.isDown(Key.DOWN) + Key.isDown(Key.RIGHT) ;
}

ahmed
July 21st, 2003, 09:40 PM
i'll post my volley tonight :)

alethos
July 22nd, 2003, 08:22 PM
This is great. I just checked back here to see what everyone was up to and I find this jewel of a thread. Keep it up. I may pop in and "check out" the file myself. :)

-Al

pom
July 23rd, 2003, 08:38 AM
Long time no see, Al :) I hope you find time the check out the file :beam:

pom
July 24th, 2003, 04:31 AM
Originally posted by ahmed
i'll post my volley tonight :) Hem... :sure:

ahmed
July 24th, 2003, 05:33 AM
aaah.. sorry

i got side-tracked, i forgot about my volley ;(

if someone wants to check out the file, feel free to do so.. if not, i'll try to get mine in sometime these two days =)

pom
July 27th, 2003, 06:00 PM
I've always wanted to try that bump feature...

ahmed
July 31st, 2003, 07:13 AM
Sorry i'm too late :blush:
/****************
* Volley #5
* Author: ahmed
* Date: 7/31
* Note: run at 24 fps
****************/

MovieClip.prototype.repel = function() {
this.dist = Math.sqrt((this._x-ship._x)*(this._x-ship._x)+(this._y-ship._y)*(this._y-ship._y))
if (this.dist<=_root.rad) {
this.force = (_root.rad-this.dist)/30
this._x = this._x+10*this.force*(this._x-ship._x)/this.dist
this._y = this._y+10*this.force*(this._y-ship._y)/this.dist
}
}
_root.rad = 150
for(i=0; i<container.length; i++) container[i].onEnterFrame = function() { this.repel() }

EZEkiel
August 1st, 2003, 06:57 AM
THIS IS ABSOLUTLEY AWESOME !!!!!!

it is good to see the evolution of it all !! it looks great at the moment keep up the match !

:p: pimp daddy E1kO

Scootman
August 1st, 2003, 05:06 PM
umm i dont really see what pom's 4th volley did... can someone explain what it did?

alethos
August 2nd, 2003, 09:28 AM
Originally posted by Scootman
umm i dont really see what pom's 4th volley did... can someone explain what it did?

It added the afterburner effect (the flames that come out the back of the ship).

Would any of you be interested in starting another ASTennis match of a more abstract nature?

-Al

pom
August 2nd, 2003, 11:29 AM
Sure Al, go ahead, start the thread :)
Oh, and Fla checked out :)

Scootman
August 2nd, 2003, 03:51 PM
thats weird... when i run it i only see part of the ship in the top left corner... and when i move the whole screen moves... no afterburner or anything

Scootman
August 2nd, 2003, 03:54 PM
oh wait now i see it... i have to maximize the screen to see it though...

thoriphes
August 2nd, 2003, 03:59 PM
yeah, i have to fix my volley sometime. I made it so the movie moves instead of the ship, like a side scroller. I'm going to make the ship move instead.

Scootman
August 2nd, 2003, 05:01 PM
is that why it stays stuck in the top left corner?

pom
August 3rd, 2003, 01:57 PM
I'm trying to modify this, as a matter of fact, but for some reason, the stars don't appear at the right place :-\

pom
August 3rd, 2003, 03:15 PM
Only general edits, nothing real new:[code]StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
/****************
* Volley #6
* Author: Ilyas
* Date: 08/03
* General edits...
****************/
MovieClip.prototype.move = function () {
if ( this._x > 0 ) this._x -= this.speed ;
else {
this._x = StageDim.width + 20 ;
this._y = random (StageDim.height);
}
}
/****************
* Volley #1
* Author: Ahmed
* Edit: pom (makeCircle proto) 7/17
* Date: 7/15
****************/
container = []; // contains circles created by createCircle
MovieClip.prototype.makeCircle = function ( size, col, alpha ) {
this.moveTo ( 0, 0 ) ;
this.lineStyle ( size, col, alpha ) ;
this.lineTo ( .45, .15 ) ;
}
this.createEmptyMovieClip("BackgroundLayer", 99)
for(i=0; i<15; i++) {
clip = BackgroundLayer.createEmptyMovieClip("mc"+i, i);// create an empty clip to contain the circle
clip.makeCircle (size=10+Math.random()*30, 0xff0000,100); // define random linestyle
(new Color (clip)).setTransform ({ga:70+random(30),ba:0,ra:70+random(30)}) ;
clip._x = Math.random()*StageDim.width ; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
clip.speed = size / 5 ;
}
this.BackgroundLayer.createEmptyMovieClip ( "DeepSpace9", -100 ).beginFill ( 0, 100 ) ;
edges = [{x:0, y:0}, {x:StageDim.width, y:0}, {x:StageDim.width, y:StageDim.height}, {x:0, y:StageDim.height}] ;
for ( var p=0; p < edges.length; p++ )
this.BackgroundLayer.DeepSpace9[p == 0 ? "moveTo" : "lineTo"](edges[p].x, edges[p].y);
/****************
* Volley #2
* Author: Senocular
* Date: 7/15
****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************
* Volley #3
* Author: thoriphes
* Date: 7/16
****************/

ship.accel = 1.01;
ship.decel = 0.99;
ship.maxvel = 10;
ship.vx = ship.vy = 0;
ship.onEnterFrame = function(){
this._x += this.vx;
this._y += this.vy;
this.vx *= .96 ;
this.vy *= .96 ;
};
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
ship.vx = Key.isDown(Key.RIGHT) ? ship.vx + (ship.vx <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.LEFT) ? ship.vx - (ship.vx >= -ship.maxvel ? ship.decel : 0) : ship.vx;
ship.vy = Key.isDown(Key.DOWN) ? ship.vy + (ship.vy <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.UP) ? ship.vy - (ship.vy >= -ship.maxvel ? ship.decel : 0) : ship.vy;
}

/****************
* Volley #4
* Author: pom
* Date: 7/17
****************/
afterBurner = ship.createEmptyMovieClip("Afterburner",99); // container clip
col = 0xff0000 ; // base color of the flame
for ( var i = 0; i < 20 ; i++ ) {
// We make a bunch of small clips that get red little by little
var clip = afterBurner.createEmptyMovieClip ( "b" + i, i ) ;
clip.makeCircle ( size = 5 + 10*Math.cos ( a+= .15 ), col += 0x001000, 20 ) ;
clip.makeCircle ( size + 10, 0xffff00, 10 ) ;
clip._x = -90 -3 * i ;
clip._y = 5 ;
}
afterBurner.onEnterFrame = function () {
// The afterburner is visible only when a key is pressed
this._visible = Key.isDown(Key.UP) + Key.isDown(Key.DOWN) + Key.isDown(Key.RIGHT) ;
}

/****************
* Volley #5
* Author: ahmed
* Date: 7/31
* Note: run at 24 fps
****************/

MovieClip.prototype.repel = function() {
this.dist = Math.sqrt((this._x-ship._x)*(this._x-ship._x)+(this._y-ship._y)*(this._y-ship._y))
if (this.dist<=_root.rad) {
this.force = (_root.rad-this.dist)/30
this._x = this._x+10*this.force*(this._x-ship._x)/this.dist
this._y = this._y+10*this.force*(this._y-ship._y)/this.dist
}
}
_root.rad = 150
for(i=0; i<container.length; i++) container[i].onEnterFrame = function() {
this.repel() ;
this.move () ;
}
//this.onEnterFrame = function (){trace (ship._x);}[/As]

Johnny64
August 4th, 2003, 04:21 AM
Hoi

is the game still on?

i what to join in too
most of the battles are design things
but this is AS :}

pom
August 4th, 2003, 05:35 AM
Well, yeah, no problem, the last volley was done yesterday :)

Johnny64
August 4th, 2003, 10:20 AM
ok i will see if i can add some thing :}

Johnny64
August 4th, 2003, 11:32 AM
Here :}


/****************
* Volley #7
* Author: Master64
* Date: 8/4
****************/
MovieClip.prototype.fire = function(){
if(this.count > 100) this.count = 0 ;
shot = this._parent.createEmptyMovieClip("shot"+this.count++,this.count+200);
shot.makeCircle(5,0xff6600,100);
shot._y = ship._y+19; shot._x = ship._x+91;
shot.onEnterFrame = function(){this._x += 12}
}
this.onEnterFrame = function () {
this.interval++;
if (Key.isDown(Key.SPACE) && this.interval > 7) {ship.fire(); this.interval = 0;}
}


it adds a gun ;)

ahmed
August 4th, 2003, 11:39 AM
NICE! :beam:

Johnny64
August 4th, 2003, 12:14 PM
thanks but i cheated a bit :beam:

with

shot._y = ship._y+19; shot._x = ship._x+91;
but......:geek:

so how is going to add the nexted piece??

ahmed
August 5th, 2003, 10:08 AM
to do my volley i had to edit master64's volley.. is that allowed?
StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
/****************
* Volley #6
* Author: Ilyas
* Date: 08/03
* General edits...
****************/
MovieClip.prototype.move = function () {
if ( this._x > 0 ) this._x -= this.speed ;
else {
this._x = StageDim.width + 20 ;
this._y = random (StageDim.height);
}
}
/****************
* Volley #1
* Author: Ahmed
* Edit: pom (makeCircle proto) 7/17
* Date: 7/15
****************/
container = []; // contains circles created by createCircle
MovieClip.prototype.makeCircle = function ( size, col, alpha ) {
this.moveTo ( 0, 0 ) ;
this.lineStyle ( size, col, alpha ) ;
this.lineTo ( .45, .15 ) ;
}
this.createEmptyMovieClip("BackgroundLayer", 99)
for(i=0; i<15; i++) {
clip = BackgroundLayer.createEmptyMovieClip("mc"+i, i);// create an empty clip to contain the circle
clip.makeCircle (size=10+Math.random()*30, 0xff0000,100); // define random linestyle
(new Color (clip)).setTransform ({ga:70+random(30),ba:0,ra:70+random(30)}) ;
clip._x = Math.random()*StageDim.width ; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
clip.speed = size / 5 ;
}
this.BackgroundLayer.createEmptyMovieClip ( "DeepSpace9", -100 ).beginFill ( 0, 100 ) ;
edges = [{x:0, y:0}, {x:StageDim.width, y:0}, {x:StageDim.width, y:StageDim.height}, {x:0, y:StageDim.height}] ;
for ( var p=0; p < edges.length; p++ )
this.BackgroundLayer.DeepSpace9[p == 0 ? "moveTo" : "lineTo"](edges[p].x, edges[p].y);
/****************
* Volley #2
* Author: Senocular
* Date: 7/15
****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************
* Volley #3
* Author: thoriphes
* Date: 7/16
****************/

ship.accel = 1.01;
ship.decel = 0.99;
ship.maxvel = 10;
ship.vx = ship.vy = 0;
ship.onEnterFrame = function(){
this._x += this.vx;
this._y += this.vy;
this.vx *= .96 ;
this.vy *= .96 ;
};
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
ship.vx = Key.isDown(Key.RIGHT) ? ship.vx + (ship.vx <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.LEFT) ? ship.vx - (ship.vx >= -ship.maxvel ? ship.decel : 0) : ship.vx;
ship.vy = Key.isDown(Key.DOWN) ? ship.vy + (ship.vy <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.UP) ? ship.vy - (ship.vy >= -ship.maxvel ? ship.decel : 0) : ship.vy;
}

/****************
* Volley #4
* Author: pom
* Date: 7/17
****************/
afterBurner = ship.createEmptyMovieClip("Afterburner",99); // container clip
col = 0xff0000 ; // base color of the flame
for ( var i = 0; i < 20 ; i++ ) {
// We make a bunch of small clips that get red little by little
var clip = afterBurner.createEmptyMovieClip ( "b" + i, i ) ;
clip.makeCircle ( size = 5 + 10*Math.cos ( a+= .15 ), col += 0x001000, 20 ) ;
clip.makeCircle ( size + 10, 0xffff00, 10 ) ;
clip._x = -90 -3 * i ;
clip._y = 5 ;
}
afterBurner.onEnterFrame = function () {
// The afterburner is visible only when a key is pressed
this._visible = Key.isDown(Key.UP) + Key.isDown(Key.DOWN) + Key.isDown(Key.RIGHT) ;
}

/****************
* Volley #5
* Author: ahmed
* Date: 7/31
* Note: run at 24 fps
****************/

MovieClip.prototype.repel = function() {
this.dist = Math.sqrt((this._x-ship._x)*(this._x-ship._x)+(this._y-ship._y)*(this._y-ship._y))
if (this.dist<=_root.rad) {
this.force = (_root.rad-this.dist)/30
this._x = this._x+10*this.force*(this._x-ship._x)/this.dist
this._y = this._y+10*this.force*(this._y-ship._y)/this.dist
}
}
_root.rad = 150
for(i=0; i<container.length; i++) container[i].onEnterFrame = function() {
this.repel() ;
this.move () ;
}
//this.onEnterFrame = function (){trace (ship._x);}
/****************
* Volley #7
* Author: Master64
* Edit: Ahmed on 8/5
* Date: 8/4
****************/
MovieClip.prototype.fire = function(){
if(this.count > 100) this.count = 0 ;
shot = this._parent.createEmptyMovieClip("shot"+this.count++,this.count+200);
shot.makeCircle(5,0xff6600,100);
shot._y = ship._y+19; shot._x = ship._x+91;
shot.onEnterFrame = function(){
/* begin ahmed's edit */
// loop through all 'starships' and hitTest them
for(var i=0; i<container.length; i++) {
if (this.hitTest(container[i])) {
// if bullet hits a starship, delete startship, bullet, and reference in array
container[i].removeMovieClip();
container[i] = null;
this.removeMovieClip();
}
}
/* end ahmed's edit */
this._x += 12
}
}
this.onEnterFrame = function () {
this.interval++;
if (Key.isDown(Key.SPACE) && this.interval > 7) {ship.fire(); this.interval = 0;}
}

Johnny64
August 5th, 2003, 03:33 PM
fine ;)

pom
August 6th, 2003, 09:23 AM
Editing a volley is absolutely fine, of course! :)

And Master64, if I may say, it would be better not to use the _root.onEnterFrame :b:

Johnny64
August 6th, 2003, 09:56 AM
ok i will make new MC with the onEnterFrame and so not getting in the way ;)


StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
/****************
* Volley #6
* Author: Ilyas
* Date: 08/03
* General edits...
****************/
MovieClip.prototype.move = function () {
if ( this._x > 0 ) this._x -= this.speed ;
else {
this._x = StageDim.width + 20 ;
this._y = random (StageDim.height);
}
}
/****************
* Volley #1
* Author: Ahmed
* Edit: pom (makeCircle proto) 7/17
* Date: 7/15
****************/
container = []; // contains circles created by createCircle
MovieClip.prototype.makeCircle = function ( size, col, alpha ) {
this.moveTo ( 0, 0 ) ;
this.lineStyle ( size, col, alpha ) ;
this.lineTo ( .45, .15 ) ;
}
this.createEmptyMovieClip("BackgroundLayer", 99)
for(i=0; i<15; i++) {
clip = BackgroundLayer.createEmptyMovieClip("mc"+i, i);// create an empty clip to contain the circle
clip.makeCircle (size=10+Math.random()*30, 0xff0000,100); // define random linestyle
(new Color (clip)).setTransform ({ga:70+random(30),ba:0,ra:70+random(30)}) ;
clip._x = Math.random()*StageDim.width ; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
clip.speed = size / 5 ;
}
this.BackgroundLayer.createEmptyMovieClip ( "DeepSpace9", -100 ).beginFill ( 0, 100 ) ;
edges = [{x:0, y:0}, {x:StageDim.width, y:0}, {x:StageDim.width, y:StageDim.height}, {x:0, y:StageDim.height}] ;
for ( var p=0; p < edges.length; p++ )
this.BackgroundLayer.DeepSpace9[p == 0 ? "moveTo" : "lineTo"](edges[p].x, edges[p].y);
/****************
* Volley #2
* Author: Senocular
* Date: 7/15
****************/

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

/****************
* Volley #3
* Author: thoriphes
* Date: 7/16
****************/

ship.accel = 1.01;
ship.decel = 0.99;
ship.maxvel = 10;
ship.vx = ship.vy = 0;
ship.onEnterFrame = function(){
this._x += this.vx;
this._y += this.vy;
this.vx *= .96 ;
this.vy *= .96 ;
};
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
ship.vx = Key.isDown(Key.RIGHT) ? ship.vx + (ship.vx <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.LEFT) ? ship.vx - (ship.vx >= -ship.maxvel ? ship.decel : 0) : ship.vx;
ship.vy = Key.isDown(Key.DOWN) ? ship.vy + (ship.vy <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.UP) ? ship.vy - (ship.vy >= -ship.maxvel ? ship.decel : 0) : ship.vy;
}

/****************
* Volley #4
* Author: pom
* Date: 7/17
****************/
afterBurner = ship.createEmptyMovieClip("Afterburner",99); // container clip
col = 0xff0000 ; // base color of the flame
for ( var i = 0; i < 20 ; i++ ) {
// We make a bunch of small clips that get red little by little
var clip = afterBurner.createEmptyMovieClip ( "b" + i, i ) ;
clip.makeCircle ( size = 5 + 10*Math.cos ( a+= .15 ), col += 0x001000, 20 ) ;
clip.makeCircle ( size + 10, 0xffff00, 10 ) ;
clip._x = -90 -3 * i ;
clip._y = 5 ;
}
afterBurner.onEnterFrame = function () {
// The afterburner is visible only when a key is pressed
this._visible = Key.isDown(Key.UP) + Key.isDown(Key.DOWN) + Key.isDown(Key.RIGHT) ;
}

/****************
* Volley #5
* Author: ahmed
* Date: 7/31
* Note: run at 24 fps
****************/

MovieClip.prototype.repel = function() {
this.dist = Math.sqrt((this._x-ship._x)*(this._x-ship._x)+(this._y-ship._y)*(this._y-ship._y))
if (this.dist<=_root.rad) {
this.force = (_root.rad-this.dist)/30
this._x = this._x+10*this.force*(this._x-ship._x)/this.dist
this._y = this._y+10*this.force*(this._y-ship._y)/this.dist
}
}
_root.rad = 150
for(i=0; i<container.length; i++) container[i].onEnterFrame = function() {
this.repel() ;
this.move () ;
}
//this.onEnterFrame = function (){trace (ship._x);}
/****************
* Volley #7
* Author: Master64
* Edit: Ahmed on 8/5
* Date: 8/4
****************/
MovieClip.prototype.fire = function(){
if(this.count > 100) this.count = 0 ;
shot = this._parent.createEmptyMovieClip("shot"+this.count++,this.count+200);
shot.makeCircle(5,0xff6600,100);
shot._y = ship._y+19; shot._x = ship._x+91;
shot.onEnterFrame = function(){
/* begin ahmed's edit */
// loop through all 'starships' and hitTest them
for(var i=0; i<container.length; i++) {
if (this.hitTest(container[i])) {
// if bullet hits a starship, delete startship, bullet, and reference in array
container[i].removeMovieClip();
container[i] = null;
this.removeMovieClip();
}
}
/* end ahmed's edit */
this._x += 12
}
}
this_mc.createEmptyMovieClip("shotTime",98).onEnterFrame = function () {
this.interval++;
if (Key.isDown(Key.SPACE) && this.interval > 7) {ship.fire(); this.interval = 0;}
}


there if that is ok :}

EZEkiel
August 12th, 2003, 07:27 AM
holy cow you guys are still goin !!! awesome !!

i can't wait to see the final result !! better be good :a:

but i know it wil be !!!

peace out
E1kO

blah-de-blah
August 12th, 2003, 09:55 AM
wow, that is the longest piece of code i have ever seen in my entire life :P

pom
August 13th, 2003, 04:46 PM
A nice anti-asteroids field if you press SHIFT :)
/****************
* Volleys
* #1: Ahmed, 7/15
* #2: Senocular, 7/15
* #3: Thoriphes, 7/16
* #4: Ilyas, 7/17
* #5: Ahmed, 7/31
* #6: Ilyas, 8/03
* #7: Master64, 8/04
* #8: Ahmed, 8/05
* #9: Ilyas, 8/13
****************/

StageDim = {width:Stage.width, height:Stage.height}; // Stage Dimensions (renamed by sen 7/15)
MovieClip.prototype.move = function () {
if ( this._x > 0 ) this._x -= this.speed ;
else {
this._x = StageDim.width + 20 ;
this._y = random (StageDim.height);
}
}
container = []; // contains circles created by createCircle
MovieClip.prototype.makeCircle = function ( size, col, alpha ) {
this.moveTo ( 0, 0 ) ;
this.lineStyle ( size, col, alpha ) ;
this.lineTo ( .45, .15 ) ;
}
this.createEmptyMovieClip("BackgroundLayer", 99)
for(i=0; i<15; i++) {
clip = BackgroundLayer.createEmptyMovieClip("mc"+i, i);// create an empty clip to contain the circle
clip.makeCircle (size=10+Math.random()*30, 0xff0000,100); // define random linestyle
(new Color (clip)).setTransform ({ga:70+random(30),ba:0,ra:70+random(30)}) ;
clip._x = Math.random()*StageDim.width ; // position circle based on Stage Dimensions
clip._y = Math.random()*StageDim.height;
container.push(clip); // add circle clip to container
clip.speed = size / 5 ;
clip.onEnterFrame = move ;
}

//***********

this.BackgroundLayer.createEmptyMovieClip ( "DeepSpace9", -100 ).beginFill ( 0, 100 ) ;
edges = [{x:0, y:0}, {x:StageDim.width, y:0}, {x:StageDim.width, y:StageDim.height}, {x:0, y:StageDim.height}] ;
for ( var p=0; p < edges.length; p++ )
this.BackgroundLayer.DeepSpace9[p == 0 ? "moveTo" : "lineTo"](edges[p].x, edges[p].y);

//***********

// create a clip at depth 100 as an "object layer" with more managable
// depths using ObjectLayer.depth++ to prevent overlapping
// in ObjectLayer create a spaceShip clip and define an outline for it
this.createEmptyMovieClip("ObjectLayer", 100).createEmptyMovieClip("spaceShip", ObjectLayer.depth++).outline = [[91,19],[31,-35],[-26,-20],[-76,-45],[-98,-43],[-60,-13],[-77,-4],[-76,9],[-58,15],[-31,15],[-53,47],[-20,43],[34,2],[75,20],[91,19]];
// drawOutlines: draws lines defined by points in an array in a movieclip
// allows optional lineStyle and fillStyle parameters
MovieClip.prototype.drawOutlines = function(points, lStyle, fStyle){
if (lStyle != undefined) this.lineStyle.apply(this, lStyle); // apply linestyle if passed
if (fStyle != undefined) this.beginFill.apply(this, fStyle); // apply fillstyle if passed
for (var i=0; i<points.length; i++){ // cycle through all the points in the array
if (i) this.lineTo(points[i][0],points[i][1]); // use a line if not the first point
else this.moveTo(points[i][0],points[i][1]);} // otherwise, move to the point if the first
if (fStyle != undefined) this.endFill(); // end the fill if passed
};
// defines 'ship' in this timeline and draws its outlines with specified line and fill
(ship = ObjectLayer.spaceShip).drawOutlines(ObjectLayer.sp aceShip.outline, [2,0,100], [0xbfbfbf,100]);

//****************

afterBurner = ship.createEmptyMovieClip("Afterburner",99); // container clip
col = 0xff0000 ; // base color of the flame
for ( var i = 0; i < 20 ; i++ ) {
// We make a bunch of small clips that get red little by little
var clip = afterBurner.createEmptyMovieClip ( "b" + i, i ) ;
clip.makeCircle ( size = 5 + 10*Math.cos ( a+= .15 ), col += 0x001000, 20 ) ;
clip.makeCircle ( size + 10, 0xffff00, 10 ) ;
clip._x = -90 -3 * i ;
clip._y = 5 ;
}
afterBurner.onEnterFrame = function () {
// The afterburner is visible only when a key is pressed
this._visible = Key.isDown(Key.UP) + Key.isDown(Key.DOWN) + Key.isDown(Key.RIGHT) ;
}

//***************

ship.accel = 1.01;
ship.decel = 0.99;
ship.maxvel = 10;
ship.vx = ship.vy = 0;
MovieClip.prototype.obeyControls = function () {
this._x += this.vx;
this._y += this.vy;
this.vx *= .96 ;
this.vy *= .96 ;
};
ship.onEnterFrame = obeyControls ;
Key.addListener(keyList = new Object());
keyList.onKeyDown = function () {
ship.vx = Key.isDown(Key.RIGHT) ? ship.vx + (ship.vx <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.LEFT) ? ship.vx - (ship.vx >= -ship.maxvel ? ship.decel : 0) : ship.vx;
ship.vy = Key.isDown(Key.DOWN) ? ship.vy + (ship.vy <= ship.maxvel ? ship.accel : 0) : Key.isDown(Key.UP) ? ship.vy - (ship.vy >= -ship.maxvel ? ship.decel : 0) : ship.vy;
}

//****************

rad = 150
MovieClip.prototype.repel = function() {
for(i=0; i<container.length; i++) {
var cl = container[i] ;
var dx = this._x-cl._x ;
var dy = this._y-cl._y ;
var dist = Math.sqrt(dx*dx+dy*dy) ;
if (dist <= rad) {
var force = (rad-dist)/30
cl._x = cl._x-10*force*dx/dist
cl._y = cl._y-10*force*dy/dist
}
}
}

//****************

MovieClip.prototype.fire = function(){
if(this.count > 100) this.count = 0 ;
shot = this._parent.createEmptyMovieClip("shot"+this.count++,this.count+200);
shot.makeCircle(5,0xff6600,100);
shot._y = ship._y+19; shot._x = ship._x+91;
shot.onEnterFrame = function(){
/* begin ahmed's edit */
// loop through all 'starships' and hitTest them
for(var i=0; i<container.length; i++) {
if (this.hitTest(container[i])) {
// if bullet hits a starship, delete startship, bullet, and reference in array
container[i].removeMovieClip();
container[i] = null;
this.removeMovieClip();
}
}
/* end ahmed's edit */
this._x += 12
}
}
this.createEmptyMovieClip("shotTime",98).onEnterFrame = function () {
this.interval++;
if (Key.isDown(Key.SPACE) && this.interval > 7) {
ship.fire();
this.interval = 0;
}
}

//***********

MovieClip.prototype.makeShield = function () {
var mc = this.createEmptyMovieClip ("shield", 1000) ;
mc.makeCircle ( 220, 0xffff00, 30 ) ;
}
// Would be cool if we could put all the key actions within the same handler... : )
myKeyListener = {} ;
myKeyListener.onKeyDown = function () {
if (Key.isDown(Key.SHIFT)) {
ship.makeShield () ;
ship.onEnterFrame = function () {
this.repel ();
this.obeyControls ();
}
}
}
myKeyListener.onKeyUp = function () {
if (!Key.isDown(Key.SHIFT)) {
ship.shield.removeMovieClip() ;
ship.onEnterFrame = obeyControls;
}
}
Key.addListener(myKeyListener) ;

ahmed
August 13th, 2003, 06:06 PM
Originally posted by Ilyas Masa
A nice anti-asteroids field if you press SHIFT :)That's very smart :thumb:

pom
August 14th, 2003, 05:07 AM
Thanks! That repel function is pretty cool :beam:

EZEkiel
August 19th, 2003, 01:18 AM
come on guys you almost finished !!

i am hanging out to see this thing !!

PEACE
E1kO

ahmed
August 19th, 2003, 03:04 AM
lol.. what more can we do?

EZEkiel
August 19th, 2003, 03:35 AM
you can script faster !! lol thats what you can do :beam:

PEACE
E1kO

pom
August 19th, 2003, 06:49 AM
Originally posted by ahmed
lol.. what more can we do? Does it mean that it's finished? :eye:

Coppertop
August 22nd, 2003, 10:53 PM
THat is one funky anti asteroid sheild

EZEkiel
August 23rd, 2003, 10:32 PM
so..... is this like the finish of this cause there hasn't been any action for quite a while now !!

just wondering

peace
E1kO

pom
August 24th, 2003, 06:57 AM
It looks like it :(