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

Serina

  • Evening Star
  • I like Danmakufu
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #240 on: June 09, 2011, 06:53:54 PM »
Thank you very much, guys! That's great, I'm trying to use tasks too, but at least I'm sure I can do cool stuff with MainLoop :3

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #241 on: June 09, 2011, 07:45:39 PM »
Hardly doubt it. Look at the code. It has a loop { } in there, it seems to loop forever as a checker. Thus, he needs dual statements

It loops forever, but it never resets any of the variables back to false after turning them true so actually, after everything is set to true, it no longer even needs to run. Thus, why I suggested my solution. It also saves a few CPU clock cycles per frame by only checking one condition per frame instead of all 3. :V
<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: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #242 on: June 10, 2011, 02:09:49 AM »
Back again! :P

I'm wondering if there is a good way to have stuff happen when bullets of different types intersect (without predetermining locations where this will happen). Here's a pseudo-code attempt at it, but I imagine there's a better way to go about it than this:

function GetDistance(x1,x2,y1,y2) {return distance}

mainloop{
ascent(i in a..b){
     CreateShotA(i, 'parameters for A-type bullet')
     CreateShotA(-i, 'parameters for B-type bullet')
}
a = b+1
b = 2b-a+1
ascent(g in 1..b)
   ascent(h in 1..b)
      if (GetDistance of shot g and -h < 'too close') {
          do stuff;
      }
   }
}

Particularly since this doesn't stop checking bullets even when they don't exist anymore, and the number of calcs is on the order of b^2, I'd guess that this would cause noticeable slowdown once b gets high enough.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #243 on: June 10, 2011, 02:14:59 AM »
you'll have to use object bullets and their Obj_GetX and Obj_GetY functions (or alternately, use Obj_Obj_Collision)... so I suggest you get more familiar with objects first, before you attempt this... :3
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #244 on: June 10, 2011, 02:38:00 AM »
You're thinking along the right lines, but you have no way of determining a bullet's position without using object bullets (go learn object bullets lol). Aside from that you're pretty much right. The best method is probably storing the objects in two global arrays for A bullets and B bullets (if your intention is to have something done when A and B collide).

let position_A = [];
let position_B = [];

//code

task objbulletA{    //similar for B, obviously
    position_A = position_A ~ [Obj_Create(OBJ_SHOT)];    //creates an object and concats into array
    let id = length(position_A) - 1;    //to track id in array if needed

    //code
}

And then you run distance checks between each A bullet to B bullet.

I guess you clean up garbage entries if the bullets are deleted but that might be a tad advanced lol. There are actually a lot of optimizations you can do with things like this but that isn't really an issue either.
« Last Edit: June 10, 2011, 02:39:54 AM by Drake »

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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #245 on: June 10, 2011, 02:39:45 AM »
I am actually familiar with object shots, and in my scripts tasks and object shots are my preferred way of creating bullets. The reason I didn't use a similar style here was because I was worried about how to call on individual shots outside of the task in which they were created (I actually just realized how to do this though - in the past I either passed nothing or shot data into the task to create an object shot named 'obj', but if I pass an object name variable down I should be able call individual shots from anywhere in the program).

I wasn't aware of an Obj_Obj_Collision function - how does this one work, or is it something I have to write?

Even using object shots, I'm not sure how to avoid having to test every bullet against every other in every frame to get my intended result.

Edit (after seeing previous post): Oh I see, haha. I'm so used to object shots I assumed I could use GetX on any bullets I spawned. ^^'
Hmm, that many calcs every frame won't slow the program down?
« Last Edit: June 10, 2011, 02:41:55 AM by BajaBlood »

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #246 on: June 10, 2011, 02:53:36 AM »
Well if the detection radius is large enough you can stand to only calculate distances once every two frames, or you can divide the work up 50/50, stuff like that.


Are you talking garbage collection?

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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #247 on: June 10, 2011, 03:17:21 AM »
Didn't know what garbage collection is - now know about what 3 minutes on wikipedia tells me. xD

I guess garbage collection isn't really my concern, though if I end up having problems with slowdown on the card I'll look into it (and actually it would probably be an interesting problem to think about as well even if it isn't necessary in this case - half the reason I'm doing danmakufu is to improve my programming skills).

I don't really have a concept for what the card will look like, but one of the things I'm planning on doing when I start mixing elements in my extra boss is having 'water' and 'fire' bullets either annihilate each other or spawn some bullets in an explosion when they meet (same with 'earth' and 'air').

Yeah, I'm sure I'd be able to check for collisions less frequently than every frame - I generally stay away from pellets and high speeds, so any overlaps should last a number of frames.

