PDA

View Full Version : [AS3] Obstacles


Zend
03-03-2009, 03:04 PM
So what I'm trying to do is make it so that a bunch of random circles fly across the screen and the point of the game is to dodge these circles. I could probably figure this out on my own but only by making every single circle it's own movie clip.

I was wondering if it's possible to make only one movie clip for the circles and just make it duplicate itself so there is more then one at a time on the screen. That way I would only have to write the script for the one circle instead of all of them.

So heres my questions:
1. First, how would I make it so that my circle will appear randomly going up, down, left, or right starting at either of the four edges of the screen? (I have no idea where to even start on a code like this, this is the first one like this that I've done.)

2. How would I make it so that more then one of the movie clip appear randomly going up, down,j left, or right starting at either of the four edges? (Basically the same as the first question, except with more then one copy of the movie clip.)

3. After I have these circles randomly moving around on my screen how would I make them move at random speeds? (I'm sure by now I will probably know how to make random numbers and probably be able to figure this one out by myself. So don't bother doing this one if you don't have the time :))

4. After all this is done, is it as easy as just doing the coding for the original movie clip and it will work on all the others? EX: making them so that when the player touches the circles it will give him a game over. If so then thats all I need to know.

Thanks for all your help everyone :)

rrh
03-04-2009, 09:09 PM
The answer to many of these questions will follow from a tutorial on how to make a class in as3 and how to link a library item with a class.

Zend
03-05-2009, 01:54 AM
The answer to many of these questions will follow from a tutorial on how to make a class in as3 and how to link a library item with a class.

Theres no simple code to do this? I just have an assignment due about a week ago and I'm trying to finish it ASAP :\

Can someone link me to the classes tutorial? :)

rrh
03-05-2009, 04:30 AM
http://www.flashandmath.com/bridge/intro/index.html

Movement is a change in x and y values. To move at a constant speed, you create some speedX and speedY attributes and give them random values in the constructor, and add those to the x and y when triggered by the enterFrame event, or another repeating event, like a timer event.