Author Topic: Danmakufu Q&A/Problem Thread II  (Read 166228 times)

ChaoStar

  • Dark History Boy
Re: Danmakufu Q&A/Problem Thread II
« Reply #300 on: November 10, 2009, 01:20:12 PM »
The way I see it, one of three things could be happening. One, you're trying to load an object effect at Initialize without putting in yield; first.  Two, you're spawning infinite bullets, or calling infinite tasks all in one frame by placing it in a loop and forgetting to put yield; in it. Or three, you're loading a filetype that danmakufu doesn't recognise (a different type of text file, a music file that isn't .mp3, .ogg, or .wav.

Try looking over the script.  If the problem persists, post it here.

Turns out, it was the fact that for some reason, my virtual XP wouldn't localize it, all the way. I fixed it. <3

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #301 on: November 10, 2009, 01:46:01 PM »
Hmmm... looks like some people could really use those codes for the magic circle effect that I learned.  I'll post it here later, as soon as I get back to my work. Math is so essential. It looks so hard, but it's actually very simple, and it'll make sense why everything is where it is. You guys will thank me for this.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #302 on: November 10, 2009, 01:46:46 PM »
(**Back to here at last**)
Can I reflect the graphics by reversing the x-coordinates in SetGraphicRect?

What do you mean reflect? Like create a 2nd image next to it being mirrored? Or are you trying to simply flip/mirror a graphic?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #303 on: November 10, 2009, 07:10:02 PM »
ATTN HELE
let speed = 0;
let acc = 0.5 or something;
let radius = 3;

speed+=acc;
radius+=speed;
radius*cos(dir); or whatever
acc-=0.05;

radius will increase with a downwards acceleration for 10 frames until acc hits 0 and radius hits 5.75 or something.
Then radius starts to slow down until it hits 0, and acc and speed is fairly small. More than likely it will come back at a fairly high speed.

I dunno. Something like this, screw around with values.

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

8lue Wizard

  • Cobalt Magician
  • (Apparently)
Re: Danmakufu Q&A/Problem Thread II
« Reply #304 on: November 10, 2009, 08:47:07 PM »
Is there a way to change one value in an array without rebuilding the entire ****in' thing? I'm trying to get bullets to fade out, and this is what I ended up with:
Code: [Select]
            let i = 0;
            while (i < length(ninja)) {
                let alph = ninja2[0] - 15;
                ninja2 = erase(ninja2,0);
                Obj_SetAlpha(ninja[i], alph);
                if(alph <= 15) {
                    ninja = erase(ninja,i);
                } else {
                    ninja2 = ninja2 ~ [alph];
                    i++;
                }
            }

Note what's happening to ninja2 there. It works, but it's almost certainly the ugliest hakcjob I've ever done.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #305 on: November 10, 2009, 10:16:05 PM »
Is there a way to change one value in an array without rebuilding the entire ****in' thing? I'm trying to get bullets to fade out, and this is what I ended up with:
Code: [Select]
            let i = 0;
            while (i < length(ninja)) {
                let alph = ninja2[0] - 15;
                ninja2 = erase(ninja2,0);
                Obj_SetAlpha(ninja[i], alph);
                if(alph <= 15) {
                    ninja = erase(ninja,i);
                } else {
                    ninja2 = ninja2 ~ [alph];
                    i++;
                }
            }

Note what's happening to ninja2 there. It works, but it's almost certainly the ugliest hakcjob I've ever done.

I stared at that block for like a minute and I can't figure out what the heck you were trying to do so I'll just answer your question. To change an element in an array, all you need is this

let array = [0, 1, 2, 3, 4, 3];
array[5] = 5;

In that example, the array became [0, 1, 2, 3, 4, 5].
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

8lue Wizard

  • Cobalt Magician
  • (Apparently)
Re: Danmakufu Q&A/Problem Thread II
« Reply #306 on: November 10, 2009, 10:56:12 PM »
really? 'cuz I was trying to do "ninja2[ i ] = ninja2[ i ] - 15;" and it was throwing errors. Ah well, whatever. It works, I'm not gonna start throwing wrenches at it now.

Basically the whole thing is a really roundabout way of tracking each bullet's alpha value ('cuz some idiot decided Obj_GetAlpha() was a waste of time, I guess.)

also, lol@ italics

Cabble

  • Ask me about my Cat.
  • Not unwilling to shank you.
Re: Danmakufu Q&A/Problem Thread II
« Reply #307 on: November 11, 2009, 01:15:46 AM »
The stage ends immediately. I know it's the enemy script too.

Code: [Select]
script_enemy_main {
@Initialize{
SetLife(10);
  Main();
yield;
 }
@MainLoop{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
yield;
 }
@DrawLoop{
 }
@Finalize{
CreateItem(ITEM_SCORE,GetX,GetY);
 }
task Main(){
yield;
CreateShot01(GetX,GetY,2,rand(0,360),BLUE01,0);
}

Here's the stage

Code: [Select]
#TouhouDanmakufu[Stage]
#Title[Stage 1 Easy]
#Text[...]
#Image[]
#Background[]
#BGM[.\SE\Iku.mp3]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{

 function Wait(let frames){
   loop(frames){yield;}
 }
 function WaitForZeroEnemy{
  while(GetEnemyNum != 0){yield;}
 }
 task stage{
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX, GetCenterY, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(120);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"TenshiBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(180);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"IkuBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(60);
  Clear;
 }
  @Initialize{
 stage;
  }
 @MainLoop{
   yield;
  }
  @Background{

  }
  @Finalize{

  }
}