J.O.B

  • YOU CAN'T MAKE ME CHANGE
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #248 on: June 10, 2011, 05:50:21 AM »
Is someone able to make a tutorial about the nitpicky fussy things in Danmakufu?
Things such as where certain functions/tasks/variables go.
When you should put curly braces and parenthesis.
And other things like that fact that task names can't have spaces in them.
If someone were to make a tutorial for those things then it'll be greatly appreciated.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #249 on: June 10, 2011, 06:05:58 AM »
Is someone able to make a tutorial about the nitpicky fussy things in Danmakufu?
http://www.shrinemaiden.org/forum/index.php/topic,4155.0.html
http://www.shrinemaiden.org/forum/index.php/topic,4762.0.html
http://www.shrinemaiden.org/forum/index.php/topic,4752.0.html


Things such as where certain functions/tasks/variables go.
When you should put curly braces and parenthesis.
And other things like that fact that task names can't have spaces in them.
If someone were to make a tutorial for those things then it'll be greatly appreciated.
Uhhhhhh no. Basic syntax should be very easy to follow, and at the very least you'll learn what not to do yourself as you script and read other tutorials. These are not "nitpicky", it's being not lazy with your punctuation, grammar, etc. Nobody should have to make a tutorial going MAKE SURE YOU MATCH UP YOUR CURLY BRACKETS!!!!!1

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

J.O.B

  • YOU CAN'T MAKE ME CHANGE
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #250 on: June 10, 2011, 06:48:00 AM »
I'm sorry then if I find that most times examples aren't enough.
Sometimes the worfing is confusing for me and I end up putting things in the wrong place.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #251 on: June 10, 2011, 07:25:50 AM »
It'll fix itself as you get more experienced and such.

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

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #252 on: June 10, 2011, 06:34:22 PM »
Two Questions: 

1.- CreateLaserB has  lengthening speed which allows the lenght of the laser to extend in "n" each frames, but what do I do if I want to change the width of the laser?

2.- Can somebody explain me how ascent/descent works in an example script? the FAQ example isn't that useful.

EDITED: Changed "CreateShotB" with "CreateLaserB"
« Last Edit: June 10, 2011, 06:51:17 PM by Teff007 »
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #253 on: June 10, 2011, 06:37:56 PM »
Two Questions: 

1.- CreateShotB has  lengthening speed which allows the lenght of the laser to extend in "n" each frames, but what do I do if I want to change the width of the laser?

CreateShotB doesn't exist.
if you mean CreateLaserB, then it doesn't work that way - you have to use object lasers and ObjLaser_SetWidth(objectid, widthinpixels);

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #254 on: June 10, 2011, 08:08:24 PM »
2.- Can somebody explain me how ascent/descent works in an example script? the FAQ example isn't that useful.

Code: [Select]
ascent(i in 0..20){
    CreateShot01(GetX, GetY, 3, i*18, RED01, 5);
}

is the same as

Code: [Select]
let i = 0;
while(i < 20){
    CreateShot01(GetX, GetY, 3, i*18, RED01, 5);
    i++;
}

except that in the ascent example, the variable i no longer exists after the ascent is over, but will still exist in the while example. In both cases, it's just a type of loop with a variable called i that starts at 0 and counts up by one until it reaches 20. Note that i will never actually be used when it hits 20 in the while loop. The same is true for ascents so it'll count from 0 to 19, not 0 to 20.

Descent makes i, go through the same numbers but in reverse order, so in the previous example, if we replaced ascent with descent, it'll count backwards from 19 to 0.
<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.

rogus247

  • Rogus is serious...
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #255 on: June 11, 2011, 03:34:37 AM »
Ok, im gonna make this one a quickie. I know the command to stop obj,bullets and hold them in place. How would i spawn like...3 bullets from that one bullet? And say if i wanted to stop THOSE bullets and make more? Would that be a Spawn command?
"Think you got what it takes to beat me? Ive blown up universes before, so what makes you think you got a chance?" -Rogus

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #256 on: June 11, 2011, 03:46:37 AM »
That's possible with CreateShotA, but it seems you wanna use object bullets.

You'd have to make a totally new object bullet, spawned by the first object bullet.

