Actionscript Tennis

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*[0],points*[1]); // use a line if not the first point
		else this.moveTo(points*[0],points*[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.spaceShip.outline, [2,0,100], [0xbfbfbf,100]);

:beam:

mind if i join? :slight_smile:

jump on in! :beam:

k, let me get to work and i’ll start on a starfield.

You need to “Check out” the file, Thor :slight_smile: [size=1]and the starField is already there… :)[/size]

doh! gotcha. i haven’t downloaded the FLA yet. i’ll see what i can do.

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*[0],points*[1]); // use a line if not the first point
		else this.moveTo(points*[0],points*[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.spaceShip.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;
	}
}

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?

*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*[0],points*[1]); // use a line if not the first point
		else this.moveTo(points*[0],points*[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.spaceShip.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;
	}
}

All righty, I’ll be checking out the file tonight :beam:

I had to edit Ahmed’s createCircle function, it was a bit too specific… Am I allowed to do that?

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*[0],points*[1]); // use a line if not the first point
                else this.moveTo(points*[0],points*[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.spaceShip.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) ;
}

i’ll post my volley tonight :slight_smile:

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. :slight_smile:

-Al

Long time no see, Al :slight_smile: I hope you find time the check out the file :beam:

*Originally posted by ahmed *
**i’ll post my volley tonight :slight_smile: **
Hem… :sure:

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 =)

I’ve always wanted to try that bump feature…

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*.onEnterFrame = function() { this.repel() }