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

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread
« Reply #270 on: July 13, 2009, 01:58:19 AM »
On an entirely different note, am I the only one who uses the ascent function? All you other folks seem to always create regular loops in which a variable is increased. Am I missing something here?

I've noticed that some people use ascent, while others (like myself) just use the while ... ++ loop construct.  It's really a matter of preference.  It's Danmakufu's equivalent to the typical for loop structure.

Personally, coming from a C/C++ background, I find ascent's syntax a bit strange, so I don't use it.  But there's really no reason to choose one over the other when both could be applied.
to quote Naut:
"I can see the background, there are too many safespots."
:V

Re: Danmakufu Q&A/Problem Thread
« Reply #271 on: July 13, 2009, 02:17:23 AM »
On an entirely different note, am I the only one who uses the ascent function? All you other folks seem to always create regular loops in which a variable is increased. Am I missing something here?

Pretty much what NC said. It's personal preference, which runs wild in Danmakufu. You can achieve the same results with while, loop, ascent, decent, ctrl v... Same issue with if and alternative/case (which almost nobody uses, probably because it isn't taught anywhere). I for one completely ignore the @MainLoop nowadays and just build everything in a myriad of tasks, while I see most people still operate using conditional statements in @MainLoop. Pikaguy900 uses an impressive amount of arrays in his scripts. It's all personal preference, since almost everything in Danmakufu can be done in at least two different ways.

Kinda makes reading other people's scripts confusing...

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #272 on: July 13, 2009, 03:00:38 AM »
Yeah I'm actually in the same boat as Cheese, I'm used to a different syntax on for loops and I never feel like looking up how to do ascent.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #273 on: July 13, 2009, 08:31:01 AM »
I have a question regarding the reflecting/bouncing lasers from walls. I did the most stupid (and easiest) thing to copypaste the entire code from Touhou wiki. I was busy trying to recreate the laser show attack from Afro dude in Uwabami breakers.

So it works, very nice but the lasers keep on bouncing everytime they hit the wall or ceiling. How do I make the lasers bounce maximum 1 time against either ceiling/wall. So basicly: Laser is shot: bounces once against the ceiling or walls and then leaves the screen (can be either ceiling/wall/floor)


puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #274 on: July 13, 2009, 10:02:26 AM »
Here's another simple one:
How do you make indestructible bullets that can survive both bombs, and the player when losing a life?
Is it as simple as CreateShot and adding a few commands, or does it need more than that?
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #275 on: July 13, 2009, 12:44:21 PM »
I have a question regarding the reflecting/bouncing lasers from walls. I did the most stupid (and easiest) thing to copypaste the entire code from Touhou wiki. I was busy trying to recreate the laser show attack from Afro dude in Uwabami breakers.

So it works, very nice but the lasers keep on bouncing everytime they hit the wall or ceiling. How do I make the lasers bounce maximum 1 time against either ceiling/wall. So basicly: Laser is shot: bounces once against the ceiling or walls and then leaves the screen (can be either ceiling/wall/floor)

If you created a task which shoots one bouncing laser,
Inside the task:
let notyetbounced = true;
if(notyetbounced)
{*insert whatever bounce codes*
notyetbounced = false;}


Here's another simple one:
How do you make indestructible bullets that can survive both bombs, and the player when losing a life?
Is it as simple as CreateShot and adding a few commands, or does it need more than that?

I think it can only be done by using Object Bullets?
Check out the awesome tutorial by Naut and Iryan : http://www.shrinemaiden.org/forum/index.php?topic=865.0

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #276 on: July 13, 2009, 02:09:44 PM »
If you created a task which shoots one bouncing laser,
Inside the task:
let notyetbounced = true;
if(notyetbounced)
{*insert whatever bounce codes*
notyetbounced = false;}

Made 0 sense.

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #277 on: July 13, 2009, 03:28:29 PM »
If you created a task which shoots one bouncing laser,
Inside the task:
let notyetbounced = true;
if(notyetbounced)
{*insert whatever bounce codes*
notyetbounced = false;}

Made 0 sense.


Errmm...