That's all I can give - the rest anyone can figure out.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #257 on: June 11, 2011, 03:58:55 AM »
Ok, im gonna make this one a quickie. I know the command to stop obj,bullets and hold them in place. How would i spawn like...3 bullets from that one bullet? And say if i wanted to stop THOSE bullets and make more? Would that be a Spawn command?
task bullet(x,y,a){
    //code
    Obj_SetPosition(obj,x,y);
    Obj_SetAngle(obj,a);
    //code
    //slow down/stop
    bullet(Obj_GetX(obj),Obj_GetY(obj), a+something);
    bullet(Obj_GetX(obj),Obj_GetY(obj), a+somethingelse);
    bullet(Obj_GetX(obj),Obj_GetY(obj), a+somethingelseelse);
    //probably Obj_Delete(obj); unless you want to do something else with the stopped bullet
}

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

rogus247

  • Rogus is serious...
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #258 on: June 11, 2011, 04:50:01 AM »
http://pastebin.com/rsTUMkH0

Im...doing something wrong here...xD
Do you have to set the variables next to the bullet task?
"Think you got what it takes to beat me? Ive blown up universes before, so what makes you think you got a chance?" -Rogus

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #259 on: June 11, 2011, 05:51:55 AM »
Code: [Select]
task bullet(x,y,a){
        //code
        Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
        Obj_SetAngle(obj,dir);
        //code
        //slow down/stop
        bullet(Obj_GetX(obj),Obj_GetY(obj), a+3);
        bullet(Obj_GetX(obj),Obj_GetY(obj), a+6);
        bullet(Obj_GetX(obj),Obj_GetY(obj), a+9);
        //probably Obj_Delete(obj); unless you want to do something else with the stopped bullet
        }

is this seriously what's in your code? the thing drake posted was just a general outline :V you have to fix it and make it fit whatever you want it to do...

EDIT: Given what you have in your pastebin
Code: [Select]
bullet(GetEnemyX,GetEnemyY,1,dir,ORANGE32,0);
I'm guessing you'll want something like this:
Code: [Select]
task bullet(x,y,v,a,g,d){
    let counter=0;
    let obj=Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj,x,y);
    Obj_SetAngle(obj,dir);
    Obj_SetSpeed(obj,v);
    ObjShot_SetGraphic(obj,g);
    ObjShot_SetDelay(obj,d);
    while(!Obj_BeDeleted(obj){
        counter++;
        if(counter==*insert whatever value you want*){Obj_SetSpeed(obj,0);}
        if(counter==*insert whatever other value you want*){
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+3,ORANGE32,0); //Change values to whatever you want
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+6,ORANGE32,0);
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+9,ORANGE32,0);
            Obj_Delete(obj);
        }
    }
}
« Last Edit: June 11, 2011, 05:59:35 AM by Kylesky »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #260 on: June 11, 2011, 06:17:35 AM »
why

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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #261 on: June 11, 2011, 06:40:01 PM »
Two questions:

1.) In one of my scripts I'm looking to use a couple global shot id's on object shots, as I need to compare their location to other object shots created by a different task. These shots are being created by a task called in MainLoop.

Is there a good way to pass a variable down to this task such that I don't need to break the task by cases? i.e. can I pass a variable to the task that lets me reference one of two shot id's

2.) With Object Shots not moving straight up or down, is there a simple way to apply a constant downward acceleration, or will I need to write some trigonometric functions to adjust the angle and speed based on the current angle and speed?
(answered on IRC - thanks Ginko)

« Last Edit: June 11, 2011, 07:09:17 PM by BajaBlood »

rogus247

  • Rogus is serious...
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #262 on: June 11, 2011, 10:29:44 PM »
http://pastebin.com/LWq0bZSn

yeah...i got the same error with the whole (wait) thing again....i think i should get some new eyes, cause i sure as hell cant! DX I should get a professional pro to come over to my house, and just...give me a 20 hour lecture on danmakufu.....

But yeah, all variables are set, but like most my problems, the thing comes up by the wait command, so...what has rogus done wrong this time? xD
"Think you got what it takes to beat me? Ive blown up universes before, so what makes you think you got a chance?" -Rogus

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #263 on: June 11, 2011, 10:41:05 PM »
I actually read over this a few times too. Didn't catch it for a while.

