Well I've never made one before - but I'd store an array of the gun,
mirrors, and goals x,y and rotation properties and crawl through them to
draw the line...something like:

[as]
w = Stage.width;
h = Stage.height;
Stage.align = "TL";
Stage.scaleMode = "noScale";
//
points = new Array({x:10, y:10, rot:0}, {x:300, y:10, rot:90}, {x:300,
y:300, rot:180}, {x:100, y:300, rot:90});
drawBeam = function () {
        holder = this.createEmptyMovieClip("holder",
this.getNextHighestDepth());
        holder.lineStyle(1);
        for (i=0; i<points.length; i++) {
                pt = points[i];
                npt = points[i+1];
                if (i == 0) {
                        holder.moveTo(pt.x, pt.y);
                }
                // if rot = 0 draw horizontally right         
                if (pt.rot == 0) {
                        // // is next point on same y axes?
                        // // // is next point x greater than this x?
                        if (pt.y == npt.y && npt.x>pt.x) {
                                holder.lineTo(npt.x, npt.y);
                        } else {
                                holder.lineTo(pt.x, w);
                                //draw to edge
                                return;
                        }
                }
                //          
                // if rot = 90 draw vertically down
                if (pt.rot == 90) {
                        // // is next point on same x axes?
                        // // // is next point y greater than this y?
                        if (pt.x == npt.x && npt.y>pt.y) {
                                holder.lineTo(npt.x, npt.y);
                        } else {
                                //draw to edge
                                holder.lineTo(pt.x, h);
                                return;
                        }
                }
                //          
                // if rot= 180 draw horizontally left
                if (pt.rot == 180) {
                        // // is next point on same y axes?
                        // // // is next point x less than this x?
                        if (pt.y == npt.y && npt.x<pt.x) {
                                holder.lineTo(npt.x, npt.y);
                        } else {
                                //draw to edge
                                holder.lineTo(0, pt.y);
                                return;
                        }
                }
                //          
                // if rot = 270 draw vertically up
                if (rot == 270) {
                        // // is next point on same x axes?
                        // // // is next point y less than this y?
                        if (pt.x == npt.x && npt.y<pt.y) {
                                holder.lineTo(npt.x, npt.y);
                        } else {
                                //draw to edge
                                holder.lineTo(pt.x, 0);
                                return;
                        }
                }
        }
};
drawBeam();
[/as] 

Untested though - but it gives the general idea.

M


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of James Marsden
> Sent: 07 March 2006 11:45
> To: Flashcoders mailing list
> Subject: [Flashcoders] Bouncing laserbeam for game
> 
> Hello games people,
> 
> I'm tasked with programming a bouncing laserbeam like in the 
> following pic.
> 
> http://www.irem.co.jp/e/game/r/rtype/image/r1stg6.gif
> 
> Has anyone done this kind of thing before and can point me in 
> the right direction?
> 
> TIA,
> 
> James
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training 
> http://www.figleaf.com http://training.figleaf.com
> 
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to