Well, I suppose those bouncing lasers are Object Lasers, right?
There have to be some kind of condition statement like if(laser touches sides){bounce it}?
If we declare a boolean varible (such as NotYetBounced) = true inside a task (I don't know... I'm assuming each laser is created via a task :x)
and that the laser will only bounce while the boolean is true (that is, something like if((laser touches sides) && (NotYetBounced))
and that NotYetBounced will be assigned as false after the bounce code.
Then after bouncing once, the condition statement will no longer be true, and thus the laser won't bounce the next time it touches the sides.
If you wanted the lasers to bounce twice or more before leaving, you can use something like a counter varible, and add 1 to it each time a laser is bounced, and only carry out the bounce codes when that counter is smaller than a certain number, that is, bounced less than a certain amount of times.

I hope I'm understanding what you want and you're understanding what I'm saying. :x

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #278 on: July 13, 2009, 05:56:58 PM »
Ah yes it is somehow starting to make sense. It is indeed a Object Laser (normal lasers cannot perform this unless you like want to script 4000 lines for a single bounce)

Anyway there are three tasks on wiki:
Code: [Select]
// Reflection laser
//     x      : x-coordinate
//     y      : y-coordinate
//     v      : velocity
//     angle  : initial direction angle
//     maxLen : max. length
//     width  : width
//     graphic: garphic of bullet
task TReflectionLaser(x, y, v, angle, maxLen, width, graphic) {
    // adjust the angle
    while(angle >= 180) { angle -= 360; }
    while(angle < -180) { angle += 360; }

    // bullet object
    let obj = Obj_Create(OBJ_LASER);

    // initial settings
    Obj_SetPosition   (obj, x, y);
    Obj_SetAngle      (obj, angle);
    ObjLaser_SetWidth (obj, width);
    ObjShot_SetGraphic(obj, graphic);
    ObjLaser_SetSource(obj, false);

    TReflectionLaser_Lengthen(obj, maxLen, v);
    TReflectionLaser_Move    (obj, x, y, v, angle);

    while(! Obj_BeDeleted(obj)) {
        x = Obj_GetX(obj);
        y = Obj_GetY(obj);

        // reflection detection
        if(angle < 0 && y < GetClipMinY) {
            // ceil
            TReflectionLaser(x, y, v, -angle, maxLen, width, graphic);
            break;
        } else if(((-90 < angle && angle < 90) && x > GetClipMaxX) ||
                   ((angle < -90 || 90 < angle) && x < GetClipMinX))
        {
            // wall
            TReflectionLaser(x, y, v, 180 - angle, maxLen, width, graphic);
            break;
        }
        yield;
    }
}

// lengthen the object laser
task TReflectionLaser_Lengthen(obj, maxLen, v) {
    let len = 0;
    let max = floor(maxLen / v);
    let i   = 0;

    while(! Obj_BeDeleted(obj)) {
        // When the length is negative,
        // the laser extends backward.
        ObjLaser_SetLength(obj, -len);
        yield;

        if(i < max) {
            len += v;
            i++;
        } else if(i == max) {
            ObjLaser_SetLength(obj, -maxLen);
            break;
        }
    }
}

// move the object laser
// Since Obj_SetSpeed is ignored in case of object laser,
// the motion needs to be controlled by Obj_SetPosition.
task TReflectionLaser_Move(obj, x, y, v, angle) {
    let vx = v * cos(angle);
    let vy = v * sin(angle);

    while(! Obj_BeDeleted(obj)) {
        Obj_SetPosition(obj, x, y);
        yield;

        x += vx;
        y += vy;
    }
}

So I should add the bounce boolean, as you said, at the reflection detection in the first task?

I added a  let bounce = true;  and  while(! bounce ==false) and concealed it with brackets. Well it works but all the lasers now don't bounce at all. I must add an extra parameter to the Task line so each laser gets tagged with a bounce value =.= But I have no idea how to achieve this as programming at these kind of situations never been my strongest side ( hence why I copypasted this code)
« Last Edit: July 13, 2009, 07:40:22 PM by Helepolis »

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #279 on: July 13, 2009, 07:53:10 PM »
I'd assume it's because you did "while(! bounce == false)"... That's a double-negative, so it's probably returning true from that... After all, if it's false that it's false, it HAS to be true that it's true, right? :/ Either way, I don't see the code you said is in there, so would you please post the WHOLE script, with all your added stuff included? After all, the error could be in another part of your script entirely!

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #280 on: July 13, 2009, 08:15:18 PM »
You don't get it: This is the entire code for the laser. The only extra code I have is a  looping task that summons the laser with the attributes like you summon a Laser01. I am asking where should I add what, such as I have no clue what to do =.=

And (! bounce == false) is the same as (! object_deleted) aka: As long as the bounce is not false -> execute the following script in other words bounce detecting.

Plus I said it works but the lasers don't bounce anymore when one laser hits the wall/ceiling. Because I don't know how to give each laser a bounce attribute. Right now they share the same variabel as it is local inside the task =.=
« Last Edit: July 13, 2009, 08:25:03 PM by Helepolis »

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #281 on: July 13, 2009, 08:47:52 PM »
And (! bounce == false) is the same as (! object_deleted) aka: As long as the bounce is not false -> execute the following script in other words bounce detecting.
Then shouldn't be simpler to do "While (bounce==true)"? After all Booleans can only be True, False or Null.
Or even, if Danmakufu is really as similar as Java as I think, then "while (bounce)" should be enough.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #282 on: July 13, 2009, 09:20:21 PM »
The statement is not the issue =,= the mechanism is.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #283 on: July 13, 2009, 09:35:35 PM »
First off: The statement kinda IS a problem. See, you have both ! and == false. BOTH are checking for false, so logcically, I would assume, it's trying to check for if it's TRUE, not false. You really should only use one check for false and true. (True = "Bounce == true" or just "Bounce"; False = "!Bounce" or "Bounce == false")

Second: Well, there's two ways I could think of that might work the way you want it...


1: Arrays.
2: Make the bounce variable be started as one of the task's variables (like the first one's x, y, etc.), so each task will have its own "Bounce" variable that you can set to be true or false as needed. Considering how your lasers are right now, this would probably be the better method for you.

