Author Topic: Another Danmakufu Tutorial?  (Read 48731 times)

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Another Danmakufu Tutorial?
« Reply #60 on: May 14, 2009, 09:46:06 AM »
Thank you.

Why does Iryan say put it after finalize?
Because I put it there everytime and because every script that uses tasks and that I've looked at does it. When I say "after the @Finalize part", I mean "after the closing bracket of your @ Finalize script". I don't mean "After the stuff after the closing bracket of the @Finalize part which would be the closing bracket of your enitre script thus causing the task not to be included in the script at all". One bracket makes all the difference.  ;D


On the bouncing, I've done a spellcard where three objects bounce inside a cage, it's not that difficult. Bullets bouncing off of each other, well, as has been said you'd need to have all the bullets be on seperate IDs, which is troublesome if you want a high amount of bullets. The real problem though would be to make the bullets bounce in a realistic fashion. I've thought about it, and to really emulate a bounce that feels "right", providing that all bullets move at the same speed, a real bounce is imitated by setting the angle of both bullets to the angle of the other one. To do that, You have to store the angle of one bullet in a variable, then copy the other bullet's angle, than change the other bullet's angle to the value of the variable. One has to be careful, though. If both bullets have this ability, they will cancel each other out. Thus every bullet pair must have only one instance of this check. Which one it is bound to is obsolete. Hell, as you probably need different tasks for each bullet, you sould be just fine putting all the bounce controllers in the main loop!

So yeah...

On another note, is there a way to have the same task spit out objects of different names which depend on a parameter so that you'd need only one task for all these interacting bullets? Something that involves converting stuff into strings with a command? Or the other way round? It could save pages of code and time.
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."

Garlyle

  • I can't brain today
  • I have the dumb
    • Tormod Plays Games
Re: Another Danmakufu Tutorial?
« Reply #61 on: May 15, 2009, 12:40:25 AM »
Quote
On another note, is there a way to have the same task spit out objects of different names which depend on a parameter so that you'd need only one task for all these interacting bullets? Something that involves converting stuff into strings with a command? Or the other way round? It could save pages of code and time.

Arrays.  I don't wanna wrap my brain around that right now, too busy enjoying Uwabami Breakers.

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Another Danmakufu Tutorial?
« Reply #62 on: May 15, 2009, 01:36:17 AM »
On another note, is there a way to have the same task spit out objects of different names which depend on a parameter so that you'd need only one task for all these interacting bullets? Something that involves converting stuff into strings with a command? Or the other way round? It could save pages of code and time.

Arrays.  I don't wanna wrap my brain around that right now, too busy enjoying Uwabami Breakers.

If you check in my scripts thread, you can check out Random Sign 「Entropy」 ...

This spellcard was made to demonstrate using arrays to keep track of several object shots (and give a glimpse of what truely random danmaku could look like :V ).  I tried to comment it heavily enough that it can help you learn how to handle it.

If not, feel free to ask and I can give a more in-depth explaination.

BTW - you don't need a task to handle this.  Like I did in the above spellcard, it can be all handled in @MainLoop.  That's my preferred style, but either way will work fine.

On the bouncing, I've done a spellcard where three objects bounce inside a cage, it's not that difficult. Bullets bouncing off of each other, well, as has been said you'd need to have all the bullets be on seperate IDs, which is troublesome if you want a high amount of bullets. The real problem though would be to make the bullets bounce in a realistic fashion. I've thought about it, and to really emulate a bounce that feels "right", providing that all bullets move at the same speed, a real bounce is imitated by setting the angle of both bullets to the angle of the other one. To do that, You have to store the angle of one bullet in a variable, then copy the other bullet's angle, than change the other bullet's angle to the value of the variable. One has to be careful, though. If both bullets have this ability, they will cancel each other out. Thus every bullet pair must have only one instance of this check. Which one it is bound to is obsolete. Hell, as you probably need different tasks for each bullet, you sould be just fine putting all the bounce controllers in the main loop!

I did "bullets bouncing off of lasers" in another spellcard in my post, Light Sign 「Reflection/Refraction」.

It's not commented as well as Entropy, but hopefully you can get something useful out of it.  It handles object-to-object collision detection, and determines the angle of the bullet being reflected off of the laser.
(It also, by the way, refracts the same bullets through the lasers when they collide)

Its not exactly what you're referring to, but it might give some help.
to quote Naut:
"I can see the background, there are too many safespots."
:V

Re: Another Danmakufu Tutorial?
« Reply #63 on: May 15, 2009, 02:24:33 AM »
Collision isn't too hard, just ensure declaration of 'reflector' (etc.) Objects are both A) Unique and B) public (aka the 'let' text is in normal variable location, not a task/loop/etc. )

I'll try?

