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

Kitsumi

  • Danmakufu Noob
Re: Danmakufu Q&A/Problem Thread II
« Reply #720 on: December 25, 2009, 01:02:08 AM »
Merged into the Q&A thread. I don't want to delete things, others might have your same questions.

Thanks.  :V

As far as I remember, Danmakufu takes most common image types including JPGs and GIFs. PNGs are preferred, however, as they aren't prone to artifacting and support semi-transparency. BMPs are a big no-no as they are huge in file size and create large downloads if you want to share the script. Although JPGs tend to have artifacts, they could be used if you don't need transparency and the quality of the texture doesn't matter for the purpose you are using it for. I haven't tried GIFs in Danmakufu, but judging from how it treats the other formats, I'd assume that you could use them instead of PNGs if you don't need partial transparency.

In short, PNGs are superior. Just use them.

So PNGs are top-tier, got it.
I was planning on making my own boss image, but I need to get scripts and everything done first. I also started making plurals (maybe familiars soon), so I'm well on my way.  :V (but not really...)

Btw, CreateLaserA acts really weird(spawning all over the place and rotating like crazy)...Is it really much better to use than CreateLaser01?


« Last Edit: December 25, 2009, 01:06:04 AM by Kitsumi »

Re: Danmakufu Q&A/Problem Thread II
« Reply #721 on: December 25, 2009, 01:08:58 AM »
Btw, CreateLaserA acts really weird(spawning all over the place and rotating like crazy)...Is it really much better to use than CreateLaser01?
With CreateLaser01 everything is predetermined, fire here, at this width/length, etc.

With CreateLaserAs you can Make them shrink,grow,move,rotate, Fire more bullets, etc...
« Last Edit: December 25, 2009, 06:38:58 AM by Demonbman »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #722 on: December 25, 2009, 08:34:00 AM »
Btw, CreateLaserA acts really weird(spawning all over the place and rotating like crazy)...Is it really much better to use than CreateLaser01?

You probably messed up your parameters for SetLaserDataA. Make sure you know what parameter does what. From the wiki:

7 Parameters
    1) ID
    2) time to modify the motion
    3) angle
    4) angular velocity
    5) variation of the laser length
    6) magnitude of velocity
    7) direction of velocity

KrackoCloud

  • I don't mean to be greedy...
  • ... but white rice is my favorite food.
Re: Danmakufu Q&A/Problem Thread II
« Reply #723 on: December 25, 2009, 07:59:19 PM »
Could someone explain object intersections?
Well, that is, assuming that I already have the right idea for it.
Like, what would I do if I wanted to have a bullet change colors when it passes a laser, for instance?

Re: Danmakufu Q&A/Problem Thread II
« Reply #724 on: December 25, 2009, 08:11:14 PM »
Could someone explain object intersections?
Well, that is, assuming that I already have the right idea for it.
Like, what would I do if I wanted to have a bullet change colors when it passes a laser, for instance?

You need to make arrays of all your objects, and test if they are colliding every frame. Once they are colliding, use a counter to make sure that the next frame the action isn't performed again (for example, if you were reflecting bullets, sometimes the bullet will collide two frames in a row, and screw up the reflection).

Something like this, where you put every object bullet or laser inside an array (array = array ~ [obj]; )...



Obj_SetCollisionToObject(obj, true);

while(!Obj_BeDeleted(obj)){

   ascent(j in 0..(length(array) - 1)){
      if(Collision_Obj_Obj(obj, array[j])==true && counter==0){
         ObjShot_SetGraphic(obj, RED02);
         counter++;
      }
   }

yield;
}

It's a big pain in the ass if you're new to arrays/object bullets.
« Last Edit: December 26, 2009, 02:04:02 AM by Naut »

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread II
« Reply #725 on: December 26, 2009, 01:57:58 AM »
How do I cut the last place off of an array? For example, to turn [0, 1, 2, 3] into [0, 1, 2]?

I have tried using the respective command from the wiki
   erase(array, length(array)-1);
but when I tell danmakufu to give me the length of the array afterwards, it says that it didn't actually decrease.


