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

Cabble

  • Ask me about my Cat.
  • Not unwilling to shank you.
Re: Danmakufu Q&A/Problem Thread
« Reply #960 on: October 17, 2009, 01:47:33 PM »
@Shikieiki Ya- Yama- CHEN:
Still looking through it... Give me a minute.
Semi-colon after your loop(1){yield} statement at the bottom of the script, put Iku Nagae in quotation marks in your DrawText function, delete the second semi-colon after your second declaration of SetGraphicRect, de-capitalize the word task for all of your tasks, rename your Main() task to something else (I don't feel comfortable with it named such, probably not a problem though), you can put the PlaySE back inside that loop in the bottom since you're yield;-ing. The only thing here that may actually fix your problem is the "Task" thing, but even that I doubt. This is just stuff you will run in to later anyways, so you might as well fix it. If none of this works, hopefully somebody else can answer this problem for you, I gotta go to bed. Sorry.

Oh thank you. It works!

First Spellcard: Done
I had a teacher who used to play radiohead during class once.

ONCE.

Re: Danmakufu Q&A/Problem Thread
« Reply #961 on: October 17, 2009, 07:59:36 PM »
Okay, I have yet another irritating dilemma.

I am trying to create a regular enemy script (inside of a spellcard). To my dismay, the first enemy script I tried worked, but this one has an enigmatic error.


This is the one I am trying to work on that is failing:
Code: [Select]
script_enemy redfairy
{
let rf = "script\Remilia spell cards\img\enemy.png";
let count2 = 0;


#include_script "script\Remilia spell cards\Movement for red fairy.txt";
 
@Initialize
{
  SetLife(2000);
  SetDamageRateEx(0,0,50,50);

  LoadGraphic(rf);
  SetTexture(rf);
  SetGraphicRect(0, 0, 64, 80);
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

 if(count2 == 250){
  SetMovePosition02(GetClipMaxX + 50, GetClipMinY + rand_int(20, 200), 30);
  }

count2++;

setgraphicmoverf;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(rf);
}
}


This is the first enemy script I had ever tried using (it worked pefectly in the spellcard I used it in):
Code: [Select]
script_enemy Remilia2
{
let ImgBoss2 = "script\Remilia spell cards\img\Remilia Boss 2.png";
let count2 = 0;


#include_script "script\Remilia spell cards\Movement for Remilia 2.txt";
 
@Initialize
{
  SetLife(2000);
  SetDamageRateEx(0,0,50,50);

  LoadGraphic(ImgBoss2);
  SetTexture(ImgBoss2);
  SetGraphicRect(0, 0, 64, 80);
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

 if(count2 == 250){
  SetMovePosition02(GetClipMaxX + 50, GetClipMinY + rand_int(20, 200), 30);
  }

 if(count2 == 290){
  SetMovePosition02(GetClipMaxX + 50, GetClipMinY + rand_int(20, 200), 1);
  }

 if(count2 == 300){
  SetMovePosition03(GetCenterX + 50, GetClipMinY + 150, 20, 5);
  }
 
 
 if(count2 == 480){
  SetMovePosition02(GetClipMinX + 50, GetClipMinY + 50, 30);
  }

 if(count2 == 540){
  SetMovePosition02(GetClipMaxX - 50, GetClipMaxY - 50, 60);
  }

 if(count2 == 600){
  SetMovePosition02(GetClipMinX + 50, GetClipMaxY - 50, 60);
  }

 if(count2 == 840){
  SetMovePosition02(GetClipMaxX - 50, GetClipMinY + 50, 60);
  }

 if(count2 == 900){
  SetMovePosition02(GetClipMinX + 50, GetClipMinY + 50, 60);
  }

 if(count2 == 1050){
  count2 = 450;
  }

loop(7){
 shoot(count2, 540, 600, rand_int(45, -135), RED12);
 shoot(count2, 600, 660, rand_int(0, 180), RED12);
 shoot(count2, 840, 900, rand_int(-45, 135), RED12);
 shoot(count2, 900, 960, rand_int(180, 360), RED12);
 }

count2++;

setGraphicMove2;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss2);
}


task shoot(c, n, n2, a, g)
{
if(c >= n && c <= n2){
CreateShot01(GetX, GetY, 2, a, g, 5);
}
}


}


The error I get with the first script is the one that you would normally get when you do not have enough closing brackets in your script [script(redfairy){...}]. This makes no sense whatsoever because there is the sufficient amount of both open and closed brackets in the script, if you look it over carefully. So why would I be getting this error?

And when I DO put one more closing bracket at the end of the script, I get this error:



What does this mean?
« Last Edit: October 17, 2009, 08:01:38 PM by Frazer »

Re: Danmakufu Q&A/Problem Thread
« Reply #962 on: October 17, 2009, 08:06:24 PM »
What does setgraphicmoverf; do?