I had a teacher who used to play radiohead during class once.

ONCE.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #308 on: November 11, 2009, 02:16:22 AM »
...
task stage{
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX, GetCenterY, 0, 0, 0);
  WaitForZeroEnemy;
...
Is what I do when it happens. Not sure if that's the fix.

EDIT: You forgot to put the closing bracket in Enemy1 (at the very end).
EDIT: Then there's no TenshiBossE.txt and IkuBossE.txt. That's probably all.
« Last Edit: November 11, 2009, 02:22:04 AM by Always お⑨烏 »

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #309 on: November 11, 2009, 02:19:43 AM »
That does fix it. The cause is that an enemy is being made in @Initialize which, for some reason, Danmakufu doesn't like. Putting just 1 yield would fix the problem, though more would be preferred since spawning enemies before the player gets a chance to get ready isn't very good design.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Cabble

  • Ask me about my Cat.
  • Not unwilling to shank you.
Re: Danmakufu Q&A/Problem Thread II
« Reply #310 on: November 11, 2009, 03:23:59 AM »
Ok it's fixed, but now in this script iku won't show up.

Code: [Select]
#TouhouDanmakufu[Stage]
#Title[Stage 1 Easy]
#Text[...]
#Image[]
#Background[]
#BGM[.\SE\Iku.mp3]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{

 function Wait(let frames){
   loop(frames){yield;}
 }
 function WaitForZeroEnemy{
  while(GetEnemyNum != 0){yield;}
 }
 task stage{
Wait(2*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX-150, GetCenterY-175, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX+150, GetCenterY-175, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(1*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX, GetCenterY-175, 0, 0, 0);
WaitForZeroEnemy;
Wait(3*60);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"TenshiBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(1*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX, GetCenterY-175, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);

WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
WaitForZeroEnemy;
Wait(180);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"IkuBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(60);
  Clear;
 }
  @Initialize{
 stage;
  }
 @MainLoop{
   yield;
  }
  @Background{

  }
  @Finalize{

  }
}
I had a teacher who used to play radiohead during class once.

ONCE.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #311 on: November 11, 2009, 03:51:11 AM »
Ok it's fixed, but now in this script iku won't show up.

Code: [Select]
#TouhouDanmakufu[Stage]
#Title[Stage 1 Easy]
#Text[...]
#Image[]
#Background[]
#BGM[.\SE\Iku.mp3]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{

 function Wait(let frames){
   loop(frames){yield;}
 }
 function WaitForZeroEnemy{
  while(GetEnemyNum != 0){yield;}
 }
 task stage{
Wait(2*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX-150, GetCenterY-175, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX+150, GetCenterY-175, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(1*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX, GetCenterY-175, 0, 0, 0);
WaitForZeroEnemy;
Wait(3*60);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"TenshiBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(1*60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy1.txt", GetCenterX, GetCenterY-175, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, GetCenterY-200, 2, 0, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, GetCenterY-200, 2, 180, 0);

WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
Wait(10);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", 0, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"\Enemy2.txt", GetCenterX+GetCenterX-1, rand(GetCenterY-100,GetCenterY-200), 2, 180, 0);
WaitForZeroEnemy;
Wait(180);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"IkuBossE.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(60);
  Clear;
 }
  @Initialize{
 stage;
  }
 @MainLoop{
   yield;
  }
  @Background{

  }
  @Finalize{

  }
}
Is Iku in the right script directory?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread II
« Reply #312 on: November 11, 2009, 04:11:57 AM »
Hm, I don't know when the last time somebody requested this was, but it's been pretty common, so here it is:

Code: [Select]
task ImageCircle(graphic,left,top,right,bottom,centerX,centerY,radius,width,segments,rotation,layer,alpha,renderstate,red,green,blue){

    yield;
    let obj = Obj_Create(OBJ_EFFECT);
    let n=0;

    Obj_SetPosition   (obj, centerX,centerY);
    Obj_SetSpeed      (obj, 0);
    Obj_SetAngle(obj, 0);
    ObjEffect_SetTexture(obj,graphic);
    ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
    ObjEffect_SetScale(obj,1,1);
    ObjEffect_SetAngle(obj,0,0,rotation);
    ObjEffect_SetLayer(obj,layer);
    ObjEffect_CreateVertex(obj,(segments*2)+2);
    ObjEffect_SetRenderState(obj,renderstate);

    n=0;
    loop((segments*2)+2){
ObjEffect_SetVertexColor(obj,n,alpha,red,green,blue);
if(n%2==0){ObjEffect_SetVertexUV(obj,n,left+(right/segments)*floor(n/2),top);
} else {   ObjEffect_SetVertexUV(obj,n,left+(right/segments)*floor(n/2),bottom);
}
ObjEffect_SetVertexXY(obj,n, cos((360/segments)*floor(n/2))*(radius-(n%2)*width), sin((360/segments)*floor(n/2))*(radius-(n%2)*width) );
n++;
    }

    yield;
    Obj_Delete(obj);
}