Is danmakufu being a jerk or am I just an idiot?
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."

Re: Danmakufu Q&A/Problem Thread II
« Reply #726 on: December 26, 2009, 02:01:32 AM »
How do I cut the last place off of an array? For example, to turn [0, 1, 2, 3] into [0, 1, 2]?

I use array = erase(array, length(array)-1);

erase(array, index); just gives you the array with the indexed place removed. I don't actually think it edits the array, it just returns what it would be if you removed that place.
« Last Edit: December 26, 2009, 02:03:42 AM by Naut »

Re: Danmakufu Q&A/Problem Thread II
« Reply #727 on: December 26, 2009, 03:42:40 AM »
Ok, when experimenting with players, I stumbled upon a problem,My bomb wont show up, http://pastebin.com/m7013265a This is the player code, The bomb doesnt want to show up.... help!
« Last Edit: December 26, 2009, 05:01:29 AM by Demonbman »

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread II
« Reply #728 on: December 26, 2009, 02:04:17 PM »
Ok, when experimenting with players, I stumbled upon a problem,My bomb wont show up, http://pastebin.com/m7013265a This is the player code, The bomb doesnt want to show up.... help!

Code: [Select]
                ObjEffect_SetVertexXY(obj,0,GetPlayerX-40,GetPlayerY+40);
                ObjEffect_SetVertexXY(obj,1,GetPlayerX+40,GetPlayerY+40);
                ObjEffect_SetVertexXY(obj,2,GetPlayerX-40,GetPlayerY-40);
                ObjEffect_SetVertexXY(obj,3,GetPlayerX+40,GetPlayerY-40);
 
                ObjEffect_SetVertexUV(obj,0,0,0);
                ObjEffect_SetVertexUV(obj,1,0,256);
                ObjEffect_SetVertexUV(obj,2,256,256);
                ObjEffect_SetVertexUV(obj,3,256,0);

                ObjSpell_SetIntersecrionLine(obj,GetPlayerX+40,GetCenterY+40,GetPlayerX-40,GetPlayerY-40,200,0,true);}

This should be in while(Obj_BeDeleted(obj)==false) { } brackets. With a yield;, of course.



Also, muchas gracias Naut. The wiki truly is a mess.  :V
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."

Re: Danmakufu Q&A/Problem Thread II
« Reply #729 on: December 27, 2009, 12:30:03 AM »
Also, muchas gracias Naut. The wiki truly is a mess.  :V

'Tis why we're building another, good sir :V

Re: Danmakufu Q&A/Problem Thread II
« Reply #730 on: December 27, 2009, 09:10:43 PM »
hurp derp I fail at event script

Code: [Select]
script_event name{

  let reimu = GetCurrentScriptDirectory ~ "img\cutins\reimu.png";
  let chen2 = GetCurrentScriptDirectory ~ "img\cutins\chen.png";

@Initialize{
  LoadGraphic(reimu);
  LoadGraphic(chen2);
 }

@MainLoop{
 SetChar(LEFT, reimu);                  //Set the player's character on the left side, with the graphic you've told it to display.
 SetGraphicRect(LEFT, 0, 0, 500, 590);           //The region you're displaying of the graphic for the player character, just like SetGraphicRect.
 MoveChar(LEFT, BACK);                             //Move the player's character into the background, to show she is not speaking.
 SetChar(RIGHT, chen2);                //Set the boss' picture on the right side of the screen.
 SetGraphicRect(RIGHT, 0, 0, 125, 512);           //Set the boundry of the picture you want displayed.
 MoveChar(RIGHT, FRONT);                          //Move the boss' image to the front to show that she is speaking.
 TextOutA("The text you want the character to speak goes here");           //Self explanatory. Danmakufu will not pass this function until a certain amount of time has passed, or the player clicks the shot button.
 MoveChar(RIGHT, BACK);                           //Move the boss to the background, then...
 MoveChar(LEFT, FRONT);                           //Move the player forward, to show that she will now speak.
 TextOutA("More words here");                     //What the player will be speaking.
 End;            //This ends the event.
 }

@Finalize{
 }

}

