Author Topic: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)  (Read 267175 times)

Zoriri

  • Danmaku Trainee
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #990 on: June 05, 2013, 11:46:59 PM »
Sorry for already asking another question, but now I'm having trouble with movment.

I'm using SetMovePositionRandom01 to move my boss, but it isn't moving from the X an Y coordinates i used.
Code: [Select]
SetMovePositionRandom01(20, 20, 2, 50, 50, 50, 50);
Also, what are the dimension of the playing field in Danmakufu?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #991 on: June 06, 2013, 12:41:51 AM »
Sorry for already asking another question, but now I'm having trouble with movment.

I'm using SetMovePositionRandom01 to move my boss, but it isn't moving from the X an Y coordinates i used.
Code: [Select]
SetMovePositionRandom01(20, 20, 2, 50, 50, 50, 50);
Also, what are the dimension of the playing field in Danmakufu?
SetMovePositionRandom01(X-distance, Y-distance, speed, left boundary, top boundary, right boundary, bottom boundary)

Well... first off, your boundary #s are the same. Basically, you're allowing the boss to move within one point. Use the following data to help yourself.

Code: [Select]
DNH

MinX: 0
MaxX: 448
GetCenterX: 224
GetClipMinX: 32
GetClipMaxX: 416

MinY: 0
MaxY: 480
GetCenterY: 240
GetClipMinY: 16
GetClipMaxY: 464

MinX/MaxX/etc. are not functions, by the way. GetCLipMin/MaxX/Y state the boundaries of the playing field (i.e. where the player can move). The boss and bullets can move out of this range.
« Last Edit: June 06, 2013, 12:43:48 AM by Sparen »

Zoriri

  • Danmaku Trainee
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #992 on: June 06, 2013, 01:18:10 AM »
SetMovePositionRandom01(X-distance, Y-distance, speed, left boundary, top boundary, right boundary, bottom boundary)

Well... first off, your boundary #s are the same. Basically, you're allowing the boss to move within one point. Use the following data to help yourself.

Code: [Select]
DNH

MinX: 0
MaxX: 448
GetCenterX: 224
GetClipMinX: 32
GetClipMaxX: 416

MinY: 0
MaxY: 480
GetCenterY: 240
GetClipMinY: 16
GetClipMaxY: 464

MinX/MaxX/etc. are not functions, by the way. GetCLipMin/MaxX/Y state the boundaries of the playing field (i.e. where the player can move). The boss and bullets can move out of this range.

Ah, that... kinda helps.(In all honesty I have no idea how to use the info you gave me). What i was trying to do was have the boss move randomly in only the upper half of the screen.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #993 on: June 06, 2013, 02:04:23 AM »
SetMovePosition01(rand(GetClipMinX, GetClipMaxX), rand(GetClipMinY, GetCenterY), 2);

That's all. But remember: The boss will move to the walls, and players hate it when bosses suddenly move to the other side of the screen. I suggest limiting the xcor values to rand(GetCenterX-80,GetCenterX+80) or something around that.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #994 on: June 06, 2013, 07:44:09 AM »
Actually Sparen, you're making two mistakes here. First: Rand is a floating number. Or in simple terms it will randomize a number between 32 and 416, including all decimals. So the boss can decide to move 32,00400000 and 300,4395000. Which might sometimes look very bad.

Second mistake, related to the first, is the movement distance. Random is random, but there is no guarantee the random will be always a greater number than the previous which might result in the boss not moving at all. We definitely do not want this. So how?

@ Zoriri & Sparen
SetMovePositionRandom01 is your friend here. It comes with a secure random movement ability. This function creates a bounding box where the boss will move inside. It will never leave the boundaries. The wiki isn't really clear about this function so I'll explain it here.
Code: [Select]
1) x-distance the static distance the boss will move on the X
2) y-distance the static distance the boss will move on the Y
3) velocity speed at the boss moves
4) left bound
5) top bound
6) right bound
7) bottom bound

