Topic: Bullet Coordinates: Orbitals  (Read 2218 times)

0 Members and 1 Guest are viewing this topic.

  • Guest

Bullet Coordinates: Orbitals
« on: May 10, 2009, 09:40:05 am »
Okay, this feels like the wrong kind of thread to make here (it seems more fitting for actual projects) but since it's Danmakufu relevant, it still feel like it belongs here. A Danmakufu scripting specific board/thread would be pretty useful.

Anyway, I need to figure something out.

For the CreateShot01 function, how can one manipulate the X and Y coordinates to orbit around the boss in a circle while firing shots?

Or better yet... How can I get familiars/objects to orbit around the boss while firing shots? Does it have anything to do with sin/cos?

I can generate bullet circles, but not orbitals. Sigh.

It's a stupid question. I know. I have just been thinking about it way too much and I know the answer is much simpler than I think it is.

Iryan

  • Ph’nglui mglw’nafh
  • Cat R’lyeh wgah’nagl fhtagn.
  • LOOK AT ME
Re: Bullet Coordinates: Orbitals
« Reply #1 on: May 10, 2009, 11:12:48 am »
To make bullets or objects that orbit a specified point, you have to:

set the x coordinate of the bullet to (xc + r*cos(angle)), and

set the y coordinate of the bullet to (yc + r*sin(angle))

...where xc and yc are the coordinates of the orbited point and r is the radius.


For example, if you have a variable "angle" and call the following code every couple of frames, you should get what I think you are trying to do.
Code: [Select]
        angle+=5;
        CreateShot01(GetX+50*cos(angle), GetY+50*sin(angle), 2, GetAngleToPlayer, RED01, 5);

You might want to look into Naut's advanced danmakufu tutorial: http://www.shrinemaiden.org/forum/index.php?topic=166.0

Scroll down a bit and you'll find the explanation you seek. Even further down the page is also a part dedicated to how one makes object bullets, which in turn is the basis for creating familiars.  ;)
« Last Edit: May 10, 2009, 11:19:18 am by Iryan »
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

  • Guest

Re: Bullet Coordinates: Orbitals
« Reply #2 on: May 10, 2009, 12:58:14 pm »
Oh wtf. There's already a whole thread on this.
Well this is embarrassing.

Close/delete thread please.
Thanks for the help, Iryan.
 

SMF 2.0.15 | SMF © 2017, Simple Machines
Theme based on ModernDark64 design by BlocWeb
Page created in 0.043 seconds with 40 queries.