raymoo and Chen are both on the right ;_;

hurp derp derp nevermind
« Last Edit: December 27, 2009, 09:16:02 PM by Kinoko Nasuma »

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #731 on: December 28, 2009, 12:28:05 AM »
WUT how could they BOTH be on the right. :/

Re: Danmakufu Q&A/Problem Thread II
« Reply #732 on: December 28, 2009, 12:42:51 AM »
His image had a large blank spot on the left.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #733 on: December 29, 2009, 01:10:13 AM »
I want my object to have a kind of life, similar to the SetLife function for enemy scripts, that when hits zero, disappears. I also want a collision circle similar to SetCollisionA and SetCollisionB, that dissappears a player's shot it you shoot at it.
Can anyone help me with this?

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread II
« Reply #734 on: December 29, 2009, 01:20:44 AM »
I want my object to have a kind of life, similar to the SetLife function for enemy scripts, that when hits zero, disappears. I also want a collision circle similar to SetCollisionA and SetCollisionB, that dissappears a player's shot it you shoot at it.
Can anyone help me with this?

Is there any reason you can't use a regular (not boss) enemy script for this?  That sounds like what you really want, honestly.
to quote Naut:
"I can see the background, there are too many safespots."
:V

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #735 on: December 29, 2009, 01:22:08 AM »
Unless you want to do messy complicated collision detection between the player script and the enemy script via common data, I suggest making a familiar or enemy instead of an object for that. What specifically are you trying to accomplish with that kind of object anyway?
<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.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #736 on: December 29, 2009, 01:45:45 AM »
I'll put it in a nutshell. The enemy isn't a boss enemy, it's a child enemy in the stage - many of them spawn at once.
The enemy spawns familiars (the objects), that move around and follow the child enemy. When the child enemy's life hits zero, the familiars dissappear with it.
It's easy enough with just what I have, but I don't know anything to make it have a collisioncircle for the familiars. I could make the actual familiars child enemies themselves and tried that, but when the child enemy that spawns them dies, they don't die and an error comes up. The error is because there are no coordinates for its familiars to follow, where as when they're object effects, they simply disappear with the boss (which is what I want).
« Last Edit: December 29, 2009, 01:47:25 AM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread II
« Reply #737 on: December 29, 2009, 02:27:01 AM »
I find this hilarious because I made an enemy that does that very thing last night.

Alright, I made all my familiars child enemies. At the beginning of the parent enemy, I declare a random number:

let r = rand(0, 100);

This will be the name of the random CommonData we will set. We're setting the name of the CommonData as a random number so that if you plan on spawning more than one of these enemies, they won't use the same coordinates.

In the @MainLoop of the main parent enemy, we'll be setting his coordinates into the CommonData. We'll use a small array so we don't have to set two different CommonDatas.

SetCommonData(ToString(r), [GetX, GetY]);

The name of CommonData has to be a string, so we'll just quickly convert it using ToString.

Now, when we go to spawn a child enemy, how will it know what CommonData to get? We'll use it's argument to pass along the value.

CreateEnemyFromScript("familiar", GetX, GetY, 0, 0, r);