SetMovePositionRandom01( 60, 60, 2, GetClipMinX, GetClipMinY, GetClipMaxX, GetCenterY );
This will move the boss randomly inside the "boundary box" defined by you at exactly 60 pixels on the X and Y coordinates. But there are some faults to this, since the boss can clip outside the field making him half off the screen which looks ugly. Additionally we don't want too much static 60 movement, but perhaps variation between 60-100 for the X and 30-60 for the Y to increase dynamics. Now we are allowed to apply Sparen's previous suggestion, but with a different rand function: rand_int. Rand_int randomizes the number you give it, but rounds it up/down into an integer.
Code: [Select]
SetMovePositionRandom01( rand_int(60,100), rand_int(30,60), 2, GetClipMinX+16, GetClipMinY+16, GetClipMaxX-16, GetCenterY );
Since GetClipMinY = 0 (top side of the field) you want to add 16 to not make the boss headless (Unless she is Sekibanki). Same goes for the ClipMinX and MaxX, to avoid the boss half off the screen add or subtract to "decrease the boundary" of the field.

To finish up, an awesome MS Paint to show what is going on.
« Last Edit: June 06, 2013, 07:53:53 AM by Helepolis »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #995 on: June 06, 2013, 12:59:12 PM »
Yes, setmovepositionrandom is alot better, but I always used move position with randomized coordinates, specifically to get the weight effect of SetMovePosition3 which I always preferred. I realize this is a dumb solution and I could probably get a better one by using randomized variables with control functions. (?)
Code: [Select]
function SetMovePositionRandom03(X-distance, Y-distance, weight, maxspeed, left bound, top bound, right bound, bottom bound){
let setrand = rand(0,360);
let Xdir = GetX+cos(setrand)*(X-distance);
let Ydir = GetY+sin(setrand)*(Y-distance);

if(Xdir>right bound){Xdir = right bound;}
if(Xdir<left bound){Xdir = left bound;}
if(Ydir>bottom bound){Ydir = bottom bound;}
if(Ydir<top bound){Ydir = top bound;}

SetMovePosition03(Xdir, Ydir, weight, maxspeed);}
Would something like this work in that case?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #996 on: June 06, 2013, 02:34:25 PM »
You're using rand as well for randomizing the degree for trigonometry. Your results could be 4.00000 4.149300 (ry. Might want to rand_int that? Well unless you want a floating variable, fine with me.

As far as I can look at your code, you're using trigonometry to define a location at the edge of virtual circle which is the bounding field? Except for that you need to use GetX+X-distance*cos(setrand) (or does your example works as well? I guess it works both day I could be wrong as well?)

However, I don't see how setrand is going to exceed the boundaries of the playfield when it is 448 and 480 at max. This would probably work out if you make the radius of the virtual circle smaller.

I am not quite sure (needs confirming) but your code is wrong? Drake? Someone?

Zoriri

  • Danmaku Trainee
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #997 on: June 06, 2013, 03:08:19 PM »
Ok, i got the boss to move, but it moves so fast that it looks more like it's having a seizure than firing danmaku. How could i have it pause for a couple of seconds before it moves again?

The code is pretty much the same thing Helepolis had.
Code: [Select]
SetMovePositionRandom01(rand_int(60,100), rand_int(30,60), 2, GetClipMinX+16, GetClipMinY+16, GetClipMaxX-16, GetCenterY);
« Last Edit: June 06, 2013, 03:16:55 PM by Zoriri »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #998 on: June 06, 2013, 04:12:14 PM »
Ok, i got the boss to move, but it moves so fast that it looks more like it's having a seizure than firing danmaku. How could i have it pause for a couple of seconds before it moves again?
Assuming you're using the function wait here. If not:
Code: [Select]
function wait(t){loop(t){yield;}}(In case you're also using tasks.)

If you want it to move, pause for a moment and then move again, this code should work fine:
Code: [Select]
//after the movement code
while(GetSpeed>0){yield;}
wait(120); //pauses for 2 seconds before moving again.
//resumes the loop

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #999 on: June 06, 2013, 04:24:00 PM »
Remember Zoriri that you dont need to stick to the rand_int numbers we gave you. Try to fiddle around to see how far/close you want to move the boss and apply some personal changes. You'll understand things better that way.

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1000 on: June 06, 2013, 05:34:54 PM »
Could someone help me with modifying this code?
Code: [Select]
   
      task QED(x, y, speed, angle, graphic, delay, num, Bombres) {
      let obj=Obj_Create(OBJ_SHOT);
      let bouncecount = num;
      Obj_SetPosition(obj, x, y);
      Obj_SetAngle(obj, angle);
      Obj_SetSpeed(obj, speed);
      ObjShot_SetGraphic(obj, graphic);
      ObjShot_SetDelay(obj, 0);
      ObjShot_SetBombResist (obj, Bombres);
      while(Obj_BeDeleted(obj)==false && bouncecount > 0) {
        if(Obj_GetX(obj)<GetClipMinX) {
          Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) );
          Obj_SetX(obj,  Obj_GetX(obj) + 0.1);
          bouncecount -= 1;
        }
        if(Obj_GetX(obj)>GetClipMaxX) {
          Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) );
          Obj_SetX(obj,  Obj_GetX(obj) - 0.1);
          bouncecount -= 1;
        }
        if(Obj_GetY(obj)<GetClipMinY) {
          //Obj_SetAngle(obj, Obj_GetAngle(obj) + (2 * (180 - Obj_GetAngle(obj))) ); //Original NetLogo code
          Obj_SetAngle(obj, -1*Obj_GetAngle(obj)); //Equally correct code for Danmakufu
          Obj_SetY(obj,  Obj_GetY(obj) + 0.1);
          bouncecount -= 1;
        }
        yield;
      }
    }