Re: Danmakufu Q&A/Problem Thread
« Reply #963 on: October 17, 2009, 08:12:51 PM »
I put in setgraphicmoverf as the graphic change for the red fairy's movement (included in a different script, as you can see in the script).

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #964 on: October 17, 2009, 08:19:58 PM »
You should check the included function for bracket errors as well.

Re: Danmakufu Q&A/Problem Thread
« Reply #965 on: October 17, 2009, 08:28:21 PM »
Ah, I did not think about that before.

Okay, I added the necessary bracket to the function script file and fixed the problem.

Thank you.


I have another question concerning enemies, then: The last time I asked about enemies, the problem I had was Danmakufu crashing due to deleting the same enemy graphic twice. Is it possible to use the same graphic file for two different enemies/the same enemy while being able to summon the same enemy more than once/both enemies and being able to prevent Danmakufu from crashing when they are killed? (Think of stages: multiples of the same enemy in different variations appear, but they are most likely to use the same image file, yet even after you kill them, you can continue the game.)

EDIT: Is the "DeleteGraphic" function necessary to an enemy file? (I ask because after deleting that line in an enemy file and an enemy is killed, Danmakufu continues and the enemy disappears.)
« Last Edit: October 17, 2009, 08:40:14 PM by Frazer »

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #966 on: October 17, 2009, 08:52:29 PM »
If the enemy is a familiar for a boss, you may as well delete it's graphic in the boss's @Finalize instead. You don't always need to delete the graphics immediately, just as soon as you're sure it won't be used again.

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
« Reply #967 on: October 18, 2009, 08:09:22 AM »
I have a problem... I only started trying 3D recently, so I don't know much yet... (I already looked at Nuclear Cheese's drawing tutorial)

ok now... why is this only showing a black screen?
but when I take out the fog, it shows everything normally, so I'm thinking something's wrong with how I made the fog...

Code: [Select]
@BackGround
   {
      WriteZBuffer(true);
      UseZBuffer(true);

      SetViewTo(-distance2, 10, -distance2/3.5-50-(distance2/12.5));
      SetViewFrom(600, 10, 30);

      SetFog(400, 600, 0, 0, 0);

SetTexture(imagefileb);
SetGraphicRect(0, 0, 50000, 50000);
SetGraphicScale(2, 2);
SetGraphicAngle(90, 70, 0);
DrawGraphic3D(0, -200, 0);

SetTexture(imagefilec);
SetGraphicRect(0, 0, 257, 50000);
SetGraphicScale(1.5, 1.5);
SetGraphicAngle(0, 160, 90);
DrawGraphic3D(-200, 0, 100);

SetTexture(imagefilec);
SetGraphicRect(0, 0, 257, 50000);
SetGraphicScale(1.5, 1.5);
SetGraphicAngle(0, 340, 90);
DrawGraphic3D(-200, 0, -400);

      SetAlpha(255);
      SetTexture(imagefile);
      SetGraphicRect(0, 0, 173, 303);
      SetGraphicScale(0.5, 0.5);
ascent(i in 1..37)
{
      SetGraphicAngle(rotation, rotation+i*10, 180);
      DrawGraphic3D(-distance2-100-(50*cos(rotation2)), -30, -distance2/3.5-(100*sin(rotation2))-(distance2/12.5)-75);
}
   }
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #968 on: October 18, 2009, 06:41:20 PM »
Extremely large polygons break under fog, usually by tinting the whole polygon with the fog (in your case, pure black), so it won't work with your 50000x50000 textures. Around 3000 seems to be where it starts acting up.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #969 on: October 18, 2009, 07:07:12 PM »
Extremely large polygons break under fog, usually by tinting the whole polygon with the fog (in your case, pure black), so it won't work with your 50000x50000 textures. Around 3000 seems to be where it starts acting up.

Confirming this as I had the same problem. I had large bits of 3D stage like 2048+. When fog kicks in, it all looks bad and clipping like crazy between the fog and stage parts. I stay myself below 1024 for complex areas and 2048 straight boxed areas shouldn't be a problem.

Cabble

  • Ask me about my Cat.
  • Not unwilling to shank you.
Re: Danmakufu Q&A/Problem Thread
« Reply #970 on: October 18, 2009, 11:32:39 PM »
Here I am with another problem. It gives me an error whenever I play the stage.

Enemy1.txt
Code: [Select]
script_enemy_main{
let angle = 0;
@Initialize{
SetLife(100);
}
@MainLoop{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
loop(60){
CreateShot01(GetX, GetY, 2, angle, BLUE01, 0);
angle += 360/60;
}
}
@DrawLoop(
}
@Finalize{
}
}