Now the familiar script knows the name of the correct CommonData to get (and not some other enemy's). Getting it is simple, to get the X coordinate, just type:

GetCommonData(ToString(GetArgument))[ 0 ];

Our first element in the CommonData array is the x coordinate of the parent enemy, so we need to get that using [ 0 ]. The y coordinate would be exactly the same, except with [ 1 ], since we're getting the second element in the array. So you're position code would look something like:

SetX(GetCommonDataDefault(ToString(GetArgument), [-9999, -9999])[ 0 ] + 50*cos(angle));
SetY(GetCommonDataDefault(ToString(GetArgument), [-9999, -9999])[ 1 ] + 50*sin(angle));


This would make the familiars rotate around the parent enemy, 50 pixels away. Well, as long as you increase angle, and set it every @MainLoop. The reason why we use GetCommonDataDefault is so that when the parent enemy gets deleted (along with all the CommonData), the child familiars will be thrown off into oblivion instantly, killing them along with the main parent.

Here's the enemy script that I wrote up last night. Note that I'm already transferring a difficulty setting through my argument parameter, so I actually use the angle parameter to transfer the CommonData name.

Code: [Select]
script_enemy_main{

#include_function "script\script_enemy\enemymisc\EnemyControl.txt"
let r = rand(0, 100);
let a = rand(0, 360);

task Attack(Difficulty){
loop(10){yield;}
if(Difficulty==1){
loop(10){
CreateEnemyFromScript("swarm", GetX, GetY, 0, r, Difficulty);
loop(10){yield;}
}
}
if(Difficulty==2){
loop(15){
CreateEnemyFromScript("swarm", GetX, GetY, 0, r, Difficulty);
loop(7){yield;}
}
}
if(Difficulty==3){
loop(20){
CreateEnemyFromScript("swarm", GetX, GetY, 0, r, Difficulty);
loop(5){yield;}
}
}
if(Difficulty==4){
loop(20){
CreateEnemyFromScript("swarm", GetX, GetY, 0, r, Difficulty);
loop(5){yield;}
}
}
loop(150){yield;}
if(GetX<224){
SetMovePosition02(500, GetY, 240);
}
if(GetX>=224){
SetMovePosition02(-50, GetY, 240);
}
}


task Attack2(Difficulty){
if(Difficulty==1){
}
if(Difficulty==2){
loop(50){
CreateShotA(0, GetX + 50*cos(a) + rand(-5, 5), GetY + 50*sin(a) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 1.8, BLUE12);
FireShot(0);
CreateShotA(0, GetX + 50*cos(a + 2) + rand(-5, 5), GetY + 50*sin(a + 2) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 1.8, BLUE12);
FireShot(0);
a+=12;
loop(5){yield;}
}
}
if(Difficulty==3){
loop(70){
CreateShotA(0, GetX + 50*cos(a) + rand(-5, 5), GetY + 50*sin(a) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 2, BLUE12);
FireShot(0);
CreateShotA(0, GetX + 50*cos(a + 2) + rand(-5, 5), GetY + 50*sin(a + 2) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 2, BLUE12);
FireShot(0);
a+=10;
loop(4){yield;}
}
}
if(Difficulty==4){
loop(140){
CreateShotA(0, GetX + 50*cos(a) + rand(-5, 5), GetY + 50*sin(a) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 2.5, BLUE12);
FireShot(0);
CreateShotA(0, GetX + 50*cos(a + 2) + rand(-5, 5), GetY + 50*sin(a + 2) + rand(-5, 5), 10);
SetShotDataA(0, 0, 7, a + rand_int(-20, 20), 0, -0.5, 2.5, BLUE12);
FireShot(0);
a+=5;
loop(2){yield;}
}
}
}

@Initialize{
SetInvincibility(10);
SetMovePosition03(GetX, 150, 10, 3);
SetLife(130);
Attack(GetArgument);
Attack2(GetArgument);

}

@MainLoop{
DeathCheck;
SetCommonData(ToString(r), [GetX, GetY]); //Set coordinates for the familiar to get.
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 4);
yield;
}

@DrawLoop{
DrawBigEnemy;
}

@Finalize{
DeadEnemy(GetX, GetY, 5, 0, 5, 50);  //x, y, points, power, IE, dispersion radius.
}
}