while(!Obj_BeDeleted(obj)){

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

rogus247

  • Rogus is serious...
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #264 on: June 11, 2011, 11:09:37 PM »
that solved the (wait problem...) but now i get a (dir) problem...i need to set it to 0, right?
"Think you got what it takes to beat me? Ive blown up universes before, so what makes you think you got a chance?" -Rogus

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #265 on: June 11, 2011, 11:18:55 PM »
Code: [Select]
task bullet(x,y,v,a,g,d){
    let counter=0;
    let obj=Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
    Obj_SetAngle(obj,dir);
    Obj_SetSpeed(obj,3);
    ObjShot_SetGraphic(obj,ORANGE32);
    ObjShot_SetDelay(obj,20);
    while(!Obj_BeDeleted(obj){
        counter++;
        if(counter==2){Obj_SetSpeed(obj,0);}
        if(counter==4){
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+3,ORANGE32,0); //Change values to whatever you want
            bullet(Obj_GetX(obj),Obj_GetY(obj),2,a+6,ORANGE32,0);
            bullet(Obj_GetX(obj),Obj_GetY(obj),3,a+9,ORANGE32,0);
            Obj_Delete(obj);
        }
    }
}       

Two things :

-  'dir' doesn't even exist, how exactly did you expect the script to work ? You have to initialize if you want to use a string as a variable. Then again, if you want the angle to be 0, why exactly don't you just put 0 ?
- What are those x,y,v,g and d arguments doing in your task ? They don't intervene anywhere ... it will work correctly but that's just pointless :O
« Last Edit: June 11, 2011, 11:21:39 PM by Ginko »

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #266 on: June 11, 2011, 11:27:16 PM »
He wants the x and y, only his initial call is supposed to spawn on the enemy. In which case,

bullet(GetEnemyX,GetEnemyY,1,anactualnumber,ORANGE32,0);

//...

task bullet(x,y,v,a,g,d){
    let counter=0;
    let obj=Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj,x,y);
    Obj_SetAngle(obj,a);
    Obj_SetSpeed(obj,3);
    ObjShot_SetGraphic(obj,ORANGE32);
    ObjShot_SetDelay(obj,20);
    while(!Obj_BeDeleted(obj){
        counter++;
        if(counter==2){Obj_SetSpeed(obj,0);}
        if(counter==4){
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+3,ORANGE32,0); //Change values to whatever you want
            bullet(Obj_GetX(obj),Obj_GetY(obj),2,a+6,ORANGE32,0);
            bullet(Obj_GetX(obj),Obj_GetY(obj),3,a+9,ORANGE32,0);
            Obj_Delete(obj);
        }
    }

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

rogus247

  • Rogus is serious...
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #267 on: June 12, 2011, 12:34:51 AM »
http://pastebin.com/2a6nqdjb

ok...it would work, but it freezes my Comp. I have yields in all places...but it still freezes. Why?
"Think you got what it takes to beat me? Ive blown up universes before, so what makes you think you got a chance?" -Rogus

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #268 on: June 12, 2011, 12:50:43 AM »
task bullet(x,y,v,a,g,d){
    let counter=0;
    let obj=Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
    Obj_SetAngle(obj,a);
    Obj_SetSpeed(obj,3);
    ObjShot_SetGraphic(obj,ORANGE32);
    ObjShot_SetDelay(obj,20);
    while(!Obj_BeDeleted(obj)){
        counter++;
        if(counter==2){Obj_SetSpeed(obj,0);}
        if(counter==4){
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+3,ORANGE32,0); //Change values to whatever you want
            bullet(Obj_GetX(obj),Obj_GetY(obj),2,a+6,ORANGE32,0);
            bullet(Obj_GetX(obj),Obj_GetY(obj),3,a+9,ORANGE32,0);
            Obj_Delete(obj);
      yield;
        }
    }
}   

change to

task bullet(x,y,v,a,g,d){
    let counter=0;
    let obj=Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
    Obj_SetAngle(obj,a);
    Obj_SetSpeed(obj,3);
    ObjShot_SetGraphic(obj,ORANGE32);
    ObjShot_SetDelay(obj,20);
    while(!Obj_BeDeleted(obj)){
        counter++;
        if(counter==2){Obj_SetSpeed(obj,0);}
        if(counter==4){
            bullet(Obj_GetX(obj),Obj_GetY(obj),1,a+3,ORANGE32,0); //Change values to whatever you want
            bullet(Obj_GetX(obj),Obj_GetY(obj),2,a+6,ORANGE32,0);
            bullet(Obj_GetX(obj),Obj_GetY(obj),3,a+9,ORANGE32,0);
            Obj_Delete(obj);
        }
   yield;
    }
}   

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #269 on: June 12, 2011, 12:55:10 AM »
In addition, even once that's fixed: Every bullet waits 4 frames, then creates 3 new bullets. Each of those waits 4 frames, then creates 3 new bullets. Each of those waits 4 frames, then creates 3 new bullets. Do you see the problem here? You need to have some limit on how many times they can split. Give the bullet task another parameter called "maxsplit" or something, and every time you create a child bullet, create it with maxsplit-1 instead. If it's zero, don't create any more bullets, so your processor will stop screaming.