But I dunno.

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #284 on: July 14, 2009, 01:21:45 AM »
You don't get it: This is the entire code for the laser. The only extra code I have is a  looping task that summons the laser with the attributes like you summon a Laser01. I am asking where should I add what, such as I have no clue what to do =.=

And (! bounce == false) is the same as (! object_deleted) aka: As long as the bounce is not false -> execute the following script in other words bounce detecting.

Plus I said it works but the lasers don't bounce anymore when one laser hits the wall/ceiling. Because I don't know how to give each laser a bounce attribute. Right now they share the same variabel as it is local inside the task =.=

task TReflectionLaser(x, y, v, angle, maxLen, width, graphic) {
    // adjust the angle
    while(angle >= 180) { angle -= 360; }
    while(angle < -180) { angle += 360; }

    let NotYetBounced = true; //The laser had not yet bounced, so it's true.
    // bullet object
    let obj = Obj_Create(OBJ_LASER);

    // initial settings
    Obj_SetPosition   (obj, x, y);
    Obj_SetAngle      (obj, angle);
    ObjLaser_SetWidth (obj, width);
    ObjShot_SetGraphic(obj, graphic);
    ObjLaser_SetSource(obj, false);

    TReflectionLaser_Lengthen(obj, maxLen, v);
    TReflectionLaser_Move    (obj, x, y, v, angle);

    while(! Obj_BeDeleted(obj)) {
        x = Obj_GetX(obj);
        y = Obj_GetY(obj);

        //Now, I bracket up this whole thing with another if condition statement
        //If the laser has yet to bounce, then it has "Not Yet Bounced", the reflection detection will be carried out

        if(NotYetBounced)
        {
        // reflection detection
        if(angle < 0 && y < GetClipMinY) {
            // ceil
            TReflectionLaser(x, y, v, -angle, maxLen, width, graphic);
            NotYetBounced = false;
            break;
        } else if(((-90 < angle && angle < 90) && x > GetClipMaxX) ||
                   ((angle < -90 || 90 < angle) && x < GetClipMinX))
        {
            // wall
            TReflectionLaser(x, y, v, 180 - angle, maxLen, width, graphic);
            NotYetBounced = false;
            //Now here and the ceiling detection above, since this part of the statement inside the if condition statement is only carried out when the laser satisfies the condition, that is, going to bounce, I'm going to change the NotYetBounced boolean to false here, as it's... well... false, since it isn't really Yet to bounce anymore. Since it is false right now, and this Boolean is declared outside the while(!Obj_BeDeleted(obj)) loop, it is only carried out at the BEGINNING of the task, just before the object laser is created, this way, this local boolean of the task will remain to take the value "false". So, since the first reflection detection, the laser will never even get to the reflection detection part, as it is stopped at the if(NotYetBounced).
            break;
        }
        }
        yield;
    }
}