EDIT: 8D Okay, does odd things once in a while, but... :3
Code: [Select]
#TouhouDanmakufu
#Title[Mirror Sign 「Border Trackers」]
#Text[Testing obj collision]
#BackGround[Default]
#BGM[.\bgm.mp3]
#PlayLevel[Test]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let frame = -120;
    let arc = 0.5;
    let cx=GetCenterX();
    let minx=GetClipMinX;
    let maxx=GetClipMaxX;
    let miny=GetClipMinY;
    let maxy=GetClipMaxY;
    let cy=GetCenterY();
    let imgExRumia="script\img\ExRumia.png";
    let BossCutIn = "player\Rumia\RumiaCutIn.png";
    let SEShot = GetCurrentScriptDirectory~"sound\Eff1.wav";
    let objLaz1=Obj_Create(OBJ_LASER);
    let objLaz2=Obj_Create(OBJ_LASER);

task BoundShot(x, y, v, angle) {
      let obj=Obj_Create(OBJ_SHOT);
      Obj_SetPosition(obj, x, y);
      Obj_SetAngle(obj, angle);
      Obj_SetSpeed(obj, v);
      ObjShot_SetGraphic(obj, RED01);
      ObjShot_SetDelay  (obj, 10);
      ObjShot_SetBombResist (obj, true);
      while(Obj_BeDeleted(obj)==false) {
              if(Collision_Obj_Obj(obj,objLaz1)) {
                     Obj_SetAngle(obj,180 - Obj_GetAngle(obj) );
                     Obj_SetX(obj,Obj_GetX(objLaz1) + 5);
              }
              if(Collision_Obj_Obj(obj,objLaz2)) {
                     Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) );
                     Obj_SetX(obj,Obj_GetX(objLaz2) - 5);
              }
              if(Obj_GetY(obj) < 0){
                     Obj_SetY(obj,10);
                     Obj_SetAngle(obj,180-Obj_GetAngle(obj));
              }
              yield;
       }
}

task Lasercage1() {
      Obj_SetAngle(objLaz1, 90);
      ObjLaser_SetLength(objLaz1, maxx+50);
      ObjLaser_SetWidth(objLaz1, 7);
      ObjShot_SetDelay(objLaz1, 60);
      ObjShot_SetGraphic(objLaz1, WHITE01);
      Obj_SetSpeed(objLaz1, 0);
      Obj_SetY(objLaz1, 0);
      while(Obj_BeDeleted(objLaz1)==false) {
            if(GetPlayerX-120 > minx){
                  Obj_SetX(objLaz1, GetPlayerX-120);
            }else{
                  Obj_SetX(objLaz1, minx);
            }
            Obj_SetCollisionToObject(objLaz1, true);
            ObjShot_SetBombResist(objLaz1, true);
            yield;
      }
}
task Lasercage2() {
      Obj_SetAngle(objLaz2, 90);
      ObjLaser_SetLength(objLaz2, maxx+50);
      ObjLaser_SetWidth(objLaz2, 7);
      ObjShot_SetDelay(objLaz2, 60);
      ObjShot_SetGraphic(objLaz2, WHITE01);
      Obj_SetSpeed(objLaz2, 0);
      Obj_SetY(objLaz2, 0);
      while(Obj_BeDeleted(objLaz1)==false) {
            if(GetPlayerX+120 < maxx){
                  Obj_SetX(objLaz2, GetPlayerX+120);
            }else{
                  Obj_SetX(objLaz2, maxx);
            }
            Obj_SetCollisionToObject(objLaz2, true);
            ObjShot_SetBombResist(objLaz2, true);
            yield;
      }
}

    @Initialize {
        SetLife(4000);
SetDamageRate(100,80);
SetTimer(50);
        SetInvincibility(120);
Concentration01(120);
        SetEnemyMarker(true);
        SetScore(1000000);
        SetEffectForZeroLife(120,51,1);
        LoadGraphic(imgExRumia);
        SetGraphicRect(1,1,64,64);
        CutIn(YOUMU, "Mirror Sign 「Border Trackers」", BossCutIn, 0, 0, 200, 600);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24);
        SetY(90);
        SetX(GetPlayerX);
        SetShotAutoDeleteClip(175,64,175,64);
if (frame==-60){
Lasercage1;
Lasercage2;
}
frame++;
        if (frame==0){
                BoundShot(GetX,GetY,2.5,arc);
                BoundShot(GetX,GetY,2.5,arc+90);
                BoundShot(GetX,GetY,2.5,arc+180);
                BoundShot(GetX,GetY,2.5,arc+270);
                arc += rand_int(8,12);
        }
if (frame==9){
frame = -1;
}
        yield;
    }

    @DrawLoop {
SetTexture(imgExRumia);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);
    }

    @Finalize {
loop(8){
CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
}
DeleteGraphic(imgExRumia);
    }

    @BackGround {
    }
}