Stage1.txt
Code: [Select]
#TouhouDanmakufu[Stage]
#Title[Stage script tutorial]
#Text[How to make stages in Danmakufu]
#Image[]
#Background[]
#BGM[]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{

 function Wait(let frames){
   loop(frames){yield;}
 }
 function WaitForZeroEnemy{
  while(GetEnemyNum != 0){yield;}
 }
 task stage{
  Wait(120);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX, GetCenterY, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX, GetCenterY, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(60);
  Clear;
 }

  @Initialize{
 stage;
  }
 @MainLoop{
   yield;
  }
  @Background{

  }
  @Finalize{

  }
}

I had a teacher who used to play radiohead during class once.

ONCE.

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #971 on: October 19, 2009, 12:29:05 AM »
DrawLoop in Enemy1.txt has a parentheses instead of a brace.

Re: Danmakufu Q&A/Problem Thread
« Reply #972 on: October 19, 2009, 02:02:31 AM »
I cant seem to get the right angle to get the bullets to move  in a uniform circle around the point of origin. What is the number i need to make to make bullets move around the Point of Origin?
i need help finding teh numbers for:
Code: [Select]
CreateShotA(1, GetX, GetY+30, 0);
SetShotDataA(1, 0, 0, 0, 0, 0, 0, BLUE01);
SetShotDataA(1, 30, 2, 90, 3.14, 0, 0, BLUE01);
FireShot(1);

CreateShotA(2, GetX, GetY+60, 0);
SetShotDataA(2, 0, 0, 0, 0, 0, 0, RED01);
SetShotDataA(2, 30, 2, 90, 3.14, 0, 0, RED01);
FireShot(2);

CreateShotA(3, GetX, GetY+90, 0);
SetShotDataA(3, 0, 0, 0, 0, 0, 0, YELLOW01);
SetShotDataA(3, 30, 2, 90, 3.14, 0, 0, YELLOW01);
FireShot(3);

CreateShotA(4, GetX, GetY+120, 0);
SetShotDataA(4, 0, 0, 0, 0, 0, 0, GREEN01);
SetShotDataA(4, 30, 2, 90, 3.14, 0, 0, GREEN01);}
FireShot(4);

I've tried a lot of numbers, any ideas?

Re: Danmakufu Q&A/Problem Thread
« Reply #973 on: October 19, 2009, 02:40:33 AM »
Read the tutorials. There's a section on sin and cos, which you'll need for any sort of circular danmaku.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #974 on: October 19, 2009, 02:50:39 AM »
I bet he is referring to uniform circular motion with change in angle...

For that you may try to consider this:

Let the velocity (constant) of the bullet be 'v', angular velocity be 'a' and the radius of circle be 'r'.

Time for it to move 1 cycle: 2*3.14*r/v
Time for the bullet to turn 360 degree: 360/a

So the two are equal, and you can get useful formulae for this kind of motion.
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Re: Danmakufu Q&A/Problem Thread
« Reply #975 on: October 19, 2009, 03:00:01 AM »
Hello, Danmakufu newb here. After going through some of the basic tutorials (and working out a somewhat hilarious laser glitch) in a test script, I thought I would slowly expand my horizons by recreating some of the Stage 1 and Stage 2 spellcards. My first victim project: Cirno's Diamond Blizzard (Normal).

However, I'm not quite sure where to go from here. I've got it set up to where all of the bullets spawn from the boss sprite, but obviously it doesn't work that way in Embodiment of Scarlet Devil. Do I need to read up on familiars or object shots that might spawn the other bullets, or is there something else I'm missing?

Source code here, with BGM and spellcard backdrop commented out.
Code: [Select]
#TouhouDanmakufu
#Title[Snow Sign "Diamond Blizzard"]
#Text[My first attempt at recreating a card.]
#BackGround[IceMountain]
//#BGM[.\bgm\th06_05.wav]
#Player[REIMU, MARISA, player\Rumia\Rumia.txt]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\img\ExRumia.png";
//let imgSpellBackdrop=GetCurrentScriptDirectory~"img\icewall.png";
let frame = -120;

    @Initialize {
SetScore(50000);
SetLife(240);
SetDamageRate(10,10);
SetTimer(60);
SetInvincibility(30);

SetGraphicRect(1, 1, 64, 64);
LoadGraphic(ImgBoss);
//LoadGraphic(imgSpellBackdrop);

SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
CutIn(KOUMA, "Snow Sign "\""Diamond Blizzard"\", 0, 0, 0, 0, 0);
    }

    @MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

if(frame == 10) {
loop(5) {
CreateShot01(GetX, GetY, rand(1, 2.5), rand(0, 359), AQUA23, 20);
    }
frame = 0;
}
frame++;
    }

    @Finalize {
DeleteGraphic(ImgBoss);
//DeleteGraphic(imgSpellBackdrop);
    }

    @DrawLoop {
SetAlpha(255);
SetTexture(ImgBoss);
SetGraphicRect(1,1,64,64);
DrawGraphic(GetX(),GetY());
    }

