Author Topic: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m [Closed, read last post!]  (Read 185505 times)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #150 on: July 25, 2013, 03:44:44 PM »
You mean the bullets from all sides code you asked page or 2 ago? Yes, correct. You could use that and use a randomized offset to spawn at different heights/locations as it seems Flandre does the same.

For the bubble and round bullets you'll need to use Obj_SetCollisionToObject(obj,true); to perform collision checking then use Collision_Obj_Obj   ( http://dmf.shrinemaiden.org/wiki/Mathematical_or_Information_Functions_%280.12m%29#Collision_Obj_Obj ) to perform the behaviour.

Something I myself haven't used it yet.

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #151 on: July 25, 2013, 04:51:37 PM »
The tactic I used for Obj_Collision with two types of bullets is to first create an object array for one type (a global one): let objarr = [];
Then in 1 of the object bullets you add each spawned bullet to the array, for example:
Code: [Select]
     task FireBullet(speed,angle){
     ID1 = Obj_Create(OBJ_SHOT);
     objarr = objarr~[ID1];   //Add the object to the global array.
Then at the end of the same obj bullet (after the while(!Obj_BeDeleted(ID1)) of the bullets last bracket):
Code: [Select]
    ascent(i in 0..length(objarr)){ //Go through all objects and remove self
        if(objarr[i] == ID1){
objarr = erase(objarr,i);
break;
}
        }
To delete the bullet from the array when it is deleted from the gamescreen to avoid getting infinite items in the array.
In both obj bullets used, set them to have obj collision, for example:
Code: [Select]
Obj_SetCollisionToObject(ID1,true);
Obj_SetCollisionToObject(ID2,true);
In each respective obj bullet task.

Then simply, in the task of the bullet type which isn't in the array;
Code: [Select]
     while(!Obj_BeDeleted(ID2)){
   
     ascent(i in 0..length(objarr)){ //Go through all objects
     if(Collision_Obj_Obj(ID2,objarr[i])){
     //do stuff on collision.
     }}

    }
Done!
(Note: tutorial is pretty much taken from OnTheNet. The whole script I made using this tactic: http://pastebin.com/UP6SrKjX)

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #152 on: July 25, 2013, 07:32:33 PM »
The tactic I used for Obj_Collision with two types of bullets is to first create an object array for one type (a global one): let objarr = [];
Then in 1 of the object bullets you add each spawned bullet to the array, for example:

Done!
(Note: tutorial is pretty much taken from OnTheNet. The whole script I made using this tactic: http://pastebin.com/UP6SrKjX)

Uh, it's not working. This is what google translates the error to.
Quote
An attempt was made to use a variable that once do not even assignment (line 2660)
Code: [Select]
let objarr = objarr~[ID1];

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #153 on: July 25, 2013, 09:20:51 PM »
Code: [Select]
let objarr = objarr~[ID1];
Why are you using let?
I don't think that's possible, since ~["item"] is just a way to add an item to the array pool.

Basics of arrays can be read at the tutorial:
http://dmf.shrinemaiden.org/wiki/Danmakufu_Basics_Tutorial

But, Drake is right. Obj_collision can be used for some stuff, but in this case, it is kind of unnecessary and it will probably be alot simpler to do it by distance and set the bullet angles from the way everything is set up. (Not saying my version is that good either, it's just the first one I got to work properly with bullet collision and everything.)
« Last Edit: July 26, 2013, 09:38:16 AM by Darkness1 »

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #154 on: July 25, 2013, 09:21:04 PM »
You didn't instantiate the variable beforehand. How are you supposed to append [ID1] to objarr if objarr doesn't exist? EDIT: Darkness: not a function

also this method is super gross and nasty

One important thing is that Kagome Kagome doesn't actually perform any object collision. All it does is keep note of the angle and position the bubbles are fired at, and then the individual bullets start moving if they're somewhat in line with that, after a certain amount of time dependent on how far the bullets are from Flandre.

This is also how I would recommend scripting this behaviour. Explicit object collision isn't necessarily needed.
« Last Edit: July 25, 2013, 09:25:52 PM by Drake »

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

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #155 on: July 25, 2013, 09:33:47 PM »
Why are you using let?
I don't think that's possible, since ~["item"] is just a function to add the item to the array pool.

If I didn't put "let" in then Danmakufu would bring up another error.

One important thing is that Kagome Kagome doesn't actually perform any object collision. All it does is keep note of the angle and position the bubbles are fired at, and then the individual bullets start moving if they're somewhat in line with that, after a certain amount of time dependent on how far the bullets are from Flandre.

This is also how I would recommend scripting this behaviour. Explicit object collision isn't necessarily needed.

So create shot objects and then set their speed and angle to the bubble and fire the bubble? This is a bit confusing.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #156 on: July 25, 2013, 11:41:04 PM »
You have to define objarr before you start adding things to it.

I think the problem here is that you're trying to create patterns above your level of know-how. I might be able to tell you precisely how to get my suggestion working, but that won't do you any good. It's basically fixing your bubble bullet angles beforehand, then setting up all of your movable bullets as CreateShotA bullets that only have a second SetShotData to move them if the spawn position is in line with the preset angle. The time to set the bullet to move just depends on how "close" the bullet is to the boss when firing. This way, nothing actually depends on the bubble being fired. You don't even need to fire the bubble, it's just good timing that makes the bullets move. If you don't get what I mean, then it's probably best if you didn't bother. But in my opinion it's much easier and cleaner than messing around with bullet arrays and object collision.
« Last Edit: July 25, 2013, 11:42:58 PM by Drake »

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

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #157 on: July 26, 2013, 02:38:10 AM »
Yeah, I'll just take your advice and wait until I get better.

Uzumaki_tenma

  • JAOOOOOOOOO!!!!!!!
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #158 on: July 27, 2013, 03:04:13 AM »
I have a question, I saw in some scripts about the "History" function (like Icicle Fall  (0/1) ), how can I put this function in the spellcards? I mean, I checked other scripts but those don't have info script (or is in an unknown script file contrary to .txt or .dnh)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #159 on: July 27, 2013, 08:42:47 AM »
I have a question, I saw in some scripts about the "History" function (like Icicle Fall  (0/1) ), how can I put this function in the spellcards? I mean, I checked other scripts but those don't have info script (or is in an unknown script file contrary to .txt or .dnh)
0.12m has no such function, so you'll need to implement your own spell card history tracker using CommonData and saving CommonData so the next time you start the card/game, you can keep note of it.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #160 on: July 27, 2013, 09:49:09 PM »
Anyone know how I would make a web of lasers like what Remilia and Eirin do?

The Noodles Guy

  • Flip the screen
  • What if Seija met a guy with bipolar disease?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #161 on: July 27, 2013, 10:06:18 PM »
Anyone know how I would make a web of lasers like what Remilia and Eirin do?
CreateLaserA.

Read the Danmakufu Basics Tutorial to find more about that function
Easy Modo? That's for kids, and for me.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #162 on: July 28, 2013, 01:46:10 PM »
How do I find out how large each sprite is in an file with multiple sprites?

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #163 on: July 28, 2013, 01:52:14 PM »
Doesn't it tell you if you right-click it and show the properties, or open it with paint.
Unless you're talking about something entirely different.
Currently a normal player

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #164 on: July 28, 2013, 02:17:19 PM »
Guess I formulated my question wrong. 
How do I find out the coordinates of each sprite(to use with SetGraphicRect) in one image file if it has multiple sprites?
Can I do this by simply taking the length and width of the full file and dividing?

If the whole file is 256X256 pixels, and there are four sprites horizontally, and three rows vertically like this:
a b c d
e f g h
i  j  k  l

If I want to know the coordinates for sprite b, are they equal to 256/4, 0, 256/4+256/4 and 256/3?

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #165 on: July 28, 2013, 02:39:50 PM »
If I remember it correctly, it should be left, top, right, bottom.
That said, I would use this:
Left: ([256/4]*Order in Row)-128
Top: ([256/3]*Order in Column)-128
Right: ([256/4]*Order in Row)
Bottom: ([256/3]*Order in Column)
This should work. Although 256/3 is 85.3... pixels. Which doesn't make sense.
Unless this isn't the real image size and just an example.
« Last Edit: July 28, 2013, 02:43:02 PM by Lavalake »
Currently a normal player

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #166 on: July 28, 2013, 07:22:44 PM »
I believe you can find that out by dividing the length and width by the number of columns and rows respectively--the result will be the individual dimensions of each sprite. Going by your example, if the whole file is 256x256 pixels and there are three rows and four columns, then: 256 / 4 = 64 and 256 / 3 = 85.33. That said, the rect coordinates for sprite "b" would be 64, 0, 128, 85.3. As you can see, you simply have to multiply the values by an increasing factor according to where the sprite you want is located. Hope that helps~

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #167 on: July 28, 2013, 10:57:25 PM »
How do you make a rotating angle move faster than 1?
I've been using Angle++;, but it only increases 1 at a time.
Is there a way to make it move faster?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #168 on: July 28, 2013, 11:18:44 PM »
How do you make a rotating angle move faster than 1?
I've been using Angle++;, but it only increases 1 at a time.
Is there a way to make it move faster?

Angle+=2; will make angle increase by increments of 2.
Angle+=1.5; will make angle increase by increments of 1.5, etc.

Please refer to the tutorials.

https://sites.google.com/site/sparensdanmakufututorials/danmakufu-0-12m-tutorials/003-introduction-to-danmakufu#TOC-003-07:-Variables-Booleans-and-Math
http://dmf.shrinemaiden.org/wiki/Danmakufu_Basics_Tutorial
« Last Edit: July 28, 2013, 11:20:29 PM by Sparen »

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #169 on: July 28, 2013, 11:51:43 PM »
Thank you! :D

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #170 on: July 29, 2013, 02:05:17 PM »
How are backgrounds made in nonspells?
@BackGround only works in spellcards, and #Background didn't work in my script.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #171 on: July 29, 2013, 02:14:38 PM »
How are backgrounds made in nonspells?
@BackGround only works in spellcards, and #Background didn't work in my script.
Correct, you don't have backgrounds in nonspells unless you alter the default ones or fiddle around with effect objects. If you want backgrounds in non-spells you can script an empty stage and use the @Background routine in there.

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #172 on: July 30, 2013, 05:45:29 AM »
I think I've asked this question before but was never answered.
Basically, I want to fire a fast bullet every frame. They all go in the same direction.
Then, I want the stream to turn to the right one pixel every frame. This lasts for 45 frames for 45 pixels to the right.
Then it moves to the left for 90 frames. Finally it moves to the right for another 45 frames.
This procedure repeats forever.
By stream of bullets, I mean like this.
http://youtu.be/MAMMVsi89yg?t=4m8s
My question is, how do
I make the turning around part smooth.
Currently a normal player

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #173 on: July 30, 2013, 06:11:03 AM »
You can use a sine wave to achieve the degree of smoothness you are looking for. You have to define the stream's angle as a variable which first holds a base--that is, the direction you want the stream to start from--add an amplitude to it (this would be 45), and multiply it by the sine of a counter variable which should be increased every frame. How fast the motion is performed can be controlled by multiplying the counter variable: a frequency. This explanation is a bit messy, but this code should illustrate it:

Code: [Select]
loop{
    let tiltAngle = angle+45*sin(count*freq);
    <Bullet Code>
    count++;
    yield;
}

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #174 on: July 30, 2013, 06:42:10 AM »
I read through your message and drew a blank.
Here's the important part of my script.
Code: [Select]
if(Obj_GetSpeed(objoption)<0.01){
BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir2,71);
BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir2+45,71);
BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir2+90,71);
BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir2-45,71);
BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir2-90,71);
}
if(count<45){ dir2++; }
if(count>=45 && count<135){ dir2--; }
if(count>=135 && count<180){ dir2++; }
if(count>=180){ count=0; }
count++;
The bullets are fired from an object right when it slows down.
Currently a normal player

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #175 on: July 30, 2013, 07:19:20 AM »
Oh, then you just have to implement the sine wave when the condition is evaluated as true. Assuming you have an Obj_BeDeleted while loop, then:

