Author Topic: Bullet Coordinates: Orbitals  (Read 3927 times)


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.


  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
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]
        CreateShot01(GetX+50*cos(angle), GetY+50*sin(angle), 2, GetAngleToPlayer, RED01, 5);

You might want to look into Naut's advanced danmakufu tutorial:

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."


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.