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

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #90 on: October 28, 2009, 02:32:02 AM »
If you want other people to understand what the hell you're doing/you to understand when you come back to it later, yes.

It's honestly stupidly random and unnecessarily hard. I like how you experimented with the colors, but the vibe just isn't there for me.

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

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #91 on: October 28, 2009, 02:33:25 AM »
If you want other people to understand what the hell you're doing/you to understand when you come back to it later, yes.

It's honestly stupidly random and unnecessarily hard. I like how you experimented with the colors, but the vibe just isn't there for me.
Shhhh... not so loud! I want some noob to wreck his brain trying to figure out how everything works. Honestly, I tried to go for something like Remi's LW in IN... but somehow I decided, why not? And now, there are WHAT THE FUCK I DONT EVEN number of variables. Arrays. Arrays. Arrays. Arrays. Arrays.
Anyways, it's at least a bit tidier than last time, isn't it?.
« Last Edit: October 28, 2009, 02:45:40 AM by AlwaysThe⑨ »

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread II
« Reply #92 on: October 28, 2009, 12:08:39 PM »
Assuming you're not talking about the actual curved lasers (which are made with LaserC functions):

Code: [Select]
task byaphase
{
let angle = 0;
let anglechange = 0.5;
loop
   {
   CreateShot01(GetX-64,GetY-96,4,angle+95,BLUE21,30); //top left
   CreateShot01(GetX-64,GetY-96,4,angle+155,BLUE21,30);
   CreateShot01(GetX-64,GetY-96,4,angle+35,BLUE21,30);

   CreateShot01(GetX+64,GetY-96,4,-angle+85,BLUE21,30); //top right
   CreateShot01(GetX+64,GetY-96,4,-angle+145,BLUE21,30);
   CreateShot01(GetX+64,GetY-96,4,-angle+25,BLUE21,30);


   CreateShot01(GetX-128,GetY+32,4,-angle+80,BLUE21,30); //bottom left
   CreateShot01(GetX-128,GetY+32,4,-angle+140,BLUE21,30);
   CreateShot01(GetX-128,GetY+32,4,-angle+20,BLUE21,30);

   CreateShot01(GetX+128,GetY+32,4,angle+100,BLUE21,30); //bottom right
   CreateShot01(GetX+128,GetY+32,4,angle+160,BLUE21,30);
   CreateShot01(GetX+128,GetY+32,4,angle+40,BLUE21,30);

   if (angle > 12 || angle < -12){anglechange = -anglechange;}
   angle += anglechange;
   loop(4){yield;}
   }
}

You may want to tweak the positions they spawn from and the exact angle, but this matches fairly well.

So for the curved lasers, a velocity of 0 and angle acceleration enables the motion like that?
Old/Forgotten member.

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #93 on: October 28, 2009, 03:12:10 PM »
Question ze:

I am trying to fool around with custom life bars by creating a function for it. However my math is amazing as ever and can't get the size proportions right. It is like this:

Enemy Life is, let's say: 1000. The static size of the lifebar is ALWAYS 300 pixels long. Now depending on a math function I have to convert the 1000 life to equal size of 300. Meaning if the enemy takes 100 damage, the life bar has to decrease with the same %. Eventually if the enemy life hits 0, the lifebar should be 0 pixels wide as well.

But I keep messing up the math , either my lifebar is shrinking too slow or too fast >.<

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #94 on: October 28, 2009, 03:34:53 PM »
Question ze:

I am trying to fool around with custom life bars by creating a function for it. However my math is amazing as ever and can't get the size proportions right. It is like this:

Enemy Life is, let's say: 1000. The static size of the lifebar is ALWAYS 300 pixels long. Now depending on a math function I have to convert the 1000 life to equal size of 300. Meaning if the enemy takes 100 damage, the life bar has to decrease with the same %. Eventually if the enemy life hits 0, the lifebar should be 0 pixels wide as well.

But I keep messing up the math , either my lifebar is shrinking too slow or too fast >.<

