-
[F8] Maths/Rotation Problem
Hi folks,
Hope everyones well and good! I am currently working on a new game, its quite classic in its nature - harking back to classic coin-munchers such as space invaders, galagga and Atlantis. Anyway, the game involves a ship orbiting a planent in the centre of the screen.
So far I have the basic code in place to make the ship orbit the planet:
///***Ship Movement Setup***///
var radius = 200;
var speed = 2
var xcenter = ship._x;
var ycenter = ship._y;
var degree = 0;
var radian;
function onEnterFrame(){
degree += speed;
radian = (degree/180)*Math.PI;
ship._x = xcenter+Math.cos(radian)*radius;
ship._y = ycenter-Math.sin(radian)*radius;
ship._rotation = ship._x+ship._y
}
///***///***///***///
stop();
what I'd really like is for the rotation of the ship to compensate for its orbit. ie. I'd like the ship to permanently face outward (so it can shoot baddies!)
Can anyone think of a bit of math that could achieve this?
If anyone can help that would be very much appreciated!
thanks
-
Senior Member
ummm well you could flip the ships image around or change its registration point from the front of the movie clip to the rear and see if that helps.
-
Flashmatics
hi this attachment should help u out
Last edited by silentweed; 11-22-2007 at 07:14 PM.
-
Senior Member
you have to make ship._rotation go full circle as it goes around the planet
-
Senior Member
Well, you already have the degree relative to the planet, would it be the right degree if you added/subtracted that degree to the _rotation of the ship?
I'm really tired so it seems to work in my head, but dunno if it really works.
Whoever taught EVERYONE to put all their code on movie clips needs to be shot...
-
Thanks so much for the help guys! I had no idea I was getting any responses since I stopped getting email notifications from the board for some reason!
I've fixed my rotation problem now thanks to your help!
Cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|