Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Animation and Effects

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-30-2007, 12:37 AM   #1
shivas
Registered User
 
Join Date: Mar 2007
Posts: 2
Default 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!
shivas is offline   Reply With Quote
Old 03-30-2007, 02:14 AM   #2
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

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.
pixelwit is offline   Reply With Quote
Old 03-30-2007, 04:21 AM   #3
shivas
Registered User
 
Join Date: Mar 2007
Posts: 2
Default

Thanks a lot but i managed to do it!
thnks again
shivas is offline   Reply With Quote
Old 03-30-2007, 04:32 AM   #4
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

You're welcome.

Glad you figured it out.

What code did you use?

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

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


All times are GMT. The time now is 11:33 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.