Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Asteroids movement
 User Name Remember Me? Password
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 03-30-2007, 12:37 AM #1 shivas Registered User   Join Date: Mar 2007 Posts: 2 Asteroids movement hi there! Im creating an asteroids type game and i cant work out how to make the asteroids move to a random direction and when they reach the end of the stage to reappear on the other side. Please help me!
 03-30-2007, 02:14 AM #2 pixelwit village halfwit     Join Date: Jul 2001 Location: USA, PA Posts: 3,330 ActionScript Code: ```// // function makeAsteroid(name, depth){     with(this){         var ast = createEmptyMovieClip(name, depth);         ast.lineStyle(100, Math.random()*0xFFFFFF);         ast.lineTo(.5, 0);         ast._x = 275;         ast._y = 200;         ast.xStep = Math.random()*5;         ast.yStep = Math.random()*5;         ast.onEnterFrame = drift;     } } function drift (){     with(this){         _x += xStep;         _y += yStep;         if(_x>550){             _x -= 550;         }else if(_x<0){             _x += 550;         }         if(_y>400){             _y -= 400;         }else if(_y<0){             _y += 400;         }     } } for(var i=1; i<6; i++){     makeAsteroid("Asteroid"+i, i) } lineStyle(0); lineTo(550, 0); lineTo(550, 400); lineTo(0, 400); lineTo(0, 0); moveTo(50, 50); lineTo(500, 50); lineTo(500, 350); lineTo(50, 350); lineTo(50, 50); // // ``` -PiXELWiT http://www.pixelwit.com __________________ There are no answers, only choices.
 03-30-2007, 04:21 AM #3 shivas Registered User   Join Date: Mar 2007 Posts: 2 Thanks a lot but i managed to do it! thnks again
 03-30-2007, 04:32 AM #4 pixelwit village halfwit     Join Date: Jul 2001 Location: USA, PA Posts: 3,330 You're welcome. Glad you figured it out. What code did you use? -PiXELWiT http://www.pixelwit.com __________________ There are no answers, only choices.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

 Similar Threads Thread Thread Starter Forum Replies Last Post XeroSiS ActionScript 2.0 7 06-11-2006 07:01 AM amjad Other Flash General Questions 1 06-30-2003 07:20 AM spoonyg ActionScript 1.0 (and below) 7 06-28-2002 02:59 PM pricey ActionScript 1.0 (and below) 2 05-13-2002 02:08 PM

All times are GMT. The time now is 10:29 PM.

///