script_enemy swarm{

#include_function "script\script_enemy\enemymisc\EnemyControl.txt"
let a = rand(0, 360);
let radius = 0;
let xvar = rand(0, 90);
let yvar = rand(0, 90);
let maxrad = rand_int(50, 100);
let Difficulty = GetArgument;
let frames = rand_int(2, 30);
let gg = GetAngle;

task Attack{
if(Difficulty==1){
loop(frames){yield;}
loop{
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran + 1, RED12, 0);
loop(80){yield;}
}
}
if(Difficulty==2){
loop(frames){yield;}
loop{
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran + 1, RED12, 0);
loop(60){yield;}
}
}
if(Difficulty==3){
loop(frames){yield;}
loop{
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran + 1, RED12, 0);
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2, GetAngleToPlayer + ran + 1, RED12, 0);
loop(50){yield;}
}
}
if(Difficulty==4){
loop(frames){yield;}
loop{
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran + 1, RED12, 0);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran - 1, RED12, 0);
let ran = rand(-90, 90);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran, RED12, 0);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran + 1, RED12, 0);
CreateShot01(GetX, GetY, 2.2, GetAngleToPlayer + ran - 1, RED12, 0);
loop(40){yield;}
}
}
}

@Initialize{
SetLife(10);
SetDamageRateEx(100, 100, 10, 10);
Attack;
}

@MainLoop{
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 4);
DeathCheck;
SetX(GetCommonDataDefault(ToString(gg), [-2000, -2000])[0] + radius*cos(a + xvar));
SetY(GetCommonDataDefault(ToString(gg), [-2000, -2000])[1] + radius*sin(a + yvar));
if(radius<maxrad){
radius++;
}
a+=3;
yield;
}

@DrawLoop{
DrawSmallGreenEnemy;
}

@Finalize{
DeadEnemy(GetX, GetY, 1, 0, 0, 10);  //x, y, points, power, IE, dispersion radius.
}
}

God I hope I explained this clearly :<

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #738 on: December 29, 2009, 04:02:05 AM »
If I want to draw 2 variables and 2 strings using DrawText, can I do it without using 4 DrawTexts ??? cause it makes danmakufu lag a lot...

I currently have this (I'm making the history thing for my game)

caprate=ToString(GetCommonData("GAME_ST1_CAP_B1E"));
seerate=ToString(GetCommonData("GAME_ST1_SEE_B1E"));

DrawText("history", GetClipMinX+10, GetClipMinY+100, 12, 255);
DrawText(caprate, GetClipMinX+60, GetClipMinY+100, 12, 255);
DrawText("/", GetClipMinX+135, GetClipMinY+100, 12, 255);
DrawText(seerate, GetClipMinX+145, GetClipMinY+100, 12, 255);

The coordinates are still a bit messy... I'll fix them later...

I've tried
DrawText("history" caprate "/" seerate, GetClipMinX+10, GetClipMinY+100, 12, 255);
but that just horribly failed...
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Re: Danmakufu Q&A/Problem Thread II
« Reply #739 on: December 29, 2009, 04:04:41 AM »
Ahh, you were close.

DrawText("History: " ~ caprate ~ "/" ~ seerate, GetClipMinX+10, GetClipMinY+100, 12, 255);

Use tilde to combine strings.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #740 on: December 29, 2009, 04:13:07 AM »
Ahh, you were close.

DrawText("History: " ~ caprate ~ "/" ~ seerate, GetClipMinX+10, GetClipMinY+100, 12, 255);

Use tilde to combine strings.

Ohhh... thanks!!! ;D
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

KrackoCloud

  • I don't mean to be greedy...
  • ... but white rice is my favorite food.
Re: Danmakufu Q&A/Problem Thread II
« Reply #741 on: December 29, 2009, 04:15:08 AM »
You need to make arrays of all your objects, and test if they are colliding every frame. Once they are colliding, use a counter to make sure that the next frame the action isn't performed again (for example, if you were reflecting bullets, sometimes the bullet will collide two frames in a row, and screw up the reflection).

Something like this, where you put every object bullet or laser inside an array (array = array ~ [obj]; )...

*code*


Oh dear. You were right - This is pretty bad.
Alright, so here's a sample code.

Code: [Select]
#TouhouDanmakufu
#Title[Spell Template]
#Text[Description]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
///
#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
///
let sprite = "script\img\ExRumia.png";
let Cutin = "";

let fr1 = 0;
let fr2 = 0;

let ang = 0;

let array = [];

//////////
@Initialize{
shotinit;
        LoadGraphic(sprite);
        SetLife(5000);
        SetDamageRate(100, 100);
        SetTimer(50);
        SetInvincibility(30);
        CutIn(YOUMU, "X Sign "\""X"\", Cutin, 0, 0, 0, 0);
        SetScore(500000);
        SetEnemyMarker(true);
        Concentration01(60);
        MagicCircle(true);
        SetEffectForZeroLife(180, 100, 1);
SetMovePosition02(GetCenterX, GetCenterY - 100, 30);
}
//////////

@MainLoop{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
fr1++;
fr2++;
if(fr1==30){
laser;
}
if(fr2==30){
shot;
fr2 = 0;
}
yield;
}
//////////
@DrawLoop{
SetColor(255,255,255);
SetRenderState(ALPHA);
SetTexture(sprite);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);
}
@Finalize{
DeleteGraphic(sprite);
}
//////////

task shot{
let counter = 0;

let o1 = Obj_Create(OBJ_SHOT);

  Obj_SetPosition (o1, GetX, GetY);
  Obj_SetAngle (o1, GetAngleToPlayer);
  Obj_SetSpeed (o1, 1);
  ObjShot_SetGraphic (o1, RED01);
  ObjShot_SetDelay (o1, 5);

  ObjShot_SetBombResist (o1, false);
  Obj_SetCollisionToObject (o1, true);

while(!Obj_BeDeleted(o1) ){

ascent(j in 0..(length (array) -1) ){
if(Collision_Obj_Obj (o1, array[j])==true && counter==0){
ObjShot_SetGraphic(o1, BLUE01);
counter++;
}
}

yield;
}

array = array ~ [o1];
}

/////

task laser{

let o2 = Obj_Create(OBJ_LASER);

  Obj_SetPosition (o2, GetClipMinX, GetCenterY);
  Obj_SetAngle (o2, 0);
  Obj_SetSpeed (o2, 3);
  ObjShot_SetGraphic (o2, RED01);
  ObjShot_SetDelay (o2, 10);
  ObjLaser_SetLength (o2, 400);
  ObjLaser_SetWidth (o2, 30);

  Obj_SetCollisionToObject (o2, true);

array = array ~ [o2];
}

/////
}