Thank you very much for the information.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Another Danmakufu Tutorial?
« Reply #64 on: July 25, 2009, 08:33:41 PM »
Quote
Sounds that you can change by filename are

sePlayerShot01.wav   
seGraze.wav   
sePlayerCollision.wav (?)
sePlayerSpellCard.wav (?)
se1UP.wav   
seScore.wav   
seBomb_ReimuA.wav   
seExplode01.wav   
seBomb_ReimuB.wav
seUseSpellCard.wav (?)
seGetSpellCardBonus.wav (?)
seEnemyExplode01.wav   
seSuperNaturalBorder1.wav   
seSuperNaturalBorder2.wav

and

STG_Player01.png
STG_Player11.png
CutIn_PlayerChar01.png
CutIn_PlayerChar11.png
Select_Player01.png
Select_Player11.png
STG_Frame.png

How about System.png, SystemText.png and Effect.png? What do those things change?
« Last Edit: July 31, 2009, 04:48:35 AM by Alwaysnew »

Drake

  • *
Re: Another Danmakufu Tutorial?
« Reply #65 on: July 25, 2009, 09:04:38 PM »
I'm not sure. I've been hearing they do do something though, so I'll have to check it out some time.

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Another Danmakufu Tutorial?
« Reply #66 on: July 26, 2009, 12:31:11 PM »
Where do you have to place these anyway?

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Another Danmakufu Tutorial?
« Reply #67 on: July 26, 2009, 03:22:13 PM »
Where do you have to place these anyway?
The img folder, that's on the main danmakufu folder as well. Normally it doesn't exist, because you're using all the default images.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Another Danmakufu Tutorial?
« Reply #68 on: July 26, 2009, 04:50:38 PM »
So that is how people modify the screen images.

edit: Well yea, the sounds go in "se" folder  (create it inside the root). I added Marisa's Masterspark sound and it works very nice. seBomb_MarisaB.wav

This will be a nice touchup for my v3 of Dancecontest as I plan to add sprites for Marisa aswell. White Marisa looks a bit =.=
« Last Edit: July 26, 2009, 07:48:26 PM by Helepolis »

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Another Danmakufu Tutorial?
« Reply #69 on: July 31, 2009, 04:51:21 AM »
So that is how people modify the screen images.

edit: Well yea, the sounds go in "se" folder  (create it inside the root). I added Marisa's Masterspark sound and it works very nice. seBomb_MarisaB.wav

This will be a nice touchup for my v3 of Dancecontest as I plan to add sprites for Marisa aswell. White Marisa looks a bit =.=

I put -THIS- in my img folder.  ;)
So far, the "Ten" bar obscures part of the #PlayLevel name. :(
Anyways...
« Last Edit: July 31, 2009, 04:55:20 AM by Alwaysnew »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Another Danmakufu Tutorial?
« Reply #70 on: July 31, 2009, 05:37:12 AM »
That I already have, a different framework. But I don't want to show it yet.

We should add these together with Pikaguy's stuff into Danmakufu tutorial.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Another Danmakufu Tutorial?
« Reply #71 on: August 26, 2009, 05:52:26 AM »
Quote
Up-to-date Cutins

Dont you just envy the new cutin scripts on the newer touhou games? What im thinking for this one would be a drawing function in the boss that would activate at the start of regular spellcards, You would ignore the actual Cutin script. This drawing function would also be easely editable for those who want to expiriment with their own custom-cutin functions.

Quote
#include won't work for drawing the cutins, I don't think.

Instead of calling a cutin, create a boolean upon loading. When a cutin is needed, change it to true. An 'if' statement inside the drawing loop activates. It should call a separate function that displays the graphic, moves it, resizes and all that junk based on what arguments the user calls.

...

How about this: I managed to do something like CtC does.

Code: [Select]
script_enemy cutin {
    let cutinimage = "script\img\cut_in.png";
    let frame = 0;
    let rotate = 0;
    @Initialize {
        SetLife(1);
        LoadGraphic(cutinimage);
        SetMovePosition02(GetClipMaxX-100, GetClipMaxY-100, 10);
    }

    @MainLoop {
        frame++;
        if(rotate >= 90) { VanishEnemy; }
        if(frame >= 51 && rotate < 90) { rotate += 15; }
        yield;
    }

    @DrawLoop {
        SetTexture(cutinimage);
        SetGraphicRect(2, 1710, 164, 1899);
        SetGraphicAngle(0, rotate, 0);
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(cutinimage);
    }
}

Now all I have to do is put
Code: [Select]
CreateEnemyFromScript("cutin", GetClipMinX-100, GetClipMaxY-100, 0, 0, 0);in @Initialize of script_enemy_main and that's it.

 :yukkuri:

Actually, screw that. Helepolis just made a custom cut-in script and it looks way more awesome.
« Last Edit: September 23, 2009, 10:08:35 PM by AlwaysThe⑨ »