//    @BackGround {
// SetAlpha(150);
// SetTexture(imgSpellBackdrop);
// SetGraphicRect(0,0,384,448);
// DrawGraphic(GetCenterX,GetCenterY);
//    }
}

Re: Danmakufu Q&A/Problem Thread
« Reply #976 on: October 19, 2009, 03:05:13 AM »
I bet he is referring to uniform circular motion with change in angle...

For that you may try to consider this:

Let the velocity (constant) of the bullet be 'v', angular velocity be 'a' and the radius of circle be 'r'.

Time for it to move 1 cycle: 2*3.14*r/v
Time for the bullet to turn 360 degree: 360/a

So the two are equal, and you can get useful formulae for this kind of motion.

I think i understand what you are saying to an Extent... I tried what i think you said and tried this:

   
Code: [Select]
CreateShotA(1, GetX, GetY+30, 0);
SetShotDataA(1, 0, 0, 0, 0, 0, 0, BLUE01);
SetShotDataA(1, 30, 2, 90, 2*3.14*360/2, 0, 0, BLUE01);
FireShot(1);

but it failed

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #977 on: October 19, 2009, 03:12:31 AM »
The problem is your initial angle and you did the maths wrongly:

The initial angle should be the angle of the tangent to the circle.

and,
since 2*3.14*r/v=360/a,

a=360*v/(2*3.14*r)

Code: [Select]
CreateShotA(1, GetX, GetY+30, 0);
SetShotDataA(1, 0, 0, 0, 0, 0, 0, BLUE01);
SetShotDataA(1, 30, 2, 180, 360*2/(2*3.14*30), 0, 0, BLUE01);
FireShot(1);
« Last Edit: October 19, 2009, 03:16:10 AM by Henry »
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Re: Danmakufu Q&A/Problem Thread
« Reply #978 on: October 19, 2009, 03:32:39 AM »
The problem is your initial angle and you did the maths wrongly:

The initial angle should be the angle of the tangent to the circle.

and,
since 2*3.14*r/v=360/a,

a=360*v/(2*3.14*r)

Code: [Select]
CreateShotA(1, GetX, GetY+30, 0);
SetShotDataA(1, 0, 0, 0, 0, 0, 0, BLUE01);
SetShotDataA(1, 30, 2, 180, 360*2/(2*3.14*30), 0, 0, BLUE01);
FireShot(1);

thanks henry! even tho im in Geometry i still couldnt figure that out...thanks again!!!

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #979 on: October 19, 2009, 03:48:05 AM »
You're welcomed to attend Cirno's Perfect Maths Classroom
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Re: Danmakufu Q&A/Problem Thread
« Reply #980 on: October 19, 2009, 10:22:41 AM »
Ok i got a lot of questions, but for now imma start with the one's that's been bothering me for a while.

I've been trying to make bullets appear around the spot you were at at the time they spawned and they spin in relation to that same spot, the final objective is to make them spin inwards towards the spot and leave trails of bullets on the way (like on Orin's card: Malicious Spirit "Spleen Eater", except here the bullets stay and never move), but i cant even make them keep spinning over that same spot, let alone make them spin inwards.

First i tried by making them detect the angle to the player (-90 or +90) and rotate, it's good... until the player moves.

Second i stored the angle towards the player in the task that spawned the bullets in another array, so for every bullet i get the angle stored, and do (-90 or +90) the bullets rotate but seem to spin outwards which is the total opposite of what i wanted.

Third i stored the player's coordinates at the time, on 2 different arrays (one for X and one for Y) and just used atan2 everytime they were moving, but i got the same result as on the second try.

Fourth i returned to the angle and removed the (+90 or -90) to check if the bullets were really aiming at the player position, and i found out they were indeed aiming at the player position, so i was running out of options.

Fifth i changed the angle modifier to (+10 or -10) and now noticed the bullets spinned inwards but  leave like a small hole in the center of idk what radious (maybe 10) and spin around it then spin outward... this is what i wanted... except i need them to converge in the very center not spin around it.

Since i ran out of options, i decided to go with this result and add some extra stuff to the spellcard and made the fairies spawn bullets instead, plus some extra stuff to make it harder, the ocassional bullets going around you were forcing you to stop for a second unless you were able enough to squeeze through their gaps, but i still want to know how to make the things to converge on the spot.

