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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #630 on: November 27, 2011, 01:53:22 PM »
Code: [Select]
task fire{
   while(something){
      loop(5){
         CreateShot01(GetX,GetY,rand(1,3),rand_int(0,360),RED03,0);
         yield;
      }
      wait(60);
   yield;
   }
}

The yield in the loop will add a one frame delay in between each shot, so if the bullets are to be fired at the same time, there shouldn't be a yield there. Also, there is no need to use rand_int when randomizing angles as danmakufu allows non integers for angles.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #631 on: November 27, 2011, 02:12:46 PM »
The yield in the loop will add a one frame delay in between each shot, so if the bullets are to be fired at the same time, there shouldn't be a yield there.
Does it mean that without yield loop will take all the time needed for it to perform? What about another tasks and if loop(1000) or something?

Also, there is no need to use rand_int when randomizing angles as danmakufu allows non integers for angles.
That's just the demonstration of the functions. While rand_int is enough for angle cause of high range of random interval, using it for speed will give exactly 1, 2 or 3 instead of any real value between them like with rand, wich can be used to control patterns.
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #632 on: November 27, 2011, 02:27:00 PM »
Greetings everyone! So I started playing around with danmakufu yesterday and I find it really enjoyable. As I progress though a few questions come up :(
For starters, where can I get the sound effect files for the bullets?

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #633 on: November 27, 2011, 03:59:12 PM »
Well, there aren't any sound effects for the bullets, actually! If you wanna go get some of the sounds from the official Touhou games, head over here and download some of the sound rips.
Hell, you can use any freaking sound you want for firing bullets, even the sound of some random dude burping if you want.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #634 on: November 27, 2011, 04:24:37 PM »
Lol! yeah that's what I actually wanted, thank you mate ;)

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #635 on: November 27, 2011, 04:32:29 PM »
Does it mean that without yield loop will take all the time needed for it to perform? What about another tasks and if loop(1000) or something?

If there is no yield in the loop then the loop will run within a single frame, so:

Code: [Select]
loop(100){
     do something;
}

takes 1 frame to perform and does whatever you want 100 times within that frame, while

Code: [Select]
loop(100){
     do something;
     yield;
}

does the same thing but takes 100 frames instead

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #636 on: November 27, 2011, 04:54:17 PM »
takes 1 frame to perform and does whatever you want 100 times within that frame, while
Yeah but if only it can fit a single frame. I always yield all loops and whiles but here it makes sence cause the time to perform such a fast loop is insignificant.
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #637 on: November 27, 2011, 05:20:05 PM »
Yeah but if only it can fit a single frame. I always yield all loops and whiles but here it makes sence cause the time to perform such a fast loop is insignificant.

Code: [Select]
loop(1024){
     CreateShot01(GetX, GetY, rand(1, 3), rand_int(0, 360), RED01, 0);
}

This code will create 1024 shots in a single frame without problems, but if you had put a yield there then it would take about 15 seconds to spawn them all. So you should only put yields in a loop if you want that delay.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #638 on: November 27, 2011, 06:01:59 PM »
Heeeelz yeah! I've managed my enemies to drop power items via common data exchange! 8) That was not so difficult. Here's some code if anyone's interested in...

In stage script:
Code: [Select]
.  .  .

//organising queue from enemies for power items to drop
CreateCommonDataArea("poweritems");
SetCommonData("firstpower",0);
SetCommonData("lastpower",0);
let firstpower=0;
let lastpower=0;
let powerdata=[0,0,0];

.  .  .

@MainLoop{
firstpower=GetCommonData("firstpower");
lastpower=GetCommonData("lastpower");
if(firstpower>lastpower){
firstpower=0;
SetCommonData("lastpower",0);
ClearCommonDataEx("poweritems");
}
if(firstpower>0){
powerdata[0]=GetCommonDataEx("poweritems",firstpower)[0];
powerdata[1]=GetCommonDataEx("poweritems",firstpower)[1];
powerdata[2]=GetCommonDataEx("poweritems",firstpower)[2];
loop(powerdata[2]){
CreatePowerItem(powerdata[0]+rand_int(-10,10),powerdata[1]+rand_int(-10,10),1);
yield;
}
firstpower++;
}
SetCommonData("firstpower",firstpower);
yield;
}

In enemy script:
Code: [Select]
.  .  .

let lastpower=GetCommonData("lastpower"); //retreiving number of last power item in queue

.  .  .

lastpower=GetCommonData("lastpower");
lastpower++;
SetCommonData("lastpower",lastpower);
if(lastpower==1){SetCommonData("firstpower",1);}
SetCommonDataEx("poweritems",lastpower,[GetX,GetY,power]); //sending information about power to drop into queue

Also, as i remind from my previous questions in this thread, this is the way to override default enemy explosions and make own ones.
« Last Edit: November 27, 2011, 06:51:16 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


AJS

  • Danmakufu Scripter
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #639 on: November 27, 2011, 07:15:37 PM »
Thanks MMX!  Now, another question for anyone who's willing to answer.  I don't know how to work with backgrounds other than creating a still image.  How can I make the multi-layered moving backgrounds that are prevalent in more recent Touhou games?  (i.e. the spinning radiation symbol in Utsuho's background, and the infinitely-moving space background behind it)

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #640 on: November 27, 2011, 08:10:21 PM »
Thanks MMX!  Now, another question for anyone who's willing to answer.  I don't know how to work with backgrounds other than creating a still image.  How can I make the multi-layered moving backgrounds that are prevalent in more recent Touhou games?  (i.e. the spinning radiation symbol in Utsuho's background, and the infinitely-moving space background behind it)
Just the same way as with static backgrounds. Load all textures you want to use as background layers and draw them one after another in @Background section with all movement, spinning commands. Be sure they have proper alpha channels and stuff to be drawn one above each other. I've made my first 2-layer BG recently
Code: [Select]
@BackGround {
SetGraphicScale(1,1);
SetTexture(starbg);
SetGraphicRect(0,0,600,1200); // set twice (or more) the width (length) of image so it'll get automatically tiled
DrawGraphic(GetCenterX,GetCenterY+bgshift-300); // draw bottom layer with moving starfield texture
bgshift+=4;
if(bgshift>=600){bgshift=0;}

SetTexture(bg);
SetGraphicRect(0,0,384,448);
DrawGraphic(GetCenterX,GetCenterY); // draw top layer with static texture with alpha "holes" to see a layer under it
}

You can see how it works in a boss script i made for my project http://www.shrinemaiden.org/forum/index.php/topic,11416.0.html


And i've got another question myself: How to draw stuff outside the game field? like show power level'n'stuff under lives and bombs. I found it's needed to call in mainloop, but it works weird.
« Last Edit: November 27, 2011, 08:49:53 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #641 on: November 29, 2011, 04:32:34 PM »
Is it possible to fade in and fade out effect objects? Obj_SetAlpha doesn't seem to work on them.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #642 on: November 29, 2011, 06:36:47 PM »
This code will create 1024 shots in a single frame without problems, but if you had put a yield there then it would take about 15 seconds to spawn them all. So you should only put yields in a loop if you want that delay.
it'll lag like fuck

And i've got another question myself: How to draw stuff outside the game field? like show power level'n'stuff under lives and bombs. I found it's needed to call in mainloop, but it works weird.
ObjEffect_SetLayer(obj,8);

Is it possible to fade in and fade out effect objects? Obj_SetAlpha doesn't seem to work on them.
for(i in 0..vertexnum){ ObjEffect_SetVertexColor(obj,i,alpha,red,green,blue); }

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

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #643 on: November 29, 2011, 10:46:25 PM »
for(i in 0..vertexnum){ ObjEffect_SetVertexColor(obj,i,alpha,red,green,blue); }

lol for
He means ascent.
<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.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #644 on: November 30, 2011, 12:33:19 AM »
goddamn it

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

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #645 on: November 30, 2011, 05:54:01 AM »
ObjEffect_SetLayer(obj,8);
Oh tanx i'll try it. But how can i place a DrawText output there? Via SetRenderTarget?
for(i in 0..vertexnum){ ObjEffect_SetVertexColor(obj,i,alpha,red,green,blue); }
you meant ascent, right?

Also i'm constantly experiencing troubles with measuring distance between two points using Pythagoras' theorem. If only i put something like (x2-x1)^2+(y2-y1)^2 it makes danmakufu halt and crash instantly on stage start (even before any actuall call of that calculations). That makes me use such a perversions like
Code: [Select]
ang=atan2(y2-y1,x2-x1);
dist=(|(x2-x1)/cos(ang)|);
And it works like a charm! Even when cos is about to be zero lol. Good thing i need an angle too so it's not such a waste but seriously. Is it a known unsolved problem, or am i doing it wrong?
« Last Edit: November 30, 2011, 03:46:07 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #646 on: November 30, 2011, 06:33:53 PM »
you meant ascent, right?
lol for
He means ascent.

Quote
Also i'm constantly experiencing troubles with measuring distance between two points using Pythagoras' theorem. If only i put something like (x2-x1)^2+(y2-y1)^2 it makes danmakufu halt and crash instantly on stage start (even before any actuall call of that calculations). That makes me use such a perversions like
Code: [Select]
ang=atan2(y2-y1,x2-x1);
dist=(|(x2-x1)/cos(ang)|);
And it works like a charm! Even when cos is about to be zero lol. Good thing i need an angle too so it's not such a waste but seriously. Is it a known unsolved problem, or am i doing it wrong?
That does not make any sense. If it crashes before even getting to that code, it can't possibly be that code's fault. That's an interesting alternate way to get distance, though I'm curious what happens when cos(ang) is 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.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #647 on: November 30, 2011, 11:22:51 PM »
Well, if you want to be really weird like that you can apply the tangent half-angle and do something incredibly stupid like

ang = atan2(y2-y1,x2-x1)
d = ( (x2-x1)^2 + (y2-y1)^2 )^0.5

tan(ang/2) = (1 - cos(ang)) / sin(ang)

ang = atan2(y2-y1,x2-x1) = 2 * atan( (d - (x2-x1)) / (y2-y1) )

d = (y2-y1) * tan( atan2(y2-y1,x2-x1) / 2 ) + (x2-x1)


But the problem is definitely with your other code, not the math code itself. (Speaking of which someone double-check my math I haven't done calc in ages)

However, d = (|(x2-x1)/cos(ang)|) doesn't make much sense. ang is (basically) the angle of o2 to o1 so cos(ang) is essentially just the +- x-distance between them, i.e. x2-x1. d looks like it should always return 1.

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

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #648 on: December 01, 2011, 01:42:24 AM »
Even though it's completely pointless to improve on this method of getting distance, here's a function to get distance without the Pythagorean theorem.

Code: [Select]
function GetDistance(x1, y1, x2, y2){
    let angle = atan2(y2-y1, x2-x1);
    if(absolute(sin(angle)) > absolute(cos(angle))){
        return absolute((y2-y1)/sin(ang));
    }
    else {
        return absolute((x2-x1)/cos(ang));
    }
}

Checking if sin or cos is larger because we don't want to divide by zero. Or even anything close to zero because of float precision.
« Last Edit: December 01, 2011, 01:43:55 AM by Blargel »
<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.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #649 on: December 01, 2011, 01:16:03 PM »
However, d = (|(x2-x1)/cos(ang)|) doesn't make much sense. ang is (basically) the angle of o2 to o1 so cos(ang) is essentially just the +- x-distance between them, i.e. x2-x1. d looks like it should always return 1.
Wat? Remember definition of cosine? http://en.wikipedia.org/wiki/Trigonometric_functions#Right-angled_triangle_definitions If we have a vector x1y1 to x2y2 then we have some angle between this vector and x axis. cosine of that angle is adjacent / hypotenuse where adjacent=x2-x1 an hypotenuse is our distance.

And my function magically works in all conditions even when cos is about to be zero. I dunno what happens there. This language continues to confuse me.
« Last Edit: December 01, 2011, 01:18:52 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #650 on: December 01, 2011, 03:27:02 PM »
Found this in the Useful Miscellaneous Code Snippets thread:

Code: [Select]
function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
}

Haven't tested if it works yet but it's worth a try.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #651 on: December 01, 2011, 03:42:58 PM »
Found this in the Useful Miscellaneous Code Snippets thread:

Code: [Select]
function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
}

Haven't tested if it works yet but it's worth a try.

Yes, that's the Pythagorean Theorem. We were trying to do it without that for stupid reasons.
<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.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #652 on: December 01, 2011, 05:31:51 PM »
Code: [Select]
function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
}
This DOESNT work in my scripts no matter of code it serves, or is it called as a separate function or not. And i think there's not a "problem of code" cause those weird trigonometric distance metering method works just fine. It looks just as kind of a curse or something :colonveeplusalpha:
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Yukari-Chan

  • Excuse me while I prepare /your/ demise. <3 TSO
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #653 on: December 02, 2011, 02:15:46 AM »
I've been wondering. Should I replace the len_05 and genmu ExRumia for something more hard and a different boss. I don't know. I am currently translating Phantasm Romance but... I think I'll improve the old danmakufu ( Like anyone uses it or cares about the old engine anyway ).
" Borders are Borders. They were meant to be manipulated and mistreated. "

Trickysticks

  • What am I? TRICKYSTEAKS I AM!
  • A stick of the tricky variety.
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #654 on: December 02, 2011, 02:40:44 AM »
( Like anyone uses it or cares about the old engine anyway ).

Plenty of people use 0.12m. Anyway, if you want to modify Ex-Rumia, go ahead. If you're just making another Rumia, then great. I hope you add sounds.

You should totally make a script/mod topic, and post all of your stuff there so it's easier for people to find  :derp:.


Interested in playing some boss fights I made? Have Danmakufu? Then check out my Danmakufu creations!

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #655 on: December 02, 2011, 02:41:25 AM »
Don't.

It's supposed to be there as an example for people who want to learn Danmakufu's scripting language by looking at actual code.

The better ExRumia scripts
Spoiler:
(and I don't mean the ones by the idiot beginners who can't do shit in Danmakufu
are more complicated and shouldn't be used as examples for learning Danmakufu off of.
« Last Edit: December 02, 2011, 02:48:34 AM by alt-kyuu-kyuu »

NonexistentFlower

  • 悪ノ花(君)
  • Oh... And... I'm a boy.
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #656 on: December 02, 2011, 08:33:53 AM »
My friend (Who hasn't an account here) wishes to ask why this fires no bullets, even with a time++; in the main loop.

http://pastebin.com/uHdMkWki

Thanks.
......I said nothing.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #657 on: December 02, 2011, 10:50:02 AM »
My friend (Who hasn't an account here) wishes to ask why this fires no bullets, even with a time++; in the main loop.

http://pastebin.com/uHdMkWki

Thanks.

It might be because of using the shot1 variable as id and not simply a number, but I'm not really sure.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #658 on: December 02, 2011, 11:18:15 AM »
It might be because of using the shot1 variable as id and not simply a number, but I'm not really sure.
Whynot? But could it be zero? :wat:

Ah! It doesnt fire because of double SetShotDataA before Fireshot. I've encountered the same mistake.

Also what means graphic id 87? Did he loaded it as user shot data?



Also i've got a question: I wanna make a spellcard for my player character wich is based on it's regular shot. Is there a way to make same task avaliable for both player and spell scripts?
« Last Edit: December 02, 2011, 12:10:54 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Yukari-Chan

  • Excuse me while I prepare /your/ demise. <3 TSO
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #659 on: December 02, 2011, 12:28:52 PM »
Don't.

It's supposed to be there as an example for people who want to learn Danmakufu's scripting language by looking at actual code.

The better ExRumia scripts
Spoiler:
(and I don't mean the ones by the idiot beginners who can't do shit in Danmakufu
are more complicated and shouldn't be used as examples for learning Danmakufu off of.
  I mean change the bullets to more beautiful bullets. I'll keep a spare copy for myself but, I just wanna change those shitty bullets(Or change the boss to Flandre or Sanae )
" Borders are Borders. They were meant to be manipulated and mistreated. "