Author Topic: Orbitals turning around Orbitals  (Read 11230 times)

KomeijiKoishi

Orbitals turning around Orbitals
« on: June 24, 2009, 07:24:51 PM »
Question's like this:
How do I make orbitals move around an orbital?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Orbitals turning around Orbitals
« Reply #1 on: June 24, 2009, 07:36:48 PM »
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));
« Last Edit: June 24, 2009, 08:49:58 PM 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."

Drake

  • *
Re: Orbitals turning around Orbitals
« Reply #2 on: June 25, 2009, 01:36:21 AM »
Epicycloid:
The circle with radius r spins on the outside of a circle with radius R. The point is on the circle r.
Code: [Select]
#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;
        }
    }
   
}

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: [Select]
#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;
        }
    }
   
}


Hypocycloid:
The circle with radius r spins on the inside of a circle with radius R. The point is on the circle r.
Code: [Select]
#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;
        }
    }
   
}

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: [Select]
#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;
        }
    }
   
}

I ♥ complex curves.
« Last Edit: June 25, 2009, 02:12:56 AM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Orbitals turning around Orbitals
« Reply #3 on: June 25, 2009, 02:20:19 AM »
while(a>-1){} == loop{}

:V

Lovely patterns you've constructed, now make a boss fight out of 'em!

Also, nice #BackGround.

Drake

  • *
Re: Orbitals turning around Orbitals
« Reply #4 on: June 25, 2009, 02:32:35 AM »
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.
« Last Edit: June 25, 2009, 03:16:52 AM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Orbitals turning around Orbitals
« Reply #5 on: June 25, 2009, 03:12:04 AM »
A bunch of moderate editing.... I did remake it y'know. You're right though, took me about 5 hours, so it isn't hard once you know the math (plus a little guess and check).
EDIT: I love you Drake <3


And...

Code: [Select]
#TouhouDanmakufu
#Title[Epicycloid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

let R = 70;
let r = 40;
let v = 2;

        let a = 0;
  
    @Initialize {

   SetLife(2000);
   SetTimer(40);
   SetMovePosition02(GetCenterX, GetCenterY-100, 20);
    }

    @MainLoop {
       SetCollisionB(GetX, GetY, 24);
       CreateShotA(0, GetX + ((R + r) * cos(a)) - (r * cos(a * ((R / r) +1))), GetY + ((R + r) * sin(a)) - (r * sin(a * ((R / r) + 1))), 20);
   SetShotDataA(0, 0, 0, a*2, 0, 0, 0, RED01);
   SetShotDataA(0, 90, 0, a*2, 0, 0.05, v, RED01);
   FireShot(0);
   a+=3;
       CreateShotA(0, GetX + ((R + r) * cos(a)) - (r * cos(a * ((R / r) +1))), GetY + ((R + r) * sin(a)) - (r * sin(a * ((R / r) + 1))), 20);
   SetShotDataA(0, 0, 0, a*2, 0, 0, 0, RED01);
   SetShotDataA(0, 90, 0, a*2, 0, 0.05, v, RED01);
   FireShot(0);
   a+=3;
   v+=0.001;
  
   } 
}

Or even....

Code: [Select]
#TouhouDanmakufu
#Title[Epicycloid]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

let R = 70;
let r = 40;
let v = 2;

        let a = 0;
  
    @Initialize {

   SetLife(2000);
   SetTimer(40);
   SetMovePosition02(GetCenterX, GetCenterY-100, 20);
    }

    @MainLoop {
       SetCollisionB(GetX, GetY, 24);
       CreateShotA(0, GetX + ((R + r) * cos(a)) - (r * cos(a * ((R / r) +1))), GetY + ((R + r) * sin(a)) - (r * sin(a * ((R / r) + 1))), 20);
   SetShotDataA(0, 0, 0, a*2, 0, 0, 0, RED01);
   SetShotDataA(0, 90, 0, a*2, 0, 0.05, v, RED01);
   FireShot(0);
   a+=2;
       CreateShotA(0, GetX + ((R + r) * cos(-a)) - (r * cos(-a * ((R / r) +1))), GetY + ((R + r) * sin(-a)) - (r * sin(-a * ((R / r) + 1))), 20);
   SetShotDataA(0, 0, 0, -a*2, 0, 0, 0, RED01);
   SetShotDataA(0, 90, 0, -a*2, 0, 0.05, v, RED01);
   FireShot(0);
   a+=2;
   v+=0.001;
  
   }
  
}

Okay last one I swear....

Code: [Select]
#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;}
        loop{
            newpoint(0, RED01);
            newpoint(120, GREEN01);
            newpoint(240, BLUE01);
            a+=3;
            yield;yield;
        }
    }

    task newpoint(aaa, ccc){
          let getxa;
          let getya;
          let anglereflex;
          let reflectcount = 0;
        let objshot = Obj_Create(OBJ_SHOT);
        Obj_SetX(objshot, GetX + ((R - r) * cos(a + aaa)) + (d * cos(a * ((R - r) / r + aaa))));
        Obj_SetY(objshot, GetY + ((R - r) * sin(a + aaa)) - (d * sin(a * ((R - r) / r + aaa))));
        Obj_SetSpeed(objshot, 0);
        Obj_SetAngle(objshot, (a + aaa)*2);
        ObjShot_SetGraphic(objshot, ccc);
        ObjShot_SetDelay  (objshot, 40);
let ff = -60;
let ll = 0;

       while(!Obj_BeDeleted(objshot)){
ff++;
if(ff<=120 && ff>=70){
Obj_SetSpeed(objshot, ll);
ll+=0.02;
}
           getxa = Obj_GetX(objshot);
           getya = Obj_GetY(objshot);
           if(getxa < GetClipMinX && reflectcount == 0){
            anglereflex = -Obj_GetAngle(objshot)+180;
let position = GetClipMinX - Obj_GetX(objshot);
Obj_SetX(objshot, GetClipMinX + position);
            Obj_SetAngle(objshot, anglereflex);
            reflectcount = 5;}
           if(getxa > GetClipMaxX && reflectcount == 0){
            anglereflex = -Obj_GetAngle(objshot)+180;
let position = GetClipMaxX - Obj_GetX(objshot);
Obj_SetX(objshot, GetClipMaxX + position);
            Obj_SetAngle(objshot, anglereflex);
            reflectcount = 5;}
           if((getya < GetClipMinY) && reflectcount == 0){
            anglereflex = -Obj_GetAngle(objshot);
let position = GetClipMinY - Obj_GetY(objshot);
Obj_SetY(objshot, GetClipMinY + position);
            Obj_SetAngle(objshot, anglereflex);
            reflectcount = 5;}
          yield;
           
          }
    }
   
}
« Last Edit: June 25, 2009, 03:36:43 AM by Naut »

Re: Orbitals turning around Orbitals
« Reply #6 on: June 25, 2009, 04:38:01 PM »
You guys rock ಥ_ಥ

Now I take your math and raise you a BROFIST: http://www.mediafire.com/?ghjom2z2wyc
« Last Edit: June 25, 2009, 04:50:47 PM by Suikama »

Drake

  • *
Re: Orbitals turning around Orbitals
« Reply #7 on: June 25, 2009, 05:58:59 PM »
You know you can change R, r and d and get different results, right?

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Orbitals turning around Orbitals
« Reply #8 on: June 25, 2009, 08:17:15 PM »
But that involves more than holding down ctrl, c and v.