Let's hope the code I write makes sense without explanation.
Code: [Select]
enemy_script_main{
  let maxLife;
  let currentLife;
  let percentage;
  let lifeBarLeft;

  @Initialize{
    SetLife(1000);
    maxLife = GetEnemyLife();
    CustomLifeBar;
  }

  @MainLoop{
    yield;
  }

  @DrawLoop{
  }

  @Finalize{
  }

  task CustomLifeBar{
    currentLife = GetEnemyLife();
    percentage = currentLife/maxLife;
    lifeBarLeft = ceil(300*percentage);

    //Do stuff with lifeBarLeft which now stores how many pixels your life bar should be.

    yield;
  }
}
« Last Edit: October 28, 2009, 03:37:10 PM 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.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #95 on: October 28, 2009, 03:42:14 PM »
FFFFFFFFF I knew I was missing something. Though I kept dividing  GetEnemyLife with 300 and such. Which is obviously NOT the method.

ps, what does ceil do? Cannot remember anymore. Round up/down to nearest with no decimals?

(heads out to try the code)

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #96 on: October 28, 2009, 03:45:18 PM »
ceil = round up

ceil(8.9) = 9
ceil(8.1) = 9
ceil(8.0000000000000001) = 9

The opposite is floor which rounds down similarly.
<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: Danmakufu Q&A/Problem Thread II
« Reply #97 on: October 28, 2009, 03:47:03 PM »
durr math stuff insert here

Code: [Select]
SetLength(healthbar, 300-((300/totallife)*GetLife());And just run it every frame.

EDIT: beaten derpderp

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #98 on: October 28, 2009, 03:59:54 PM »
I am such an frikken idiot when it comes down to implementing math in code. Argh....

My life bar loads up and extends till 300, but when the math code kicks in, it pops ALL the way to the left :V

Code: [Select]
--- Declaring above  maxLife and inside @initialize before calling hpBar I do maxLife = GetEnemyLife;

--- function
    // hp life
    task hpBar{
// vars
let lifebarSize = 0;
let lifebarReady = 0;
        let enyLife;
let hpp; // hp percentage
let nhp; // new hp (updated aka left over)

let obj = Obj_Create(OBJ_EFFECT);

// effect functions etc.
ObjEffect_SetTexture(obj,lifebar);
Obj_SetPosition(obj,40,40);
ObjEffect_SetLayer(obj,7);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);

while(! Obj_BeDeleted(obj)) {

// requires to be inside loop for update
          ObjEffect_SetVertexXY(obj, 0, 0, -4);
          ObjEffect_SetVertexUV(obj, 0, 0, 0);
          ObjEffect_SetVertexXY(obj, 1, lifebarSize, -4);
          ObjEffect_SetVertexUV(obj, 1, 128, 0);
          ObjEffect_SetVertexXY(obj, 2, 0, 4);
          ObjEffect_SetVertexUV(obj, 2, 0, 32);
          ObjEffect_SetVertexXY(obj, 3, lifebarSize, 4);
          ObjEffect_SetVertexUV(obj, 3, 128, 32);

if(lifebarSize<300 && lifebarReady == 0){ lifebarSize+=5; } // prepares the lifebar to 300
if(lifebarSize==300){ lifebarReady = 1;} // switch
if(lifebarReady==1){ // start animating it

enyLife = GetEnemyLife;
hpp = enyLife/maxLife;
nhp = ceil(300*hpp);
lifebarSize -= nhp;
}
yield;
}
}

Ok you may laugh now.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #99 on: October 28, 2009, 05:48:32 PM »
Enemy starts with 1000. First iteration does this:

hpp = 1000/1000 = 1
nhp = ceil(300*1) = 300
lifebarSize = 300 - 300 = 0

You also shouldn't need another variable for GetEnemyLife if it does it every frame. If this code works you can break it into separate variables if you want.