It takes any image and converts it to a circle, made in about one hour. It only lasts one frame by default (so you can pass the variables directly to the function without changing the function itself, which you can keep in a library of sorts), though feel free to change that. It seems like it has a lot of parameters, but all of them are self-explanatory, and once again, it makes it so you can just use this single task for everything. Any questions or suggestions?

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #313 on: November 11, 2009, 05:05:06 AM »
Alright, the long-awaited effect is explained here.  Thank you for your patience-.  Now, on to the little tutorial.


Now, first thing we need to do.  I'll set a code here for you, and explain what it does.  Some explanations are in the code, so take a second to look at it.  I don't go to the basics of the basics, that's something everyone should figure out on their own.

Code: [Select]
#TouhouDanmakufu
#Title[magic circle 2]
#Text[]
#Player[FREE]
#ScriptVersion[2]
 
script_enemy_main{
    let imagefile = GetCurrentScriptDirectory ~ "index.png";




    @Initialize{
      SetMovePosition02(GetCenterX,GetCenterY-100,0);  ///the object will be on the boss's position
      SetLife(1);
      LoadGraphic(imagefile);
      object;
    }
 
    @MainLoop{
      yield;
    }
 
    @DrawLoop{
    }
 
    @BackGround{
    }
 
    @Finalize{
    }

   task object{   yield; yield;     ///the yield needs to be in place so Danmakufu doesn't crash.  Object effects cannot load directly at Initialize unless a couple of frames pass first.


      let objid = Obj_Create(OBJ_EFFECT);
      Obj_SetX(objid, GetX);    ///the Object will be on the Boss's X and Y position
      Obj_SetY(objid, GetY);
      ObjEffect_SetScale(objid,1,1);
      ObjEffect_SetPrimitiveType(objid, PRIMITIVE_TRIANGLESTRIP);  ///the basics you need to know
      ObjEffect_SetRenderState(objid,ADD);
      ObjEffect_SetTexture(objid, imagefile);

      let totalradius=100;   ////the real radius of the circle
      let repeat=2;            ////number of times the image is repeated in the circle.  The higher, the more scrunched-up the circle will look.  the lower, the more stretched the image will look (height-wise)
      let sides=80;      ////it's not a perfect circle. It actually has 80 "sides".  If it were 3, it'd be a triangle.
      let d=0;             //// this will be used to determine the height of the image later
      let Z=0;             //// it will spin upon the Z axis
      let RotateSpeed=1;       ///added to Z to rotate the circle
      let IN=0;              ////added to the real radius, this will be where the inner vertices of the circle will be.
      let OUT=30;         ////added to the real radius, this will be where the outer vertices of the circle will be. It should be equal to the width of the desired image (not the whole image, just the part you want seen.  A bigger number will stretch the image (width-wise).  Experiment and see.


         
      ObjEffect_CreateVertex(objid, 2+sides*2);   ///here, we're making the vertices for the whole circle. A triangle with 3 sides would have 8 vertices, not 6, because the first two are used to "start" the triangle (or any other shape you're doing). The first is the inner verticy, the second is the outer verticy.  Then inner again, then outer, and so on.


////everything below is explained in forum

                     ascent(i in 0..sides+1){    ///since we're doing the shape in pairs, the number vertices will be half of the ObjEffect_CreateVertex

                         ObjEffect_SetVertexUV(objid,i*2,32,d*repeat/sides);  ///the first is the inner verticy
                         ObjEffect_SetVertexUV(objid,i*2+1,0,d*repeat/sides);   ///the second is outer verticy
                         d+=-256;  ////the height of the actual png image.  When it goes out of bounds, it repeats itself.  This can be done infinitely.
                            }
////see the forum for explanation of everything below

      while(!Obj_BeDeleted(objid)){



                     ascent(i in 0..sides+1){         

                     let radiusINX=(totalradius +IN)*cos(i*360/sides +Z);
                     let radiusINY=(totalradius +IN)*sin(i*360/sides +Z);   

                     let radiusOUTX=(totalradius +OUT)*cos(i*360/sides +Z);
                     let radiusOUTY=(totalradius +OUT)*sin(i*360/sides +Z);

                         ObjEffect_SetVertexXY(objid, i*2, radiusINX, radiusINY);
                         ObjEffect_SetVertexXY(objid, i*2+1, radiusOUTX, radiusOUTY);


                           }

               yield;
               }


                   
   }
   








}

