~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
Orbitals turning around Orbitals
KomeijiKoishi:
Question's like this:
How do I make orbitals move around an orbital?
Iryan:
An attack of the boss battle I am working on does just that. :V
First, craete six global variables. Let's call them cx, cy, rad1 phase1, rad2 and phase2.
Those are the center coordinates of the inner circle and the radii and phases of the two circles.
First make sure the phase variables are increased every frame in the main loop.
Second, create an object bullets that uses the following command inside its loop:
Obj_SetPosition(obj, cx+rad1*cos(phase1)+rad2*cos(phase2), cy+rad1*sin(phase1)+rad2*sin(phase2));
Drake:
Epicycloid:
The circle with radius r spins on the outside of a circle with radius R. The point is on the circle r.
--- Code: ---#TouhouDanmakufu
#Title[Epicycloid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let R = 70;
let r = 40;
let a = 0;
@Initialize {
SetLife(2000);
SetTimer(40);
SetMovePosition02(GetCenterX, GetCenterY-70, 20);
rose;
}
@MainLoop {
SetCollisionB(GetX, GetY, 24);
yield;
}
@DrawLoop {
}
@Finalize {
}
task rose{
loop(100){yield;}
while(a>-1){
newpoint;
a+=3;
yield;
}
}
task newpoint{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, GetEnemyX + ((R + r) * cos(a)) - (r * cos(a * ((R / r) +1))));
Obj_SetY(obj, GetEnemyY + ((R + r) * sin(a)) - (r * sin(a * ((R / r) + 1))));
Obj_SetSpeed(obj, 0);
Obj_SetAngle(obj, a);
ObjShot_SetGraphic(obj, RED01);
ObjShot_SetDelay (obj, 3);
while(Obj_BeDeleted(obj)==false) {
yield;
}
}
}
--- End code ---
Epitrochoid:
The circle with radius r spins on the outside of a circle with radius R. The point is d away from the circle r.
--- Code: ---#TouhouDanmakufu
#Title[Epitrocoid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let R = 60;
let r = 40;
let d = 30;
let a = 0;
@Initialize {
SetLife(2000);
SetTimer(40);
SetMovePosition02(GetCenterX, GetCenterY-70, 20);
rose;
}
@MainLoop {
SetCollisionB(GetX, GetY, 24);
yield;
}
@DrawLoop {
}
@Finalize {
}
task rose{
loop(100){yield;}
while(a>-1){
newpoint;
a+=3;
yield;
}
}
task newpoint{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, GetEnemyX + ((R + r) * cos(a)) - (d * cos(a * ((R + r) / r))));
Obj_SetY(obj, GetEnemyY + ((R + r) * sin(a)) - (d * sin(a * ((R + r) / r))));
Obj_SetSpeed(obj, 0);
Obj_SetAngle(obj, a);
ObjShot_SetGraphic(obj, RED01);
ObjShot_SetDelay (obj, 3);
while(Obj_BeDeleted(obj)==false) {
yield;
}
}
}
--- End code ---
Hypocycloid:
The circle with radius r spins on the inside of a circle with radius R. The point is on the circle r.
--- Code: ---#TouhouDanmakufu
#Title[Hypocycloid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let R = 150;
let r = 20;
let a = 0;
@Initialize {
SetLife(2000);
SetTimer(40);
SetMovePosition02(GetCenterX, GetCenterY-70, 20);
rose;
}
@MainLoop {
SetCollisionB(GetX, GetY, 24);
yield;
}
@DrawLoop {
}
@Finalize {
}
task rose{
loop(100){yield;}
while(a>-1){
newpoint;
a+=3;
yield;
}
}
task newpoint{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, GetEnemyX + ((R - r) * cos(a)) + (r * cos(a * ((R - r) / r))));
Obj_SetY(obj, GetEnemyY + ((R - r) * sin(a)) - (r * sin(a * ((R - r) / r))));
Obj_SetSpeed(obj, 0);
Obj_SetAngle(obj, a);
ObjShot_SetGraphic(obj, RED01);
ObjShot_SetDelay (obj, 3);
while(Obj_BeDeleted(obj)==false) {
yield;
}
}
}
--- End code ---
Hypotrochoid:
The circle with radius r spins on the inside of a circle with radius R. The point is d away from the circle r.
--- Code: ---#TouhouDanmakufu
#Title[Hypotrochoid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let R = 150;
let r = 50;
let d = 60;
let a = 0;
@Initialize {
SetLife(2000);
SetTimer(40);
SetMovePosition02(GetCenterX, GetCenterY-70, 20);
rose;
}
@MainLoop {
SetCollisionB(GetX, GetY, 24);
yield;
}
@DrawLoop {
}
@Finalize {
}
task rose{
loop(100){yield;}
while(a>-1){
newpoint;
a+=3;
yield;
}
}
task newpoint{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, GetEnemyX + ((R - r) * cos(a)) + (d * cos(a * ((R - r) / r))));
Obj_SetY(obj, GetEnemyY + ((R - r) * sin(a)) - (d * sin(a * ((R - r) / r))));
Obj_SetSpeed(obj, 0);
Obj_SetAngle(obj, a);
ObjShot_SetGraphic(obj, RED01);
ObjShot_SetDelay (obj, 3);
while(Obj_BeDeleted(obj)==false) {
yield;
}
}
}
--- End code ---
I ♥ complex curves.
Naut:
while(a>-1){} == loop{}
:V
Lovely patterns you've constructed, now make a boss fight out of 'em!
Also, nice #BackGround.
Drake:
by the way I stole that background from you
It's just a base demonstration so that you can add onto it. In even just the little I provided you can create complex patterns just by editing SetSpeed, SetAngle and the three base circle values.
For example, Virtue of Wind God is just three epicycloids on top of each other with a bunch of moderate editing.
EDIT: I did that just to spite you by the way. It's excellent.