Code: [Select]
      if(lifebarReady==1){                   // start animating it
         lifebarSize = 300-ceil((300/maxLife)*GetEnemyLife());
      }

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

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #100 on: October 28, 2009, 06:03:06 PM »
Let's hope the code I write makes sense without explanation.
Code: [Select]
enemy_script_main{
  let maxLife;
  let currentLife;
  let percentage;
  let lifeBarLeft;

  @Initialize{
    SetLife(1000);
    maxLife = GetEnemyLife();
    CustomLifeBar;
  }

  @MainLoop{
    yield;
  }

  @DrawLoop{
  }

  @Finalize{
  }

  task CustomLifeBar{
    currentLife = GetEnemyLife();
    percentage = currentLife/maxLife;
    lifeBarLeft = ceil(300*percentage);

    //Do stuff with lifeBarLeft which now stores how many pixels your life bar should be.

    yield;
  }
}

What, "enemy_script_main"? No!
Anyways, custom life bar, as in Satori's things at the end?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #101 on: October 28, 2009, 06:23:53 PM »
Enemy starts with 1000. First iteration does this:

hpp = 1000/1000 = 1
nhp = ceil(300*1) = 300
lifebarSize = 300 - 300 = 0

You also shouldn't need another variable for GetEnemyLife if it does it every frame. If this code works you can break it into separate variables if you want.

Code: [Select]
      if(lifebarReady==1){                   // start animating it
         lifebarSize = 300-ceil((300/maxLife)*GetEnemyLife());
      }

PLEASE WAIT WARMLY AS I ATTEMPT AGAIN ( hits head against the desk a few times )

Edit: the lifebar bar now jumps suddenly to some unknown location lol. Like diagonal. What the hell ?

Edit2: %$#FAFADADASD    ** goes to boot laptop and copy the code over from there **

Edit3:   =D =D =D It works, but Drake. Your code is not 100% correct I seen:

               lifebarSize = 300-ceil((300/maxLife)*GetEnemyLife());  <--- 300 has to go in the beginning
               lifebarSize = ceil((300/maxLife)*GetEnemyLife());  <--- like this.



Edit4: Allright, though there seem to be a glitch with this. First of all, the original lifebar is ALWAYS updated before any other task. So sometimes like mm bar is left or when using the 'H' button, a whole chuck stays. See here
« Last Edit: October 28, 2009, 06:49:20 PM by Helepolis »

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #102 on: October 28, 2009, 06:35:48 PM »
PLEASE WAIT WARMLY AS I ATTEMPT AGAIN ( hits head against the desk a few times )

Edit: the lifebar bar now jumps suddenly to some unknown location lol. Like diagonal. What the hell ?

Edit2: %$#FAFADADASD    ** goes to boot laptop and copy the code over from there **
I tried it too, but the effect obbject doesn't shrink. Am I doing something wrong?

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #103 on: October 28, 2009, 06:59:56 PM »
What, "enemy_script_main"? No!
Anyways, custom life bar, as in Satori's things at the end?

Bah, I always just copy-paste a framework, but I wrote it out straight into the reply thing here this time.
<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: Danmakufu Q&A/Problem Thread II
« Reply #104 on: October 28, 2009, 10:52:03 PM »
How does graphic layering work? is there a way to put a graphic over the bullets, boss, and the player?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #105 on: October 28, 2009, 10:56:49 PM »
Make an effect object, declare it's vertices and such and then ObjEffect_SetLayer(obj, 4); or 5 or something.

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

Re: Danmakufu Q&A/Problem Thread II
« Reply #106 on: October 28, 2009, 11:37:57 PM »
Make an effect object, declare it's vertices and such and then ObjEffect_SetLayer(obj, 4); or 5 or something.

is there a way to put that into a task or something?

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread II
« Reply #107 on: October 28, 2009, 11:50:46 PM »
Of course, the same way that you would make an object bullet, but instead of OBJ_SHOT use OBJ_EFFECT. Remove all of the shot-only functions and replace them with the necessary effect-only ones.

Here is an example that I used to make a "stage title":