Here's the current code:
Code: [Select]
#TouhouDanmakufu
#Title[Orin Spell 1]
#Text[Orin's First SpellCard]
#BGM[.\system\OrinTheme.mp3]
#PlayLevel[Extra]
#player[FREE]
#ScriptVersion[2]
script_enemy_main{
let CSD = GetCurrentScriptDirectory;
let FairyZ = CSD ~ "FairyZ01.txt";
let imgBoss = CSD ~ "system\Orin.png";
let SpellCircle = CSD ~"system\SpellCircle.png";
let cut = CSD ~ "system\orincut.png";
let bg = CSD ~ "system\OrinBGa.png";
let bg2 = CSD ~ "system\OrinBGb.png";

let shotSE = CSD ~ "system\shotSE.wav";
let chargeSE = CSD ~ "system\charging.wav";
let TO1 = CSD ~ "system\se_timeout.wav";
let TO2 = CSD ~ "system\se_timeout2.wav";

let frame = 0;
let frame2 = 0;
let frame3 = 0;
let frame4 = 0;
let angle = 0;
let angle2 = 360/6;
let angleTilt = 0;
let Circle = 0;
let PlayerAngle = [];
let DrawAngle = 0;
let radious = 0;
let bullets = [];
let spiral = [];
let spawned = false;
@Initialize{
SetLife(1500);
SetTimer(25);
SetScore(1000000);
SetDamageRate(70,70);
SetInvincibility(120);
// Expert;

LoadGraphic(imgBoss);
LoadGraphic(cut);
LoadGraphic(bg);
LoadGraphic(bg2);
LoadGraphic(SpellCircle);
LoadSE(shotSE);
LoadSE(chargeSE);
LoadSE(TO1);
LoadSE(TO2);

SetMovePosition02(100,GetCenterY-100,120);
CutIn(YOUMU,"Wheel of Hell ~ Zombie Fairies",cut,0,0,402,512);
}
@MainLoop{
SetCollisionA(GetX,GetY,30);
SetCollisionB(GetX,GetY,18);
frame++;
frame2++;
frame3++;
DrawAngle++;
if(frame==180){
SummonCircle(GetPlayerX,GetPlayerY);
frame=60;
}
if(frame2==120){
SetMovePosition02(GetPlayerX,GetCenterY-100,120);
if(spawned==false){
loop(10){
CreateEnemyFromFile(FairyZ,GetX,GetY,3,angle2,0);
angle2+=360/10;
}
spawned=true;
}
frame2=0;
}
if(frame3==120){
loop(2){
CreateShot01(GetX,GetY,5+rand(-3,3),0+angleTilt+rand(-3,3),GREEN01,2);
CreateShot01(GetX,GetY,5+rand(-3,3),180+angleTilt+rand(-3,3),GREEN01,2);
}
angleTilt++;
frame3=118;
}
let i = 0;
while(i<length(bullets)){
if(Obj_BeDeleted(bullets[i])){
bullets = erase(bullets,i);
PlayerAngle = erase(PlayerAngle,i);
i--;
}else{
let obj = bullets[i];
Obj_SetSpeed(obj,5);
Obj_SetAngle(obj,PlayerAngle[i]-10);

}
i++;
yield;
}
yield;
if(GetTimer>4&&GetTimer<=10&&frame%60==0){
PlaySE(TO1);
// wait(60);
}
if(GetTimer<=4&&frame%60==0){
PlaySE(TO2);
// wait(60);
}
}
task SummonCircle(x,y){
loop(8){

let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj,x+100*cos(angle),y+100*sin(angle));
PlayerAngle = PlayerAngle ~ [atan2(y-Obj_GetY(obj),x-Obj_GetX(obj))];
Obj_SetSpeed(obj,0);
Obj_SetAngle(obj,0);
ObjShot_SetDelay(obj,5);
ObjShot_SetGraphic(obj, RED04);
ObjShot_SetBombResist(obj, true);

bullets = bullets ~ [obj];

angle+=360/8;
}
yield;
}
task ShootSpiral{

}
@DrawLoop{
frame4++;
if(frame4<=60){
Circle+=1/60;
}
if(frame4>60 && frame4<=120){
Circle-=1/60;
}
if(frame4>120){
frame4=0;
}
DrawText("Rin Kaenbyou", 36, 39, 12, 225);
SetTexture(imgBoss);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,62,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);

SetTexture(SpellCircle);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetAlpha(60);
SetGraphicRect(0,0,126,125);
SetGraphicScale(Circle+1,Circle+1);
SetGraphicAngle(0,0,DrawAngle*2);
DrawGraphic(GetX,GetY);
}
@BackGround{
SetTexture(bg);
SetRenderState(ALPHA);
SetAlpha(90);
SetGraphicRect(0,0,512,512);
SetGraphicAngle(0,0,DrawAngle);
SetGraphicScale(1,1);
DrawGraphic(GetCenterX,GetCenterY);

SetTexture(bg2);
SetRenderState(ALPHA);
SetAlpha(160);
SetGraphicRect(-DrawAngle,-DrawAngle,512-DrawAngle,512-DrawAngle);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
DrawGraphic(GetCenterX,GetCenterY);

}
@Finalize{
DeleteGraphic(imgBoss);
DeleteGraphic(cut);
DeleteSE(shotSE);
DeleteSE(chargeSE);
DeleteSE(TO1);
DeleteSE(TO2);
SetCommonData("Vanish",true);
DeleteAllEnemyWithoutBoss;
loop(8){
CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
}
function wait(w){
loop(w){yield;}
}
}
As for the second question, I wanna know how to add my own bullets to the game, i wanted to recreate Murasa's Anchor, although i get an error everytime, or no sprite at all for it, here are the codes:

Bullet Code:
Code: [Select]
#UserShotData    // Required

ShotImage = GetCurrentScriptDirectory~"system\anchor.png"    // Image of Bullets

// Definition of bullet
ShotData {
    id               = 120                  // Bullet ID
    rect             = (0, 0, 32, 32)     // Region in the ShotImage
    render           = ALPHA              // Render type
    delay_color      = (255, 128, 255)    // Color of light on delay
    angular_velocity = rand(-5, 5)        // Ang. vel. of graphic rotation
}

And the Script where the bullet is supposed to appear (i commented out all the things i did to try to make it appear, and returned the bullet graphic to BLUE03, i left what i was using earlier in a comment too)
Code: [Select]
#TouhouDanmakufu
#Title[Satori Spellcard 2]
#Text[Satori's Second SpellCard]
#BGM[.\system\SatoriTheme.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss= CSD ~ "system\satori.PNG";
let cut= CSD ~ "system\satoricut.png";
let bg = CSD ~ "system\SatoriBGa.png";
let bg2 = CSD ~ "system\SatoriBGb.png";

// let ANCHOR = CSD~"Anchor.txt";
// let ANCHOR = LoadUserShotData(CSD~"Anchor".txt);

let shotSE = CSD ~ "system\shotSE.wav";
let chargeSE = CSD ~ "system\charging.wav";
let anchorSE = CSD ~ "system\se_boon00.wav";
let TO1 = CSD ~"system\se_timeout.wav";
let TO2 = CSD ~"system\se_timeout2.wav";

let frame = 0;
let frame2 = 0;
let frame3 = 0;
let angle = 0;

@Initialize{
SetLife(500);
SetTimer(60);
SetScore(110000);
SetDamageRate(10,0);
SetInvincibility(120);
// Expert;

LoadGraphic(imgBoss);
LoadGraphic(cut);
LoadGraphic(bg);
LoadGraphic(bg2);
LoadSE(shotSE);
LoadSE(chargeSE);
LoadSE(anchorSE);
// LoadUserShotData(ANCHOR);
LoadSE(TO1);
LoadSE(TO2);

SetMovePosition02(GetCenterX, GetCenterY - 100, 120); //Move the boss to the top center of the screen.
CutIn(YOUMU,"Recolection ~ Death Anchor",cut,0,0,256,512);
Concentration01(120);
PlaySE(chargeSE);
}
@MainLoop{

if(OnBomb==false){
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,21);
}
frame ++;
frame2 ++;
if(GetTimer>4&&GetTimer<=10&&frame3%60==0){
PlaySE(TO1);
}
if(GetTimer<=4&&frame3%60==0){
PlaySE(TO2);
}
if(frame==120){
CreateShotA(1,GetX,GetY,10);
// SetShotDataA(1,0,1,GetAngleToPlayer,0,0.4,12,ANCHOR);
SetShotDataA(1,0,1,GetAngleToPlayer,0,0.4,12,BLUE03);
ascent(i in 1..60){
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer-90,0,0,0,AQUA01);
SetShotDataA(2,30,0,GetAngleToPlayer-90,0,0.3,8,AQUA01);
AddShot(i*2,1,2,0);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer-90,0,0.0,0,AQUA01);
SetShotDataA(2,33,0,GetAngleToPlayer-90,0,0.2,8,AQUA01);
AddShot(i*2,1,2,0);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer-90,0,0.0,0,AQUA01);
SetShotDataA(2,35,0,GetAngleToPlayer-90,0,0.1,8,AQUA01);
AddShot(i*2,1,2,0);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer+90,0,0,0,AQUA01);
SetShotDataA(2,30,0,GetAngleToPlayer+90,0,0.3,8,AQUA01);
AddShot(i*2,1,2,0);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer+90,0,0,0,AQUA01);
SetShotDataA(2,33,0,GetAngleToPlayer+90,0,0.2,8,AQUA01);
AddShot(i*2,1,2,0);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,0,GetAngleToPlayer+90,0,0,0,AQUA01);
SetShotDataA(2,35,0,GetAngleToPlayer+90,0,0.1,8,AQUA01);
AddShot(i*2,1,2,0);
}
FireShot(1);
frame = 60;
PlayAnchor;
}
if(frame2==120){
loop(60){
CreateShot01(GetX,GetY,1,GetAngleToPlayer+angle,PURPLE31,5);
angle+=360/60;
}
PlaySE(shotSE);
angle=0;
frame2=60;
}
yield;


}