ObjEffect_SetVertexUV(objid,i*2,32,d*repeat/sides);
To explain this, lets use the first value of the ascent, which is zero.  Remember, it's done in pairs.  So I'll put in two. The variables in the parameters are like so. Remember, the first vertex is always 0! (id, verticy#, x-coordinate on PNG, Y-coordinate on PNG);  In Danmakufu, it looks like this, with the "i" value in ascent equal to 0.

Code: [Select]
ObjEffect_SetVertexUV(objid,0*2,32,d*repeat/sides);
ObjEffect_SetVertexUV(objid,0*2+1,32,d*repeat/sides);

This way, when i=0,  it will be doubled, so the first verticy will be 0.  Then one added, so the second verticy will be value 1, which is what we want.  Then, when i=1, the verticy value will be doubled again, so 1*2=2. That's our 3rd verticy.  Then one added, 4th verticy will have value of 3, and so on.

Next, d*repeat/sides.  We have 80 sides, with 162 vertices, as you noticed. To make things simple, lets make the repeat value 1, so we only have 1 "line" image in our circle. Since we have 80 sides, we also have to define 81 angles in our circle.  Remember, the first angle will be our "start", and every angle after that will define where our inner and outer vertices of the circle will be.  The entire image will be 256 pixels in height, so 256 pixels divided by 81 angles (the first angle will be the top of our image, so we actually divide the image by 80), that will be how many times we divide that one png "line".  It will stretch all the way around until the circle completes itself, which will make it look messy, so we'll have to repeat the image more than once so it doesn't look like a stretched image. In code, we'll put this as d*repeat/sides.  "d" being the height of the image, divided 80 "times" (sides) due to all the angles, and "repeat" being how many times we multiply the height. 256*2=512, so we're actually dividing the 512 pixels of the "line" by 80.  This looks much neater.

Next, mapping the image on Danmakufu.  The parameters for ObjEffect_SetVertexXY are (id, verticy number, X-coordinate of verticy, Y-coordinate of verticy);

Code: [Select]
ObjEffect_SetVertexXY(objid, i*2, radiusINX, radiusINY);  Remember, we're doing this in pairs, so there's an inner AND outer vertex for the circle.  Two for each angle, so we also have this
Code: [Select]
ObjEffect_SetVertexXY(objid, i*2+1, radiusOUTX, radiusOUTY); Remember what we learned before about the vertex numbers?  We apply it here too. So it's very simple. Same number of ascents as before since we're doing the verticies in pairs, and the same basic code.  "i*2" for the inner, and "i*2+1" for the outer.  Next, defining the X and Y parameters.  It's actually a bit long, so I let a variable represent them to make them a bit shorter.

Code: [Select]
let radiusINX=(totalradius +IN)*cos(i*360/sides +Z); We're using cosine for the X parameter, as always. Basic stuff. Because of that, we have to use 360/sides in there, since there are 360 degrees in a full circle.  Since we're not using 360 sides, we can't just plug in cosine(i+Z).  Instead, we use (i*360/sides+Z).  i being our actual angle which the verticy pairs will lay, and 360/sides being the format we lay it in.  This way, we could use 8 sides to make an octagon, 3 sides to make a triangle, or whatever.  We're not limited to having always using 360 sides because of cosine this way , we could use more or less, whichever we want.  Now that 360/sides is out of the way, what's the "i" for?  We use that for our angle.  The first angle at 0 degrees, then (when i=1, we define our SECOND pair of vertices ) 2nd angle at 4.5 degrees (since we have 80 sides to our circle.  360/80=4.5) The added "Z" in our parameter is the added degrees we use that allows us to "spin" our circle.  When i=2, we define our third pair of vertices, which will be 2*4.5, which is at 9 degrees.  Smart, huh?  360 degrees divide by 4.5 degrees per angle equals 80.  See why we use ascent (i in 0..80+1) now?  And instead name it to (ascent i in..sides+1) instead? We'll easily make it from a pentagon to an 80-sided circle with only having to change 1 variable, instead of like 20.  That's why we use the variable "sides". Remember, we need our added 1 there to actually finish our circle, since our first vertices will only be our starting angle.

We do the same thing for the Y parameter, but instead of using cosine, we use sine.
Code: [Select]
let radiusINY=(totalradius +IN)*sin(i*360/sides +Z);It does the same exact thing, except the sin there is used for our Y parameter. Sine of zero degrees is 0, so our Y parameter doesn't change for GetY; , though the cosine(0 degrees)=1, so it's 100 pixels to the right.  Now since that's out of the way, you might be wondering what the IN there is for?  Well, first let me explain why we have the OUT in
Code: [Select]
let radiusOUTX=(totalradius +OUT)*cos(i*360/sides +Z);Since OUT=30, our radius for the second vertex in each pair of verticies will alway be 30 more than our "totalradius" value.  This is especially useful when we want to shrink our circle without having to reduce the width of the displayed PNG image.  Also, if we want to shrink our circle with the timer, we could just make a timer value. In the beginning of our script, we can put in let timer=GetTimer*60 (multiply by 60 because of 60 frames per second), then let timer2=timer.

After that, we just subtract the value of timer by 1 each frame.  then, we just apply it to the variable totalradius. By now, you should see what's going on here just by looking at it.
Code: [Select]
#TouhouDanmakufu
#Title[magic circle]
#Text[]
#Player[FREE]
#ScriptVersion[2]
 
script_enemy_main{
    let imagefile = GetCurrentScriptDirectory ~ "index.png";
    let objid;




    @Initialize{
      SetMovePosition02(GetCenterX,GetCenterY-100,0);
      SetLife(1);
      LoadGraphic(imagefile);
      SetTimer(10);
      object;
    }
 
    @MainLoop{
      yield;
    }
 
    @DrawLoop{
    }
 
    @BackGround{
    }
 
    @Finalize{
    }

   task object{   yield; yield;


      objid = Obj_Create(OBJ_EFFECT);
      Obj_SetX(objid, GetX);
      Obj_SetY(objid, GetY);
      ObjEffect_SetScale(objid,1,1);
      ObjEffect_SetPrimitiveType(objid, PRIMITIVE_TRIANGLESTRIP);
      ObjEffect_SetRenderState(objid,ADD);
      ObjEffect_SetTexture(objid, imagefile);

      let totalradius=250;
      let repeat=3;
      let sides=80;     
      let d=0;     
      let rotate=0;
      let RotateSpeed=1;
      let timer=GetTimer*60;
      let timer2=timer;
      let IN=-totalradius;
      let OUT=-totalradius;


         
      ObjEffect_CreateVertex(objid, sides*2+2);   



                     ascent(i in 0..sides+1){

                         ObjEffect_SetVertexUV(objid,i*2,32,d*repeat/sides);
                         ObjEffect_SetVertexUV(objid,i*2+1,0,d*repeat/sides);
                         d+=-256;
                            }


      while(!Obj_BeDeleted(objid)){



                     ascent(i in 0..sides+1){         

                     let radiusINX=(totalradius*timer/timer2+IN)*cos(i*360/sides +rotate);
                     let radiusINY=(totalradius*timer/timer2+IN)*sin(i*360/sides +rotate);

                     let radiusOUTX=(totalradius*timer/timer2+OUT)*cos(i*360/sides +rotate);
                     let radiusOUTY=(totalradius*timer/timer2+OUT)*sin(i*360/sides +rotate);

                         ObjEffect_SetVertexXY(objid, i*2, radiusINX, radiusINY);
                         ObjEffect_SetVertexXY(objid, i*2+1, radiusOUTX, radiusOUTY);


                           }


               if(IN<0){IN+=totalradius/100;}
               if(OUT<30){OUT+=totalradius/20;}
               rotate+=RotateSpeed;
               timer--;
               yield;
               }


                   
   }
   








}

The reason why we have to define function SetVertexXY each frame is because it changes every frame.  If you want it to spin or shrink or whatever, you'll have to have it in just before the end of the loop, like so.
Code: [Select]
while(!Obj_BeDeleted(objid)){

all your SetVertexXY ascents here....
yield;
Z++;  //or Z+=rotation, and define the rotation variable up near the top of the task
timer--;
whatever else;
}


Okay, next.  This is where the somewhat tricky part comes in.  This is completely optional, but can have a really cool effect.  Next we want to bend the circle into a star shape with smooth edges.  Okay, here we go.


Next, we want to put in two new variables. "extra" and "digit".
"extra" will be our extra radius added onto our real radius, "totalradius" See how the edges there are smooth? They move in a smooth and wavy-like motion, kind of like a wave, and really reminds us of how sine looks like when we graph it. That's because, we're using it! We're actually using sin(angle) for this.  Remember, our initial angle is at 0 degrees, so sine of 0 is 0.  Then, as we move to 90 degrees in our sine, our resultant goes toward 1. Then as we go to 180, sin moves toward 0 again, then at 270 degrees, we get a resultant toward -1, and as we finish our 360 degrees in our sine, our resultant finishes at 0 again. That's one full revolution.  Up there in the image above, we have 5 revolutions. Now, one pixel isn't noticable, so we'll have to multiply our resultant by a considerable amount.  40 pixels is good, so our "extra" will have the value of 40, multiplied by our sine function, which altogether will be added on to our value of "totalradius"

Remember how we did 5 revolutions? That's what the variable "digit" will equal.  Keep that in mind.  Now, when dealing with sine or cosine, they revolve around 360 degrees, or in our case, we'll have to use 360 angles.  That can eat up on our memory so we'll need to tone it down a bit.  It's the same thing we did before when dealing with sine.  "360/sides"  So in our X parameter of our inner verticy, we'd have this.
Code: [Select]
let radiusINX=(radius+RadiusIN+extra*sin(360/sides*digit))*cos(i*angle +rotate);Then, in the ascent, since we want the value of "digit" to change while we're forming our circle, we also put this in the ascent
Code: [Select]
digit+=5;Get it?  If we had 360 sides, that'd also be 360 angles.  360/360=1.  sin(1*5)=0.087  Which is what we want.  The next angle, it would be sin(1*10)=0.17;, and so on for the next 360 angles. But because we use sin(360/sides), we don't have to have 360 sides in our circle for the sine to work, and can use less instead.  sin(360/sides*digit) is what we want, and so it works.  Basically what we did here is make 5 revolutions, and get the sin value of each degree in each revolution, and add that to the total radius of our circle as we make it.  This is how we get that wavy effect.

Now, we just plug it in our inner and outer vertex components, and this is what we should get.
Code: [Select]
                     let radiusINX=(radius+RadiusIN+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusINY=(radius+RadiusIN+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                     let radiusOUTX=(radius+RadiusOUT+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusOUTY=(radius+RadiusOUT+extra*sin(360/sides*digit))*sin(i*angle +rotate);

Then, with the digit adding to itself, in each loop of the ascent, we just plug in the variables we made into the actual parameters for our verticies.  Altogether, it should look like this.

Code: [Select]
                     ascent(i in 0..sides+1){
                     

                     let radiusINX=(radius+RadiusIN+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusINY=(radius+RadiusIN+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                     let radiusOUTX=(radius+RadiusOUT+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusOUTY=(radius+RadiusOUT+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                    digit+=5;


                         ObjEffect_SetVertexXY(circle, i*2, radiusINX, radiusINY);
                         ObjEffect_SetVertexXY(circle, i*2+1, radiusOUTX, radiusOUTY);

                                     }

The one little pesky problem here is, "ascent(i in 0..sides+1)"
Because of that added 1, it throws our entire circle off and makes it spin and look funky.  We could fix it by adding 1 to our sides in
Code: [Select]
(radius+RadiusOUT+extra*sin((360(sides+1))*digit))*cos(i*angle +rotate);, but then that X and Y coordinates for our last pair of verticies will be off, and the star doesn't connect to itself and looks funky because of the "digit+=5".  It finishes our sine at 360 degrees, but because our first angle is use to start our circle (the one we use for our first pair of verticies), the last angle we use to define our last pair of IN and OUT verticies gets an extra 5, and our finishing verticies get the value of (360/sides*digit), with digit=405 (which, with our sine and our number of sides in our circle being 80, is equal to digit=5), where as the first angle for our first verticies get (360/sides*digit) with digit=0.    So instead, we use our ascent without the added 1.  This will make our star look good, but incomplete because the finishing angle is missing.  That last pair of verticies will have to be added manually.  I take the time to do it.  NOTE: the variable lastdigit=digit.  Initially, digit was 0 before the while(!Obj_BeDeleted(circle)) loop , so lastdigit is also 0.  When the last pair of verticies are made, they are made with the exact same variables with just a few small differences.  Our last angle is equal to our first angle, and the verticies along with it are also the same, so we must have the same variables altogether but with the variable
Code: [Select]
lastdigit equal to initial digit, before it adds a 5 to itself.  i=0 in our first run of the ascent, so our last angle is also equal to zero degrees, + the added Z for rotation.  This gives us a perfect star.

Here's the code you should have in it in your while loop.  Notice, LastINX, etc, should be almost exactly the same as your initial INX, with a few exceptions like the lastdigit, and so on. Wherever the variable "i" would go, replace with 0, since our first run in ascent with "i" also equals zero.

Code: [Select]
      while(!Obj_BeDeleted(circle)){



                     ascent(i in 0..sides){
                     

                     let radiusINX=(radius+RadiusIN+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusINY=(radius+RadiusIN+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                     let radiusOUTX=(radius+RadiusOUT+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusOUTY=(radius+RadiusOUT+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                    digit+=5;


                         ObjEffect_SetVertexXY(circle, i*2, radiusINX, radiusINY);
                         ObjEffect_SetVertexXY(circle, i*2+1, radiusOUTX, radiusOUTY);

                                     }


                    let LastInX=(radius+RadiusIN+extra*sin(360/sides*lastdigit))*cos(0*angle +rotate);
                    let LastInY=(radius+RadiusIN+extra*sin(360/sides*lastdigit))*sin(0*angle +rotate);

                     let LastOutX=(radius+RadiusOUT+extra*sin(360/sides*lastdigit))*cos(0*angle +rotate);
                     let LastOutY=(radius+RadiusOUT+extra*sin(360/sides*lastdigit))*sin(0*angle +rotate);

                        ObjEffect_SetVertexXY(circle, sides*2, LastInX, LastInY);
                        ObjEffect_SetVertexXY(circle, sides*2+1, LastOutX, LastOutY);



               
               if(extra>0){extra+=addtoextra;}
               yield;
               }


Altogether, you can warp it to your desire, very easily.  Stuff like coloring the verticies, changing the alpha value, number of sides, our circle has, IF its a circle, it should all be elementary at this point.

The entire code for the warping circle
Code: [Select]
#TouhouDanmakufu
#Title[magic circle 3]
#Text[]
#Player[FREE]
#ScriptVersion[2]
 
script_enemy_main{
    let imagefile = GetCurrentScriptDirectory ~ "index.png";




    @Initialize{
      SetMovePosition02(GetCenterX,GetCenterY-100,0);
      SetLife(1);
      LoadGraphic(imagefile);
      SetTimer(60);
      object;
    }
 
    @MainLoop{
      yield;
    }
 
    @DrawLoop{
    }
 
    @BackGround{
    }
 
    @Finalize{
    }

   task object{   yield; yield;


      let circle = Obj_Create(OBJ_EFFECT);
      Obj_SetX(circle, GetX);
      Obj_SetY(circle, GetY);
      ObjEffect_SetScale(circle,1,1);
      ObjEffect_SetPrimitiveType(circle, PRIMITIVE_TRIANGLESTRIP);
      ObjEffect_SetRenderState(circle,ADD);
      ObjEffect_SetTexture(circle, imagefile);

      let radius=100;
      let RadiusIN=0;
      let RadiusOUT=30;
      let INA=0;
      let OUTA=0;
      let repeat=6;
      let sides=60;
      let d=0;     
      let rotate=0;
      let RotateSpeed=1;
      let angle=360/sides;
      let angle2=0;
      let digit=rand(0,180);
      let lastdigit=digit;
      let extra=40;
      let addtoextra=-0.4;
     
   



         
      ObjEffect_CreateVertex(circle, sides*2+2);   



                     ascent(i in 0..sides+1){

                         ObjEffect_SetVertexUV(circle,i*2,32,d*repeat/sides);
                         ObjEffect_SetVertexUV(circle,i*2+1,0,d*repeat/sides);

                         d+=-256;
                            }


      while(!Obj_BeDeleted(circle)){



                     ascent(i in 0..sides){
                     

                     let radiusINX=(radius+RadiusIN+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusINY=(radius+RadiusIN+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                     let radiusOUTX=(radius+RadiusOUT+extra*sin(360/sides*digit))*cos(i*angle +rotate);
                     let radiusOUTY=(radius+RadiusOUT+extra*sin(360/sides*digit))*sin(i*angle +rotate);

                    digit+=5;


                         ObjEffect_SetVertexXY(circle, i*2, radiusINX, radiusINY);
                         ObjEffect_SetVertexXY(circle, i*2+1, radiusOUTX, radiusOUTY);

                                     }


                    let LastInX=(radius+RadiusIN+extra*sin(360/sides*lastdigit))*cos(0*angle +rotate);
                    let LastInY=(radius+RadiusIN+extra*sin(360/sides*lastdigit))*sin(0*angle +rotate);

                     let LastOutX=(radius+RadiusOUT+extra*sin(360/sides*lastdigit))*cos(0*angle +rotate);
                     let LastOutY=(radius+RadiusOUT+extra*sin(360/sides*lastdigit))*sin(0*angle +rotate);

                        ObjEffect_SetVertexXY(circle, sides*2, LastInX, LastInY);
                        ObjEffect_SetVertexXY(circle, sides*2+1, LastOutX, LastOutY);



               
               if(extra>0){extra+=addtoextra;}
               yield;
               }

     
     }
   








}

It's set up so you can easily manipulate it.  Good luck.
« Last Edit: November 11, 2009, 06:24:45 AM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread II
« Reply #314 on: November 11, 2009, 05:06:01 AM »
This deserves a spot in the intermediate tutorial

Re: Danmakufu Q&A/Problem Thread II
« Reply #315 on: November 11, 2009, 05:12:46 AM »
Hm. I have run into a situation with object bullets once more.

I am trying to make the bullets fall erratically down the screen, but they do not move at all.

Code: [Select]
task flower(x, angle) {
     let obj=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj, x, GetClipMinY);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, 0);
     ObjShot_SetGraphic(obj, RED12);
     ObjShot_SetDelay(obj, 10);
     ObjShot_SetBombResist(obj, true);

     while(Obj_BeDeleted(obj)==false){

Obj_SetPosition(obj, Obj_GetX(obj) + rand(-2, 2), Obj_GetY(obj) + rand(1, 3));
Obj_SetAngle(obj, Obj_GetAngle(obj) + 3);


       yield;
}
}

The speed has nothing to do with it, because I want the bullets to fall in groups of four (i.e. shuriken shape). Neither the angle nor the position of the bullets change here, for some odd reason (practically everything inside "while(Obj_BeDeleted)" does not work). What is the problem here?
« Last Edit: November 11, 2009, 05:15:38 AM by Frazer »

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #316 on: November 11, 2009, 05:16:45 AM »
Hm. I have run into a situation with object bullets once more.

I am trying to make the bullets fall erratically down the screen, but they do not move at all.

Code: [Select]
task flower(x, angle) {
     let obj=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj, x, GetClipMinY);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, 0);
     ObjShot_SetGraphic(obj, RED12);
     ObjShot_SetDelay(obj, 10);
     ObjShot_SetBombResist(obj, true);

     while(Obj_BeDeleted(obj)==false){

Obj_SetPosition(obj, Obj_GetX(obj) + rand(-2, 2), Obj_GetY(obj) + rand(1, 3));
Obj_SetAngle(obj, Obj_GetAngle(obj) + 3);


       yield;
}
}

The speed has nothing to do with it, because I want the bullets to fall in groups of four (i.e. shuriken shape). Neither the angle nor the position of the bullets change here, for some odd reason (practically everything inside "while(Obj_BeDeleted)" does not work). What is the problem here?

Nothing wrong with your task from what I can tell in my quick glance. Is there a yield; in your @MainLoop?
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Re: Danmakufu Q&A/Problem Thread II
« Reply #317 on: November 11, 2009, 05:22:34 AM »
Nope. I just did that and it fixed.

I forgot about the yield. I really make the clumsiest mistakes sometimes.

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread II
« Reply #318 on: November 11, 2009, 05:28:05 AM »
Aww, Mokou's circle script is fancier than mine... oh well, I'm sure mine has its uses. Mokou's is more customizable while mine has everything ready from the get-go.
Great tutorial by the way, you should put it in its own thread so it can have its own discussion.

Lawence Codye

  • The Nine Tails of Subconscious...
  • Come & your desires shall all become reality...
Re: Danmakufu Q&A/Problem Thread II
« Reply #319 on: November 11, 2009, 05:38:57 AM »
@Fujiwara no Mokou
Thank you very much...now to create...5 Seasons...
& I agree with some others that all that should be an addition to a tutorial, it's own tutorial or
made into a thread topic for discussion...

Also thanks all others who helped me with whatever else I ask for help with...
I am the Nine Tails of Subconscious...

Come & your greatest desires will be reality...

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #320 on: November 11, 2009, 05:46:23 AM »
I haven't read it all yet, but that's still great. Especially if Hele can make use of this code. Probably deserves a spot somewhere as it's not exactly a tutorial, though. Post it on the wiki for sure.

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

Re: Danmakufu Q&A/Problem Thread II
« Reply #321 on: November 11, 2009, 05:48:56 AM »
Think it's time we start compiling an "expert tutorial (or database)", which will most likely consist only of instructions for really complicated effects, much like this one.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #322 on: November 11, 2009, 05:50:05 AM »
 ;D Haha thanks.  I think I'll get back to this later, though. There's a lot of work for me to do.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #323 on: November 11, 2009, 06:56:28 AM »
Expert tutorial section , go.

I haven't read it all yet, but that's still great. Especially if Hele can make use of this code. Probably deserves a spot somewhere as it's not exactly a tutorial, though. Post it on the wiki for sure.

Definitely. I was fooling around already trying to shape but kept getting the sides wrong leaving a gap in the circle. Also the texture mapping was horrible. Now with this tutorial I can finally shape a good looking one.

I will read the tutorial fully tonight or so to try out things.
« Last Edit: November 11, 2009, 07:01:41 AM by Helepolis »

Nimble

  • Broken English Fox
  • Rushing toward the bullet!
    • Viewmix
Re: Danmakufu Q&A/Problem Thread II
« Reply #324 on: November 11, 2009, 09:45:05 AM »
Some graphic question :V

I looking for drawing function that can make a layer of BG and scroll them like in #BackGround, but don't find any.

I want to make multi layer scrolling background like this

Is it possible in danmakufu?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #325 on: November 11, 2009, 10:09:08 AM »
That is extremely easy.

somewhere in the beginning: let scrolling = 0;
Inside @BackGround:   
DrawGraphic(GetX, GetY+scrolling); <--- drawing
scrolling++;  <-- scroll speed.

Remember the order of drawing, the first drawn image is always at the bottom. The 2nd is above it etc.

Example:

// ground
SetTexture(ground);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling);

// bushes / forest
SetTexture(forest);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling2); <-- different speed or unless you are math whiz add math

// clouds
SetTexture(clouds);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling3);  <--- same as above
« Last Edit: November 11, 2009, 10:11:09 AM by Helepolis »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #326 on: November 11, 2009, 10:20:10 AM »
I have had a go at Fujiwara's spellcircle code, though I don't get the extreme complexity of the circle spawning. Note that the following is just an analysis. You can take it as you want it :V Right, to explain myself:

Am I missing vital information here why the circle has so many spreaded out math and functions? If I take a look for example at your Spellcircle code on page 5 ( didn't knew there was one there ). It is so much easier and simple to spawn. Aswell as achieving the same endresults for the simple beings. The difference I can tell between both codes is this one has the ability to retain image rects while shrinking.

Though I am puzzled why you are rotating the vertexs inside the code and not just use ObjEffect_SetAngle(0,0,spin);?

Also the double yield is not needed. The circle does spawn even if you call the task inside @initialize

I think we can make this spellcircle codewise more efficient. I'll dig bit more through it. I am having trouble with imitating so I will try the good old copy/paste method and then break down while analysing.


Edit: ( just a sum up what I personally think it can be improved / changed
I am not a math whizkid so for the "lagging" behaviour of the circle simply create a familiar upon spellcircle spawn and use the effect object code here. Then add a function for movement, see below.

task circleMove{loop{SetMovePosition03(GetEnemyX,GetEnemyY,10,10); yield;}}

- Double yields not needed
- Obj_SetPosition(objid,GetX,GetY);   inside the loop. to reposition the circle with the enemy.
- Rotation done with  ObjEffect_SetAngle(obj,0,0,rotation); ( eliminates the rotationspeed var, rotation can be kept just set the speed with  rotation++; or rotation+=5; or w/e )
        
I am liking Fujiwara's spellcircle code. It is strong, it just needs some cleanup that is all.
Double circle spawned , note how the outercircles are "lagging" behind the main spellcircle.

« Last Edit: November 11, 2009, 10:55:22 AM by Helepolis »

Nimble

  • Broken English Fox
  • Rushing toward the bullet!
    • Viewmix
Re: Danmakufu Q&A/Problem Thread II
« Reply #327 on: November 11, 2009, 10:54:07 AM »
That is extremely easy.

somewhere in the beginning: let scrolling = 0;
Inside @BackGround:   
DrawGraphic(GetX, GetY+scrolling); <--- drawing
scrolling++;  <-- scroll speed.

Remember the order of drawing, the first drawn image is always at the bottom. The 2nd is above it etc.

Example:

// ground
SetTexture(ground);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling);

// bushes / forest
SetTexture(forest);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling2); <-- different speed or unless you are math whiz add math

// clouds
SetTexture(clouds);
blabla SetGraphicRect, Angle etc.
DrawGraphic(GetX, GetY+scrolling3);  <--- same as above

Oh I didn't think of this..... oTL~

Thank you so much :)


Infy♫

  • Demonic★Moe
  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #328 on: November 11, 2009, 08:11:35 PM »
I wonder if someone here could possibly make the music i got, playable for danmakufu? because some songs make danmakufu act weird or crash!
at certain points i am being forced to use songs i dont want to use or that dont fit very well...
or at least tell me how to make them playable using audacity

Re: Danmakufu Q&A/Problem Thread II
« Reply #329 on: November 11, 2009, 08:15:28 PM »
I wonder if someone here could possibly make the music i got, playable for danmakufu? because some songs make danmakufu act weird or crash!
at certain points i am being forced to use songs i dont want to use or that dont fit very well...
or at least tell me how to make them playable using audacity
Try to see if there are any similarities in the bitrate/sample rate of the songs you are using that work, and convert the songs that don't work according to those values.