Code: [Select]
if(Obj_GetSpeed(objoption)<0.01){
    let dir = angle+45*sin(count*freq);
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir,71);
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir+45,71);
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir+90,71);
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir-45,71);
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir-90,71);
    count++;
}

When the condition is evaluated as true, "count" will increase by 1 every frame and allow for the bullets' trajectories to smoothly accelerate and decelerate back and forth between the bounds of your amplitude. In this case, since you want for it to move 45 degrees towards each side, said amplitude will be 45. You can change "angle" to anywhere you want for the bullets to begin aiming at. Also, I recommend first testing the generated pattern by firing them from the enemy to begin with, if you still feel confused about how this is supposed to work.

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #176 on: July 30, 2013, 10:29:51 AM »
Ah. I get it. I just started playing around with the function.
Thanks for the help.
Currently a normal player

fondue

  • excuse me
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #177 on: July 30, 2013, 01:11:26 PM »
Just do this:
Code: [Select]
if(Obj_GetSpeed(objoption)<0.01){
    let dir = angle+45*sin(count*freq);
ascent(i in -2..2){
    BulletA(Obj_GetX(objoption),Obj_GetY(objoption),6,dir+(45*i),71);
}
    count++;
}

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #178 on: July 30, 2013, 05:07:42 PM »
I am making a spellcard with Shikieiki's laser attack. (one large laser aimed at the player, and two "wings" made up of four lasers about 70-90 degrees from the angle to the player)
I want the lasers to the side to move towards the large purple laser, and when they're close, having the lasers on the side of the player disappear, and the other lasers continue, forcing the player to move around the screen. (Shikieiki is positioned at the center of the screen.)

To accomplish this, I made a global variable called playerangle, which is set to GetAngleToPlayer everytime the purple laser is fired (the purple lasers and those to the side are in separate tasks), and then I compare it to GetAngleToPlayer inside mainloop. If it is larger/smaller, two other global variables are changed which are placed inside the SetShotKillTime's of the task of the "wings"

I have 2 problems however:
1. Sometimes the wrong set of lasers disappears (and I don't know why).
2. There will probably be a problem if the player faces to the right because of angles.

I think I remember some kind of function to change how angles are calculated on the Danmakufu wiki, but I can't remember where.
Does anybody know how to solve this?

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #179 on: July 31, 2013, 04:04:34 AM »
I have an attack that's not working the way I want it and it's kinda confusing why it's not.

Code: [Select]
   
CreateShotA(1,GetX,GetY,30);
SetShotDataA(1,0,2,0,0,0,1,60);
SetShotDataA(1,60,5,GetAngleToPlayer,0,0,0,60);
FireShot(1);

Now this should shoot a bullet to the right and after 60 frames turn towards the player, but instead it turns down or at an angle nowhere near the player.