Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
orbit position #131977
05/26/07 06:07
05/26/07 06:07
Joined: Apr 2007
Posts: 83
prog Offline OP
Junior Member
prog  Offline OP
Junior Member

Joined: Apr 2007
Posts: 83
I want to make the spaceship orbit in the space, and i have done it through the below script.
But, i want the spaceship to move(change it's position while rotating) ie., for the first 10 rotations it should move around one orbit and for other 10 rotations it should change it's position to other orbit(which is located around the first)...

action orbit
{
var radius = 100; //the radius of the circle it'll move on
var cur_pan;
var speed = 10; //the speed at which the entity will be moving
var cur_center = 0; //the center of the circle.
while(1)
{
my.x = cur_center.x + sin(cur_pan)*radius;
my.y = cur_center.y + cos(cur_pan)*radius;
my.z = cur_center.z;
cur_pan +=speed*time_step;
my.pan -= speed/1 * time_step;
wait(1);
}
}

Re: orbit position [Re: prog] #131978
05/26/07 08:02
05/26/07 08:02
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
so you wanna make a solar system or something?

If those orbits are constans You may use paths...
and when ship reach last node add +1 to var f.e. oribts_count.
If orbits_count >=10 go to next path
About paths look HERE

If not... add two another vars
var starting_pan;
var orbit_counts =0;
at the beggining of ship's action set
starting_pan = my.pan (not in loop)
my.pan %= 360;

Then In loop add
if(abs(starting_pan - my.pan) >=360){orbits_count +=1;}
if(orbits_count >=10){radius += 50; orbits_count = 0;}

Not tested but something like this

Last edited by tompo; 05/26/07 08:25.

Never say never.
Re: orbit position [Re: tompo] #131979
05/26/07 10:28
05/26/07 10:28
Joined: Apr 2007
Posts: 83
prog Offline OP
Junior Member
prog  Offline OP
Junior Member

Joined: Apr 2007
Posts: 83
My problem is not yet solved.

How to increment the radius after every 3 rotations(in the code pasted above).so that after every 3 rotations it will move to other orbit .

Re: orbit position [Re: prog] #131980
05/27/07 06:53
05/27/07 06:53
Joined: Aug 2006
Posts: 128
Papua New Guinea
I
Impaler Offline
Member
Impaler  Offline
Member
I

Joined: Aug 2006
Posts: 128
Papua New Guinea
give the planet orbit rotation skills, say skill1 and skill2, and the distance from the sun as skill3.I think the script would look like this: Code:


my.skill1 += 1 * time;//horizontal orbit rotation += 1 * time
my.skill2 += 1 * time;//vertical orbit rotation += 1 * time (optional)
my.skill3 += 1 * time;//distance from sun increases;

my.x = sun.x + my.skill3 * cos(my.skill1);//substitute coordinates for sun.x
my.y = sun.y + my.skill3 * sin(my.skill1);
my.z = sun.z + my.skill3 * tan(my.skill2);




this isn't tested, but it should make the planet orbit around whatever sun.x is, and increase distance from sun gradually. Hope this works!

Last edited by Impaler; 05/27/07 11:51.

Murphey's Law:
<< if anything can go wrong, it will >>

(Murphey was an optimist).

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1