Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 1,085 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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 | 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