~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
Bullet Coordinates: Orbitals
Pages: (1/1)
Adun:
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:
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: --- angle+=5;
CreateShot01(GetX+50*cos(angle), GetY+50*sin(angle), 2, GetAngleToPlayer, RED01, 5);
--- End code ---
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. ;)
Adun:
Oh wtf. There's already a whole thread on this.
Well this is embarrassing.
Close/delete thread please.
Thanks for the help, Iryan.
Pages: (1/1)