@DrawLoop{
SetColor(255,255,255);
SetRenderState(ALPHA);

if(OnBomb==false){
SetAlpha(255);
}else{
SetAlpha(150);
}

SetTexture(imgBoss);
SetGraphicRect(0,0,47,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);
}
@BackGround{
frame3++;
SetTexture(bg);
SetRenderState(ALPHA);
SetAlpha(90);
SetGraphicRect(-frame3,0,512-frame3,512);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX, GetCenterY);

SetTexture(bg2);
SetRenderState(ALPHA);
SetAlpha(150);
SetGraphicRect(0,0,256,256);
SetGraphicAngle(0,0,frame3);
DrawGraphic(GetCenterX,GetCenterY);
}

@Finalize
{
DeleteGraphic(imgBoss);
DeleteGraphic(cut);
DeleteGraphic(bg);
DeleteSE(shotSE);
DeleteSE(chargeSE);
DeleteSE(anchorSE);
DeleteSE(TO1);
DeleteSE(TO2);
// DeleteUserShotData(ANCHOR);
loop(20){
CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
}
CreateItem(ITEM_1UP,GetX,GetY);
}
task PlayAnchor{
PlaySE(anchorSE);
wait(20);
PlaySE(anchorSE);
yield;
}


function wait(w){
loop(w){yield};
}
}

And for the last question, how can i make bullets glow? hope you guys can help me out

Re: Danmakufu Q&A/Problem Thread
« Reply #981 on: October 19, 2009, 11:35:36 AM »
Umm... I'm having a problem with a script.






Well, I don't really know what the problem is...
I'm loading a separate script (using #include_function) and well, I'm loading the variables there.
I'm sure I did it correctly, but if I missed anything, well... could anyone help me?
Here is the separate script...
Code: [Select]
let 1a = GetCurrentScriptDirectory~"images\stagedata\Back001.png";
let 1b = GetCurrentScriptDirectory~"images\stagedata\Back002.png";
let 1c = GetCurrentScriptDirectory~"images\stagedata\Back003.png";
etc...
task LoadImages{
yield;
LoadGraphic(1a);LoadGraphic(1b);LoadGraphic(1c);LoadGraphic(1d);LoadGraphic(1e);LoadGraphic(1f);LoadGraphic(1g);
etc...
}
task DeleteImages{
yield;
DeleteGraphic(1a);DeleteGraphic(1b);DeleteGraphic(1c);DeleteGraphic(1d);DeleteGraphic(1e);DeleteGraphic(1f);DeleteGraphic(1g);
etc...
}

task AnimateBackground(let delay){
yield;

function wait(let frame){
loop(frame){yield;}}
            SetTexture(1a);SetGraphicRect(0,0,384,448);SetAlpha(255);SetRenderState(ALPHA);SetGraphicAngle(0, 0, 0);SetGraphicScale(1,1);DrawGraphic(GetCenterX,GetCenterY);wait(delay);
            SetTexture(1b);SetGraphicRect(0,0,384,448);SetAlpha(255);SetRenderState(ALPHA);SetGraphicAngle(0, 0, 0);SetGraphicScale(1,1);DrawGraphic(GetCenterX,GetCenterY);wait(delay);
etc...
}

And the main script.

Code: [Select]
#TouhouDanmakufu[Stage]
#Title[TEST]
#Text[TEST]
#Player[MARISA]
#ScriptVersion[2]

script_stage_main
{
#include_function".\stageframes.txt";
   @Initialize
   {
yield;
LoadImages;
   }

   @BackGround
{
yield;
AnimateBackground(0);
   }
   
   @Finalize
   {
      DeleteImages;
   }
}


I'm loading the variables like this:
Code: [Select]
let 1a = *;
until...
let 1z = *;
and then...
Code: [Select]
let 2a = *;
until...
let 2x = *;

Yeah it's a long stupid process :\
Maybe that's the problem? :V

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #982 on: October 19, 2009, 12:03:39 PM »
I've no idea what the problem is, the error message says something about "Identifier is needed" or something.

but I just want to ask about the use of yield;s in your scripts...
Why are you including it at the beginning of every task? There is no need for pausing your task for 1 frame before you load the graphics. Yield; is not a must in every task you make, you know.

Also, the script is lacking a @MainLoop. I don't know if it's neccesary, maybe it's causing an error. :x
But putting a single yield; in the @MainLoop would be sufficient, you don't need to put a yield; everywhere.

Also, why are you declaring function wait inside task AnimatedBackground? (Can you actually declare functions inside tasks? :x) You should declare it outside of the task and you can still refer to it inside the task.