Not using code tags so you can see what I editing more easily.
I'm not sure if this works (didn't test it), but... you get the idea. :P
« Last Edit: July 14, 2009, 01:24:51 AM by Thaws »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #285 on: July 14, 2009, 06:27:55 AM »
I appreciate the help you people give but I have the feeling people do not read it carefully. Or I am extremely bad at explaining.

Pikaguy, logically it makes no sense indeed to use such statements, but like I said the statement is not the issue here.

Thaws, I already tried that and I said that a local var does not work. If I take out the var and place it in @Initialize then it doesn't work either.

Like Pika said in his 2nd point (which I repeated twice), the variabel needs to be a parameter and linked to the object Laser. Though how?!?!?!?
« Last Edit: July 14, 2009, 07:45:47 AM by Helepolis »

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #286 on: July 14, 2009, 07:18:59 AM »
I appreciate the help you people give but I have the feeling people do not read it carefully. Or I am extremely bad at explaining.

Pikaguy, logically it makes no sense indeed to use such statements, but like I said the statement is not the issue here.

Thaws, I already tried that and I said that a local var does not work. If I take out the var and place it in @Initialize then it doesn't work either.

Like Thaws said in his 2nd point (which I repeated twice), the variabel needs to be a parameter and linked to the object Laser. Though how?!?!?!?

I looked at the code mroe closely and realised my mistake :P using a parameter instead shouldn't be too hard though...
I never tried referring a task itself inside the task, but this should work.


//When creating a laser, enter 0 for the parameter of counter.

task TReflectionLaser(x, y, v, angle, maxLen, width, graphic, counter) {
    // adjust the angle
    while(angle >= 180) { angle -= 360; }
    while(angle < -180) { angle += 360; }

    // bullet object
    let obj = Obj_Create(OBJ_LASER);

    // initial settings
    Obj_SetPosition   (obj, x, y);
    Obj_SetAngle      (obj, angle);
    ObjLaser_SetWidth (obj, width);
    ObjShot_SetGraphic(obj, graphic);
    ObjLaser_SetSource(obj, false);

    TReflectionLaser_Lengthen(obj, maxLen, v);
    TReflectionLaser_Move    (obj, x, y, v, angle);

    while(! Obj_BeDeleted(obj)) {
        x = Obj_GetX(obj);
        y = Obj_GetY(obj);

        if(counter < *insert number of time you want it to bounce*)
        {
        // reflection detection
        if(angle < 0 && y < GetClipMinY) {
            // ceil
            TReflectionLaser(x, y, v, -angle, maxLen, width, graphic, counter+1);
            break;
        } else if(((-90 < angle && angle < 90) && x > GetClipMaxX) ||
                   ((angle < -90 || 90 < angle) && x < GetClipMinX))
        {
            // wall
            TReflectionLaser(x, y, v, 180 - angle, maxLen, width, graphic, counter+1);
            break;
        }
        }
        yield;
    }
}
« Last Edit: July 14, 2009, 07:34:30 AM by Thaws »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #287 on: July 14, 2009, 04:02:03 PM »
That worked like a charm Thaws. That was exactly the issue I was looking for. adding the counter+1 behind the paremeters in the detection section.

Now I just need to find out how to make this more beautiful, as the laser that is going to be reflected or leaves the screen suddenly dissapears instead of shrinking.

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #288 on: July 14, 2009, 05:38:06 PM »
Okay, no matter what I do, I can not get circleshots that don't shoot from the same spot to work. I copied the exact examples posted in the tutorials, and I still keep getting error messages. The best thing I got to appear was one single bullet aiming south-east. But any further step I take ends in errors, even if I use the examples shown.

I want to make a circle that appears around the player and then shrinks in on you, so according to the examples I found, my code should look something like this:

Code: [Select]
if(frame==60){
let a   = 0;
let num = 360;
       
loop(num)
{
CreateShot02(GetPlayerX + 100*cos(60), GetPlayerY + 100*sin(60), -1, a+GetAngleToPlayer, 0.02, -3, RED01, 0);
a += 360/num;
}
}

...Except that it doesn't work.

How do I change this to a working shot?
And can someone post an example shot involving sinus and cosinus that will work?


This is the example from the tutorial, which worked for me only once, but after that completely rejects me if I try to use it again:

Code: [Select]
if(frame==120){
   loop(36){
      CreateShot01(GetX + 60*cos(angle), GetY + 60*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
   }
   angle += 4;
   frame = 112;
}
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #289 on: July 14, 2009, 06:45:42 PM »
Make it like this:

if(frame==120){
  let u = 60;
   loop(36){
      CreateShot01(GetPlayerX + u*cos(angle), GetPlayerY + u*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
      u--;
   }
   angle += 4;
   frame = 112;
}

The u = the radius which will shrink because of u--; If you want to make it shrink faster use a higher value like u-=2; etc. If you want to expand the circle use u++;

Just becareful that eachtime the loop is executed the Circle will be spawned on your current position. You can lock the last X and Y position if you put these into a variabel before calling the loop.

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #290 on: July 14, 2009, 06:53:22 PM »
Make it like this:

if(frame==120){
  let u = 60;
   loop(36){
      CreateShot01(GetPlayerX + u*cos(angle), GetPlayerY + u*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
      u--;
   }
   angle += 4;
   frame = 112;
}

The u = the radius which will shrink because of u--; If you want to make it shrink faster use a higher value like u-=2; etc. If you want to expand the circle use u++;

Just becareful that eachtime the loop is executed the Circle will be spawned on your current position. You can lock the last X and Y position if you put these into a variabel before calling the loop.



I just copied the exact code into my main loop, but still:



Can anything besides this piece of the script not want to cooperate with it?

My full file looks like this:

Code: [Select]
#TouhouDanmakufu
#Title[Sinus Cosinus circles]
#Text[Test]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

let frame = 0;
let count=0;
let cx=GetCenterX();
let changing = 0;


    @Initialize {
SetScore(30000);
SetLife(300);
SetDamageRate(10,10);
SetTimer(60);

SetGraphicRect(1,1,64,64);
SetInvincibility(30);

SetMovePosition02(cx,224,240);
Concentration01(150);
CutIn(YOUMU,"Test "\""Test"\", 0,0,0,0,0);

   }

    @MainLoop {

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

frame++;


if(frame==120){
  let u = 60;
   loop(36){
      CreateShot01(GetPlayerX + u*cos(angle), GetPlayerY + u*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
      u--;
   }
   angle += 4;
   frame = 112;
}



    }

    @DrawLoop {       
    }

    @Finalize {
    }
}
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #291 on: July 14, 2009, 07:01:12 PM »
Maybe writing an actual angle would work better than using (angle).
Because you know, that's a placeholder.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #292 on: July 14, 2009, 07:05:50 PM »
That or he forgot to declare it. Declare: let angle = 0; in your script and it is done.

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #293 on: July 14, 2009, 07:13:33 PM »
That almost did it.

It doesn't error now, although it doesn't work as I hoped. The player is not surrounded by a circle, but something that looks more like a shell. The circle doesn't form a complete loop.

Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #294 on: July 14, 2009, 07:42:57 PM »
I really can't help you right now because I don't know what the hell you want to do.

MSPaint drawing, stat.

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

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #295 on: July 14, 2009, 07:46:59 PM »
I want to make a circle that appears around the player and then shrinks in on you

So, like...



..this, because I'm a sadist.
Right now it forms anything besides a nice circle.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #296 on: July 14, 2009, 07:52:50 PM »
Try this:

Code: [Select]
ang=rand(0, 360);
ascent(i in 0..n){
   CreateShotA(1, GetPlayerX+r*cos(ang+360*i/n), GetPlayerY+r*sin(ang+360*i/n), 10);
   SetShotDataA(1, 0, 0, ang+360*i/n + 180, 0, 0.05, 2, BLUE11);
   FireShot(1);
}

n = number of bullets
r = radius of the circle

The variable "ang" has to be created in the beginning of the script, of course. It exists solely to randomize the alignment of the ring a little.
« Last Edit: July 14, 2009, 07:55:42 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."

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #297 on: July 14, 2009, 08:12:38 PM »
Try this:

Code: [Select]
ang=rand(0, 360);
ascent(i in 0..n){
   CreateShotA(1, GetPlayerX+r*cos(ang+360*i/n), GetPlayerY+r*sin(ang+360*i/n), 10);
   SetShotDataA(1, 0, 0, ang+360*i/n + 180, 0, 0.05, 2, BLUE11);
   FireShot(1);
}

n = number of bullets
r = radius of the circle

The variable "ang" has to be created in the beginning of the script, of course. It exists solely to randomize the alignment of the ring a little.


It still errors. *cries*
Can somebody put down the code of a complete file, instead of just a part, and confirm the techniques which work best?
With just these small bits and pieces it's easy to make mistakes or to oversee things that other people do in a different way.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #298 on: July 14, 2009, 08:25:26 PM »
D'oh!

You refer to a variable of the name "angle" in your script, but you don't have created a variable of that name with the command "let angle=0;".

Also, your code cannot create a circle as you have the variable "u" which regulates the radius decrease with every spawned bullet, causing the pattern to look like a spiral.

If I go into your code and fix it, it looks something like this:

Code: [Select]
#TouhouDanmakufu
#Title[Sinus Cosinus circles]
#Text[Test]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

   let frame = 0;
   let angle = rand(0, 360);
   let count=0;
   let cx=GetCenterX();
   let changing = 0;
   let u = 60;


    @Initialize {
      SetScore(30000);
      SetLife(300);
      SetDamageRate(10,10);
      SetTimer(60);

      SetGraphicRect(1,1,64,64);
      SetInvincibility(30);

      SetMovePosition02(cx,224,240);
      Concentration01(150);
      CutIn(YOUMU,"Test "\""Test"\", 0,0,0,0,0);

   }
   
    @MainLoop {

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

frame++;


if(frame==120){
   loop(36){
      CreateShot01(GetPlayerX + u*cos(angle), GetPlayerY + u*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
   }
   angle += 4;
   frame = 112;
}



    }

    @DrawLoop {       
    }

    @Finalize {
    }
}

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."

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #299 on: July 14, 2009, 08:36:14 PM »
D'oh!

You refer to a variable of the name "angle" in your script, but you don't have created a variable of that name with the command "let angle=0;".

Also, your code cannot create a circle as you have the variable "u" which regulates the radius decrease with every spawned bullet, causing the pattern to look like a spiral.

If I go into your code and fix it, it looks something like this:

Code: [Select]
#TouhouDanmakufu
#Title[Sinus Cosinus circles]
#Text[Test]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

   let frame = 0;
   let angle = rand(0, 360);
   let count=0;
   let cx=GetCenterX();
   let changing = 0;
   let u = 60;


    @Initialize {
      SetScore(30000);
      SetLife(300);
      SetDamageRate(10,10);
      SetTimer(60);

      SetGraphicRect(1,1,64,64);
      SetInvincibility(30);

      SetMovePosition02(cx,224,240);
      Concentration01(150);
      CutIn(YOUMU,"Test "\""Test"\", 0,0,0,0,0);

   }
   
    @MainLoop {

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

frame++;


if(frame==120){
   loop(36){
      CreateShot01(GetPlayerX + u*cos(angle), GetPlayerY + u*sin(angle), 3, angle, BLUE12, 12);
      angle += 360/36;
   }
   angle += 4;
   frame = 112;
}



    }

    @DrawLoop {       
    }

    @Finalize {
    }
}



The angle variable was a remainder of an old script, but I forgot to remove it ^^;

Ah, but it actually works now! I should be able to change this into a CreateShot2 so it can accelerate and do more mean tricks. Or lasers... *drool*
I'm so glad these sinus/cosinus circles work. *cries Mannosuke tears*
Those two together with tangens have always hated me, during math classes too. But those classes were nothing compared to Danmakufu ^^;
Thanks a bunch, now I can sleep without fear again! ;D
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html