Code: [Select]
task DrawTitle
{
let obj=Obj_Create(OBJ_EFFECT);
let alpha = 0;
let x = 100;

ObjEffect_SetTexture(obj,Title);
ObjEffect_SetRenderState(obj,ALPHA);
ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetLayer(obj,6);

ObjEffect_CreateVertex(obj,4); //Set the 4 corners of the graphic
ObjEffect_SetVertexUV(obj,0,0,0);
ObjEffect_SetVertexUV(obj,1,320,0);
ObjEffect_SetVertexUV(obj,2,320,240);
ObjEffect_SetVertexUV(obj,3,0,240);

ObjEffect_SetVertexXY(obj,0,-160,-120); //Set where those corners draw relative to the object
ObjEffect_SetVertexXY(obj,1,160,-120);
ObjEffect_SetVertexXY(obj,2,160,120);
ObjEffect_SetVertexXY(obj,3,-160,120);

while(alpha<255) //while still fading in...
{
ascent(vertex in 0..4){ObjEffect_SetVertexColor(obj,vertex,alpha,255,255,255);} //Updates the object alpha
Obj_SetPosition(obj,x,200);
alpha+=3;
x++;
yield;
}
loop(120) //wait a bit...
{
Obj_SetPosition(obj,x,200);
x++;
yield;
}
while(alpha>0) //while fading out...
{
ascent(vertex in 0..4){ObjEffect_SetVertexColor(obj,vertex,alpha,255,255,255);}
Obj_SetPosition(obj,x,200);
alpha-=3;
x++;
yield;
}
Obj_Delete(obj);
}

Re: Danmakufu Q&A/Problem Thread II
« Reply #108 on: October 28, 2009, 11:56:28 PM »
And here I was going to try and ninja Onthenet with an ObjEffect example like this:

Code: [Select]
task ohjesus{
let l2 = Obj_Create(OBJ_EFFECT); //l2 is the farthest section of the ..., not attached to the ....
ObjEffect_SetTexture(l2, gfs);
ObjEffect_CreateVertex(l2, 4);
ObjEffect_SetRenderState(l2, ALPHA);
ObjEffect_SetPrimitiveType(l2, PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetVertexUV(l2, 0, 79, 12);
ObjEffect_SetVertexUV(l2, 1, 116, 12);
ObjEffect_SetVertexUV(l2, 2, 116, 101);
ObjEffect_SetVertexUV(l2, 3, 76, 101);
let l1 = Obj_Create(OBJ_EFFECT); //l1 is the closest section of the ..., attached to the .... Drawn second so it appears above l2.
ObjEffect_SetTexture(l1, gfs);
ObjEffect_CreateVertex(l1, 4);
ObjEffect_SetRenderState(l1, ALPHA);
ObjEffect_SetPrimitiveType(l1, PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetVertexUV(l1, 0, 11, 12);
ObjEffect_SetVertexUV(l1, 1, 52, 12);
ObjEffect_SetVertexUV(l1, 2, 52, 100);
ObjEffect_SetVertexUV(l1, 3, 11, 100);
let x = 948 - 80; //coordinates of the tip of the ....
let y = 480;
let hy = 100;
let counter = -10;
loop{
counter++;
if(counter>=30 && counter<45){
x-=4;
y-=8;
}
if(counter>=45 && counter<60){
x-=4;
y+=8;
}
if(counter>=90 && counter<105){
x-=4;
y-=8;
}
if(counter>=105 && counter<120){
x-=4;
y+=8;
}
if(counter>=150 && counter<165){
x-=4;
y-=8;
}
if(counter>=165 && counter<180){
x-=4;
y+=8;
}
if(counter>=210 && counter<225){
x-=4;
y-=8;
}
if(counter>=225 && counter<240){
x-=4;
y+=8;
}
if(counter>=270 && counter<285){
x-=4;
y-=8;
}
if(counter>=285 && counter<300){
x-=4;
y+=8;
}
if(counter>=330 && counter<345){
x-=4;
y-=8;
}
if(counter>=345 && counter<360){
x-=4;
y+=8;
}
if(counter>=440 && counter<455){
x-=6;
y-=6;
}
if(counter>=455 && counter<460){
x-=6.5;
y-=2;
}
let ang = atan2(y - kingy, x - kingx); //Angle from the ... to the tip of the ....
let x1 = ((kingx + x)/2) + (((hy^2) - ((kingx + x)/2))^0.5)*cos(ang + 90); //X coordinate of the ....
let y1 = ((kingy + y)/2) + (((hy^2) - ((kingy + y)/2))^0.5)*sin(ang + 90); //Y coordinate of the ....
let ang1 = atan2(y1 - kingy, x1 - kingx); //Angle from the ... to the ....
let ang2 = atan2(y - y1, x - x1); //Angle from the ... to the tip of the ....
ObjEffect_SetVertexXY(l2, 0, x1 + 20*cos(ang1 - 45), y1 + 20*sin(ang1 - 45));
ObjEffect_SetVertexXY(l2, 1, x1 + 20*cos(ang1 + 45), y1 + 20*sin(ang1 + 45));
ObjEffect_SetVertexXY(l2, 2, kingx + 20*cos(ang1 + 135), kingy + 20*sin(ang1 + 135));
ObjEffect_SetVertexXY(l2, 3, kingx + 20*cos(ang1 + 225), kingy + 20*sin(ang1 + 225));
ObjEffect_SetVertexXY(l1, 0, x1 + 20*cos(ang2 - 95), y1 + 20*sin(ang2 - 95));
ObjEffect_SetVertexXY(l1, 1, x1 + 20*cos(ang2 + 95), y1 + 20*sin(ang2 + 95));
ObjEffect_SetVertexXY(l1, 2, x + 20*cos(ang2 + 135), y + 20*sin(ang2 + 135));
ObjEffect_SetVertexXY(l1, 3, x + 20*cos(ang2 + 225), y + 20*sin(ang2 + 225));
if(((x - GetPlayerX)^2 + ((y - 20) - GetPlayerY)^2)^0.5<20 || ((x1 - GetPlayerX)^2 + (y1 - GetPlayerY)^2)^0.5<20 && variable==1){
ShootDownPlayer;
variable=2;
}
yield;
} //end loop
} //end task

I see it was a good thing I didn't.

Re: Danmakufu Q&A/Problem Thread II
« Reply #109 on: October 29, 2009, 01:31:15 AM »
is there a way to have a layered image go down the field? like its scrolling down?

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #110 on: October 29, 2009, 01:39:13 AM »
is there a way to have a layered image go down the field? like its scrolling down?
DrawGraphic(<x-co>, yvariable);
...
and somewhere:
yvariable -= <a value> ;

Re: Danmakufu Q&A/Problem Thread II
« Reply #111 on: October 29, 2009, 01:39:45 AM »
Create a variable for it's y coordinates, increase the variable, keep setting the Object's XY vertices at the end of your while loop. Actually, my example does this, though I didn't and still don't expect you to read it :V

Edit: ahhh, ninja'd. Nice job. Even though your response does nothing for Objects, :S

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread II
« Reply #112 on: October 29, 2009, 01:49:00 AM »
Why this segment does not make the enemy move in a curve?

Code: [Select]
SetMovePositionHermite(GetCenterX*2-GetX, GetY, 10, 90, 10, -90, 60);
Old/Forgotten member.

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

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread II
« Reply #113 on: October 29, 2009, 05:07:55 AM »
Is there any way (or workaround) to add a 3D background to a plural-script that's more than one layer deep? If there's no way to make it 3D, is there any way to get it multi-layered anyway?
If neither are possible, it's not too big of a deal (I'm making a stage anyway), but it would be nice to use the same background when you choose to just practice the boss.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #114 on: October 29, 2009, 07:46:27 AM »
Is there any way (or workaround) to add a 3D background to a plural-script that's more than one layer deep? If there's no way to make it 3D, is there any way to get it multi-layered anyway?
If neither are possible, it's not too big of a deal (I'm making a stage anyway), but it would be nice to use the same background when you choose to just practice the boss.