One more thing, you are starting up a new AnimatedBackground every frame, resulting in one task overlapping draw graphics on another. So the structure won't work.

Sorry that I can't help you with the main problem...
« Last Edit: October 19, 2009, 12:19:45 PM by Thaws »

Re: Danmakufu Q&A/Problem Thread
« Reply #983 on: October 19, 2009, 01:28:15 PM »
Oh wow...
The variables' labels were the actual problems.
I just replaced the numbers in the variables with something else, and I did what you advised me.
It works perfectly now. Thanks!

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #984 on: October 19, 2009, 04:32:23 PM »
Yeah, you can't start a variable name with a number.

Re: Danmakufu Q&A/Problem Thread
« Reply #985 on: October 19, 2009, 05:37:14 PM »
Well now one has answered any of my questions yet, but i just got a new one, how do people make it so that it shows Spell Card Attack on the background at the start of a spellcard like on Touhou 10+?

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #986 on: October 19, 2009, 05:48:24 PM »
Well now one has answered any of my questions yet, but i just got a new one, how do people make it so that it shows Spell Card Attack on the background at the start of a spellcard like on Touhou 10+?
Here be it.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #987 on: October 19, 2009, 05:49:09 PM »
oh the magic of literacy

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

Re: Danmakufu Q&A/Problem Thread
« Reply #988 on: October 19, 2009, 06:22:38 PM »
Here be it.
Thanks =D now if someone could answer my other questions ><

PT8Sceptile

  • All hail Giant Catfish!
Re: Danmakufu Q&A/Problem Thread
« Reply #989 on: October 19, 2009, 08:23:30 PM »
Thanks =D now if someone could answer my other questions ><

Well...

For the inwards spinning circle, the easiest way would be to make a task that saves the current location of the player, and then keep setting the position of the bullet again and again with a shrinking radius and a changing angle. It's completely doable with arrays, too, but a bit trickier, so I'll give an example using a task:

Code: [Select]
task CirclingBullet(x, y, rad, ang, avel, rshrink){
      //x and y are the location of the center, rad the distance from center,
      //ang the initial angle, avel the rate of angle change and rsrink the
      //amount by which the radius shrinks per frame.
      //Add additional variables as necessary

     let obj = Obj_Create(OBJ_SHOT);
     Obj_SetPosition(obj,x+rad*cos(angle),y+rad*sin(angle));
     Obj_SetSpeed(obj,0);
     Obj_SetAngle(obj,0);
     ObjShot_SetDelay(obj,5);
     ObjShot_SetGraphic(obj, RED04);
     ObjShot_SetBombResist(obj, true);

     while(!Obj_BeDeleted(obj) {
          rad -= rshrink;
          ang += avel;
          Obj_SetPosition(obj,x+rad*cos(angle),y+rad*sin(angle));
          //Possibly add some code here to delete the bullet once
          //rad hits 0 if you don't want it to spiral outwards afterwards.
          //Also add bullet creation code here.
          yield;
     }
     
}

And create it in your mainloop using:

Code: [Select]
ascent(i in 0..8) {
    CirclingBullet(GetPlayerX, GetPlayerY, 100, i*360/8, 1, 0.5);
}

And as long as there's a yield; in your main loop, that should be enough.

Also, this is doable with arrays by saving the x and y coordinates in seperate arrays and resetting the position in the main loop accordingly. It just takes a bit more work.

For the anchor problem, I see you're calling the bullet through ANCHOR, which is a String variable. The bullet however has to be called by ID. This should probably make things clearer:

Danmakufu references bullets using numbers. Things such as RED01 and YELLOW03 are just convenient names that reference numbers. If you want to make ANCHOR represent the anchor bullet, you must set "let ANCHOR = 120;", since in the shot creation file, you set the id of the shot to 120. Or you can just put 120 in the bullet part of the script.

However, if I'm right about how bullet defining scripts work (someone please correct me if I'm wrong), loading user shot data replaces all bullets in danmakufu at the moment, so if you load your anchor bullet, bullets like BLUE03 and AQUA01 don't work anymore. So you either have to create the whole bullet sheet from scratch, or edit the anchor to some existing bullet definition file (like for example the CtC shot replace script). Adding a single bullet type while preserving all older ones is, under my current knowledge, impossible through any conventional means.

I'm not exactly sure about this, but seemingly glowy bullets have "render = ALPHA" in the shot definition script replaced with "render = ADD" (again, someone please correct me if I'm wrong). You could create your own in the same file as the anchor for example, or you can use a pre-existing bullet sheet with them (for example the CtC shot replace script has [COLOR]50, [COLOR]51 and [COLOR]57 that glow).
« Last Edit: October 19, 2009, 08:26:09 PM by PT8Sceptile »