I'm trying to make an edit to this code with causes reflection to allow it to double the reflected bullets in an exponential way (1, 2, 4, 8, 16, ...) and reflect up to 10x (512 bullets I think) and then dissapear if they hit the walls again

And happy reply 1000 (me)
« Last Edit: June 06, 2013, 05:51:12 PM by K+ ~ Bake-Danuki »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1001 on: June 06, 2013, 05:49:52 PM »
I hope you're realising that nothing is being doubled or multiplied here. The object behaviour code makes it reflect/bounce of the field and that is it.

If you want to multiply the bullets, you need to summon the bullets inside the bounce detection code. You can do this two ways, since I am not quite sure about the "disappear" you mention.
1) Summon more bullets upon reflection by simple using CreateShot or CreateShotA and delete the original obj bullet.
2) Script a secondary object bullet with no reflection code but disappearing effect (if that is what you seek)

Code: [Select]
if(Obj_GetX(obj)<GetClipMinX) {
ascent(i in 0..4) { CreateShot or NewObjBulletWithDissapearingEffect...... }
Obj_Delete(obj);
}

Decide which one works better for you. No idea how exactly you plan on reflecting or which direction and which speeds, but I assume you know that already.
« Last Edit: June 06, 2013, 05:51:25 PM by Helepolis »

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1002 on: June 06, 2013, 05:55:49 PM »
I actually am a noob at this stuff.
The way I was going to see about making them disappear is like normal bullets, where they just drift outside of the boundary of the HUD.
And I was hoping like if a bullet goes and hits a wall at 90 degrees, it would reflect at 45 and 135 degrees causing a split and probably the default velocity.
And I have honestly no idea which on of those I would use.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1003 on: June 06, 2013, 05:59:45 PM »
Ah I see. In that case things change.

Have you ever scripted Object bullets from scratch? Such as understand how they are build up and what they are capable of? If not, I would first read upon the tutorials about them. Otherwise you're just going to copy/paste code and try to spaghetti-code it.

It won't take you long to grasp, within several minutes most likely. From there on you can mutate/modify the script yourself to your desired. But start out with some tutorials please.

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1004 on: June 06, 2013, 06:02:49 PM »
Oh, sorry.  I'll go read up on these and learn.
Although, I have figured out like how to make a circle of bullets but that's about it.  I haven't been using tutorials, just a template plus source material from scripts to make my own ones.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1005 on: June 06, 2013, 06:20:59 PM »
While that method works, I would however heavily encourage to learn. Mainly as eventually, somewhere you're not going to be able to get those desired ideas from your mind onto your notepad/script and enjoy the results if you don't know how to transfer them. (Like right now).

So if my response to your initial question is already a question mark, it means you're not ready for Object bullets yet. Go and read/watch tutorials.

(This suddenly sounds like some movie dialogue :V) ((Though seriously, so many resources available to learn))


Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 6 ※ for OLD Danmakufu version (0.12m)
« Reply #1006 on: June 07, 2013, 01:07:48 AM »
[The 7th thread has been started by Drake.]