You can always use common data to have the scripts communicate with each other. Store all the variables in it and recall them in the next attack so that there's no jump in the background? Might be kinda weird when it actually becomes a stage though.
<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.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #115 on: October 29, 2009, 02:27:46 PM »
Sorry for the double post.

I'm trying to narrow down a problem and it'd be a great help if someone could tell me if there was anything wrong with this effect object code since I'm new to effects.. No error occurs when making the effect object, but nothing is being drawn. If I run it with the debug window open, the log tab outputs something about the path of the two PNG files that I have, but I double-checked the path and they are named correctly and in the correct folder.

Code: [Select]
let RED_GRAPHIC = "lib\Ikareimu\img\RedShield.png";
let BLUE_GRAPHIC = "lib\Ikareimu\img\BlueShield.png";
let ShieldObj;

task CreateShield(
  yield;
  ShieldObj = Obj_Create(OBJ_EFFECT);
  Obj_SetAlpha(ShieldObj, 255);

  // GetCurrentColor is a function that gets common data.
  // RED and BLUE are variables.
  // These are defined in an #include_function so don't worry about them.
  if(GetCurrentColor == RED){
    ObjEffect_SetTexture(ShieldObj, RED_GRAPHIC);
  }
  if(GetCurrentColor == BLUE){
    ObjEffect_SetTexture(ShieldObj, BLUE_GRAPHIC);
  }

  Obj_SetCollisionToObject(ShieldObj, true);
  ObjEffect_SetRenderState(ShieldObj, ADD);
  ObjEffect_CreateVertex(ShieldObj, 4);
  ObjEffect_SetPrimitiveType(ShieldObj, PRIMITIVE_TRIANGLEFAN);
  ObjEffect_SetVertexUV(ShieldObj, 0, 1, 1);
  ObjEffect_SetVertexUV(ShieldObj, 1, 64, 1);
  ObjEffect_SetVertexUV(ShieldObj, 2, 64, 64);
  ObjEffect_SetVertexUV(ShieldObj, 3, 1, 64);
  while(!Obj_BeDeleted(ShieldObj)){
    Shield_update;
    Obj_SetPosition(ShieldObj, GetPlayerX, GetPlayerY);
    if(GetCurrentColor == RED){
      ObjEffect_SetTexture(ShieldObj, RED_GRAPHIC);
    }
    if(GetCurrentColor == BLUE){
      ObjEffect_SetTexture(ShieldObj, BLUE_GRAPHIC);
    }
    yield;
  }
}
@Initialize{
  LoadGraphic(RED_GRAPHIC);
  LoadGraphic(BLUE_GRAPHIC);
  CreateShield;
}

@MainLoop{
  yield;
}

EDIT: Nevermind, I just realized this is a terrible way to do what I wanted to do.
« Last Edit: October 29, 2009, 03:01:36 PM 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.

