[font=verdana, arial, helvetica][size=2]Hi everyone…I’m not sure if anyone here remembers an old PC game called “Star Control”…but I thought it’d be a fun exercise to try to put something similar together in Flash.

Unfortunately, I’ve hit my first roadbloack. If you’ve never played the original game - here’s a quick overview:

-It’s one-on-one spaceship ‘combat’

-It’s a top-down “Asteroids” sort of view, but the playfield scrolls a bit as the players move around. Both the player’s ships and any debris appear on the bottom if they scroll off the top, and appear on the left if they scroll off the right side(like the old Mario bros.-before he was Super)

-As the two ships get closer, the ‘camera’ zooms in. As the two ships get farther apart, the camera pulls back to reveal the whole playfield

Of course, there’s a lot more to it than that. But as far as the play dynamics, it’s the “Zooming In” that’s giving me the problem. I had the idea that I could somehow tie the scale of everything in play to the distance between the ships. I set some variables, used the Pythagorean theorem for the distance between the ships, and put it into an onClipEvent that loops endlessly at runtime:

dist = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));

And it worked! Variable “dist” decreases as they get closer, and increases as they get further apart.

Problem is, if I try to tie “dist” into the scale properties of each clip involved, the whole scene gets smaller as the ships get closer together (because dist is decreasing) instead of getting larger and zooming in.

Is there a way to calculate the inverse of the Pythagorean theorem, so that the final value increases as they get closer? Or should I not even be using that and checking the distance vs. the scale using something else?

I’ve attached a FLA file to show you what I mean.

When you first test the movie, move toward the other ship (which is kind of on 'auto-pilot’for testing, always heading towards the top). Everything gets smaller. Move away, and everything gets bigger. I haven’t set min or max levels yet so it gets pretty large/small.

If you delete “‘Zoomer’ movie clip” you’ll see what the base playfield is like without the zoom.

The arrow keys move the little ship around.[/size][/font]

Thanks!