Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (Dico), 16,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Maths question spawning ent around circle #399230
04/12/12 15:43
04/12/12 15:43
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Hello,

How could I code an object that spawns entities around it in a circle at a set distance.

For instance, a random angle is chosen 1-360 and the object is spawned at distance of 100 at the random angle.

I can think of several ways of doing this like random pan then move to set distance but there must be a mathematician who knows better.

thanks,
Rob

Re: Maths question spawning ent around circle [Re: robertbruce] #399232
04/12/12 16:07
04/12/12 16:07
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi!

Code:
SpawnPos.x = Center.x + fsin ( Angle, Distance );
SpawnPos.y = Center.y + fcos ( Angle, Distance );



The conditions of the operations depend on the coordinate system, as well as the addition or subtraction of the same.

Wellcome to trigonometry!

Re: Maths question spawning ent around circle [Re: robertbruce] #399233
04/12/12 16:08
04/12/12 16:08
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline
User
JoGa  Offline
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
I'm at cooking, so I can't write a roman, but here a idea:

I made something like this some weeks ago (spawming PowerUps in a cycle)
Code:
int anzahl = 5; //numbers of Ents
	VECTOR vec_platzierung;
	var drehung = 360 / anzahl;
	vec_set(vec_platzierung, vector(300,0,0)); // place around 0,0,0 with distance of 300 Quants
	for(i=0;i<anzahl;i++)
	{
		vec_rotate(vec_platzierung, vector(drehung,0,0)); // turn the place around
		you = ent_create(...);
	}



edit: txesmi was quicker and did it like a (math) boss ^^

Last edited by JoGa; 04/12/12 16:10.
Re: Maths question spawning ent around circle [Re: JoGa] #399250
04/12/12 21:59
04/12/12 21:59
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
thanks for the maths lessons. Will give them a try.

best regards,
Rob


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

Gamestudio download | 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