Re: Danmakufu Q&A/Problem Thread II
« Reply #116 on: October 29, 2009, 06:43:25 PM »
Despite your edit, I'll answer your question anyways. ObjEffect_SetVertexUV declares the vertices on your image, ObjEffect_SetVertexXY plots the corresponding vertices on to the Danmakufu field. You're missing the XY portion of an ObjEffect (you're not telling Danmakufu where to draw the image), so nothing is drawn.

Before you say "yes I am", Obj_SetPosition does not work with ObjEffects, nor does Obj_SetAlpha for that matter (to set the alpha value of an ObjEffect, you need to use ObjEffect_SetVertexColor(id, vertex, alpha, red, green, blue); ). A pain in the ass, but setting each vertex also allows you to bend and distort the image however you please. Useful when you get used to it.
« Last Edit: October 29, 2009, 09:34:32 PM by Naut »

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #117 on: October 29, 2009, 11:09:18 PM »
Despite your edit, I'll answer your question anyways. ObjEffect_SetVertexUV declares the vertices on your image, ObjEffect_SetVertexXY plots the corresponding vertices on to the Danmakufu field. You're missing the XY portion of an ObjEffect (you're not telling Danmakufu where to draw the image), so nothing is drawn.

Before you say "yes I am", Obj_SetPosition does not work with ObjEffects, nor does Obj_SetAlpha for that matter (to set the alpha value of an ObjEffect, you need to use ObjEffect_SetVertexColor(id, vertex, alpha, red, green, blue); ). A pain in the ass, but setting each vertex also allows you to bend and distort the image however you please. Useful when you get used to it.

Ah, I see. Well, hopefully I'll get it right the second time when I really need to use an effect object for something. Thanks!
<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: Danmakufu Q&A/Problem Thread II
« Reply #118 on: October 30, 2009, 01:50:30 AM »
Im such a noob....

Please help with this one. I keep getting "Bad Allocation".

Code: [Select]
#TouhouDanmakufu
#Title[Fantasy Seal Lol not]
#Text[blahblah]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
let CSD = GetCurrentScriptDirectory;

let imgBoss = CSD ~ "system\cirno.png";
let cut = CSD ~ "system\cirnocut.png";
let bg = CSD ~ "system\lake.png";

@Initialize{
SetLife(1000);
SetTimer(60);
SetScore(100000);
SetMovePosition01(GetCenterX,GetCenterY,5);
LoadGraphic(imgBoss);
LoadGraphic(cut);
LoadGraphic(bg);
shotinit;

CutIn(YOUMU,"Holy Amulet -Spread-",cut,0,0,300,384);

mainTask;
}

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

@DrawLoop{

SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,110,110);
SetGraphicScale(0.7,0.7);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);

}

@BackGround{

SetTexture(bg);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,512,512);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

}

@Finalize{
DeleteGraphic(imgBoss);
DeleteGraphic(cut);
DeleteGraphic(bg);
}


task mainTask{
wait(120);
yield;
fire;
movement;
}

task movement{
loop{
SetMovePosition01(GetCenterX-100,120,5);
wait(120);
SetMovePosition01(GetCenterX+100,120,5);
wait(120);
yield;
}

}

task fire{
let x = 0;
let dir = 0;
let dira = 0;

loop{

while(x<36){
CreateShotA(1,GetEnemyX+75*cos(dir),GetEnemyY+75*sin(dir),30);
SetShotDataA(1,0,0,dir,0,0,0,RED01);
SetShotDataA(1,60,2,dir,0.5,0,2,YELLOW01);
FireShot(1);
CreateShotA(2,GetEnemyX+75*sin(dir),GetEnemyY+75*cos(dir),30);
SetShotDataA(2,0,0,dira,0,0,0,YELLOW01);
SetShotDataA(2,60,2,dira,-0.5,0,2,RED01);
FireShot(2);

}
dir+=360/36;
dira-=360/36;
x++;

x = 0;
dir = 0;
dira = 0;
wait(60);

yield;
}
}


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

}


Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #119 on: October 30, 2009, 02:41:01 AM »
Im such a noob....

Please help with this one. I keep getting "Bad Allocation".

Your "fire" task's while loop is not exiting and became an infinite. Here's a revised version of what I believe you were trying to do.

Code: [Select]
task fire{
let x = 0;
let dir = 0;
let dira = 0;
loop{
while(x<36){
CreateShotA(1,GetEnemyX+75*cos(dir),GetEnemyY+75*sin(dir),30);
SetShotDataA(1,0,0,dir,0,0,0,RED01);
SetShotDataA(1,60,2,dir,0.5,0,2,YELLOW01);
FireShot(1);
CreateShotA(2,GetEnemyX+75*sin(dir),GetEnemyY+75*cos(dir),30);
SetShotDataA(2,0,0,dira,0,0,0,YELLOW01);
SetShotDataA(2,60,2,dira,-0.5,0,2,RED01);
FireShot(2);
dir+=360/36;
dira-=360/36;
x++;
}

x = 0;
dir = 0;
dira = 0;
wait(60);
yield;
}
}

By the way, that "bad allocation" message is bizarre. If my fix works, then I don't understand what causes it. The last time I got that message, it was because of a stupid mistake where I mixed up a function with a variable and tried to do "function = 1;"
« Last Edit: October 30, 2009, 02:44:53 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.