The problem with this thing is, if you run it, you have to wait, like, maybe 20ish seconds before the color-changes-when-passing-laser kicks in.
I can make it start up faster by increasing the bullet's speed, but that's obviously not a good solution.

The original idea was for something similar to work with sinuates. Unfortunately, no matter how long one waits, it never works with them, whereas you just gotta wait a while before it works for the screen-long laser.

I should probably make a task to erase bullets from the array when they're deleted, but save that for another time. I'm pretty sure that has nothing to do with the problem.

Man. Arrays are the worst. (So far. I'm sure there'll be harder things for me in the future.)

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #742 on: December 29, 2009, 06:12:39 AM »
Took a quick look, but didn't copypaste and test the script. I spotted a few errors that might be causing the delay before the color changing happens:

1.) ascent(j in 0..(length (array) -1) ){ should really just be ascent(j in 0..length(array)){
Remember that ascents stop one number before the defined upper bound, which is just perfect for array handling.

2.) You shouldn't really be adding the shot ids to the array at the very end. It doesn't serve any purpose that I can see and it just eats up memory (although very slowly).

3.) You actually don't need an array at all if you're only going to have one laser. As you may have noticed if you followed what I said in the #2, you'll only be storing one value, a laser object id, in the array. Arrays are for storing multiple values so it's fairly redundant in this case. Instead, you can declare let o2; at the very top and put o2 = Obj_Create(blahblah); in the laser creation task. Then, when you check for collision in the shot task, you can just compare if o1 is colliding with o2. Of course, if you later plan to add more lasers, go ahead and leave the array in there.
<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.

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread II
« Reply #743 on: December 29, 2009, 06:18:49 AM »
Hey Naut, a quick improvement on your idea:

let r = rand(0, 100);

... and if I want to spawn 500 of them?  Suddenly we're guarenteed overlap, which will cause problems.

A better way to do this is to store an identifier in another common data, such as follows:

r = GetCommonDataDefault("Next_Familiar_ID", 0);
SetCommonData("Next_Familiar_ID", r + 1);


This way, regardless of how many get spawned, we'll never have overlap.

Plus, using rand runs the risk of overlap regardless - there's nothing preventing rand from throwing the same number twice in a row.



Also, it might just be me, but I'd find it better to define a prefix on the Common Data name you're using, such as:

let common_data_name = "familiar_" + r;

... and use that, rather than just the number itself.  Wouldn't make a difference by itself, but I think it's more structured, and less likely to interact with another script in a bad way.
to quote Naut:
"I can see the background, there are too many safespots."
:V

Re: Danmakufu Q&A/Problem Thread II
« Reply #744 on: December 29, 2009, 06:57:13 AM »
rand(0, 100); has a one in one hundred million chance of producing the same number twice in a row.

You're probably thinking of rand_int(0, 100);

But yes, your idea would've guaranteed no duplicates. Honestly, I was just tired of dealing with CommonData so I settled on random numbers without thinking about it... Making a full game is so CommonData heavy that I'm sick of it now. And I've barely skimmed the surface. </minor rant>

KrackoCloud

  • I don't mean to be greedy...
  • ... but white rice is my favorite food.
Re: Danmakufu Q&A/Problem Thread II
« Reply #745 on: December 29, 2009, 07:16:59 AM »
Took a quick look, but didn't copypaste and test the script. I spotted a few errors that might be causing the delay before the color changing happens:

1.) ascent(j in 0..(length (array) -1) ){ should really just be ascent(j in 0..length(array)){
Remember that ascents stop one number before the defined upper bound, which is just perfect for array handling.

2.) You shouldn't really be adding the shot ids to the array at the very end. It doesn't serve any purpose that I can see and it just eats up memory (although very slowly).

3.) You actually don't need an array at all if you're only going to have one laser. As you may have noticed if you followed what I said in the #2, you'll only be storing one value, a laser object id, in the array. Arrays are for storing multiple values so it's fairly redundant in this case. Instead, you can declare let o2; at the very top and put o2 = Obj_Create(blahblah); in the laser creation task. Then, when you check for collision in the shot task, you can just compare if o1 is colliding with o2. Of course, if you later plan to add more lasers, go ahead and leave the array in there.

All right. I've kept the array since the original idea was for multiple sinuate lasers. Unfortunately, although your advice has helped for the screenlong laser, and even works for bullets, the sinuates are still being jerks.

Well, if worst comes, I can always just makes streams of bullets :U

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread II
« Reply #746 on: December 30, 2009, 12:35:49 AM »
rand(0, 100); has a one in one hundred million chance of producing the same number twice in a row.

You're probably thinking of rand_int(0, 100);

But yes, your idea would've guaranteed no duplicates. Honestly, I was just tired of dealing with CommonData so I settled on random numbers without thinking about it... Making a full game is so CommonData heavy that I'm sick of it now. And I've barely skimmed the surface. </minor rant>

Yeah, you're right, I was thinging rand_int.

Sounds like you're really using the hell out of Common Data ...
to quote Naut:
"I can see the background, there are too many safespots."
:V

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #747 on: December 30, 2009, 01:08:23 AM »
Yeah, you're right, I was thinging rand_int.

Sounds like you're really using the hell out of Common Data ...

I agree. This is probably one of the rare times I use it.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #748 on: December 30, 2009, 07:48:17 PM »
Config.exe is pissing me off. No matter what type of compatiblity I use or any setting in Applocal, it refuses to show up. Though it is visible inside taskmanager as a running task.

What the hell, I want to adjust options so dnh runs smoother on my laptop. Currently the fps is like 30-40 =.=

P♂ zeal

  • Haha,
  • old chap
Re: Danmakufu Q&A/Problem Thread II
« Reply #749 on: December 30, 2009, 08:02:23 PM »
my fps is weird too. Either I let it run free and get like 50 windowed[40 with lag] and 78 fullscreen[50 with lag]
or I limit it and get 50 windowed and fullscreen.