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

Schezo

  • en-counse
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #330 on: June 30, 2011, 06:35:47 AM »
I don't get the feeling he's using tasks.

Can you please post your entire script into a pastebin and post it for us?

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #331 on: June 30, 2011, 07:06:58 AM »
I'm looking to make bullets and lasers to wait before firing in this script:

I have no idea what you mean by this.
Also if all you looked at is my tutorial, then you are almost definitely not using tasks so don't bother with the wait function Darkness1 suggested.

Anyways, try to describe what you're trying to accomplish a little better. Did you want the bullets and lasers to be delayed for120 frames? Did you want to shoot bulletss first, wait 120 frames, and then fire lasers (or vice versa?)? Did you want your AddShot bullets to be added 120 frames later?
<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.

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #332 on: June 30, 2011, 08:23:57 AM »
Some things I wanted to ask:


1,. No matter what I do, the Spell Score is always higher than the one I specified (say, I put 150000 and it starts aat 300000), does it multiply the score or something?

2.-  The next script has no problem, but I wanted to get feedback about the scripting method(I know, not the thread to, but didn't want to open a thread just for this) http://pastebin.com/ASvXf1z7
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #333 on: June 30, 2011, 09:09:01 AM »
1,. No matter what I do, the Spell Score is always higher than the one I specified (say, I put 150000 and it starts aat 300000), does it multiply the score or something?
Danmakufu's spellcard scoring system is bizarre. I do know that if you disable the rating system, the initial spellcard score in game will be 3x what you put in the script for some reason. I don't really know any good way to work around this besides making your own spellcard system...

Quote
2.-  The next script has no problem, but I wanted to get feedback about the scripting method(I know, not the thread to, but didn't want to open a thread just for this) http://pastebin.com/ASvXf1z7
You want someone to yell at you for scripting stupidly? SOUNDS LIKE A PLAN! Honestly speaking though, it's not too bad. The fact that you have comments really helps with readability. The following points are just opinions -- don't take em as an absolute truth or anything:

1.) So yeah, first point, fix your tabbing. It's not hard to follow the code right now because it's relatively simple and there's a good amount of comments, but when it gets more complex, properly tabbed code makes a huge difference in how easy it is to understand or debug. Here's a Wikipedia article on indent styles. Most people use some variation of the first example, but what really matters is keeping your tabbing style consistent.


2.) I think you need better names for your variables at the top. Make it more easily identifiable what each thing is. For example, it's obvious that ImgBoss is an image because it's prefixed with Img. However, something like Cut is really vague. The last thing I would expect it to be is a cut-in, honestly, if none of your stuff was commented. These two lines are especially bizarre:

let Layer2 = CSD ~ "\Pic\JackBG1.png";
let BG = CSD ~ "\Pic\JackBG2.png";


Why didn't you just name the variables BG1 and BG2? Basically, like my opinion on tabbing, I think you need a more consistent and less ambiguous naming scheme for your variables.


3.) Your handling of the timer sound is really inefficient. If you decide to change the timer of the spell, you'd have to redefine all the conditionals. Why aren't you using GetTimer?


4.) Your mainTask is doing nothing except calling your fire task. Unless you're planning to add more stuff to the mainTask, this is entirely pointless and you should just call the fire task directly.


5.) Your fire task can be simplified greatly with a loop, specifically an ascent. Also you don't really need to use 4 different ids for the bullets. Here's my revised version that should behave exactly the same:
Code: [Select]
ascent(i in 0..4){
    CreateShotA(1,GetEnemyX,GetEnemyY,10);
    SetShotDataA(1,0,1,dir+i*90,0,0,1,24+i);
    SetShotDataA(1,60,0,dir+i*90,0,0,1,24+i);
    SetShotDataA(1,210,1,dir+i*90,0,0,1,24+i);
    SetShotDataA(1,270,0,dir+i*90,0,0,1,24+i);
    SetShotDataA(1,440,1.5,rand(0,360),0,0,1,9+i);
    FireShot(1);
}
Also, I changed rand(0,359) to rand(0, 360). I suppose it doesn't really make too big a difference, but technically you were missing 1 whole degree between 359 and 360 :V


6.) At the very end of your fire task, you have both a wait(1); and a yield; . wait(1) is the same thing as a yield so you're actually yielding twice. This is causing the boss to run that loop once every other frame instead of every frame. If that was your intention, you should probably use wait(2); instead of one wait(1); and one yield;


That's all I can find that bugged me about your scripting style. Honestly though, if you don't plan on collaborating, none of this really matters. All my tips are just to improve readability. If you're going to be writing everything yourself and not sharing it, as long as you can remember what you were doing, it's not really necessary to write clean code. Unless you're making something huge. :derp:
<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: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #334 on: June 30, 2011, 01:25:42 PM »
I know, the script is a hot mess...I tried using task fire{ }, but the bullets just stopped firing (I'm undoubtedly doing something wrong). I know how to make the bullets delay firing, but the problem I'm having is that the bullets are just perpetually firing instead of say, one bullet every ten frames, so instead of a stream of butterflies, I get an unmoving streak of them. I have this same problem with any other type of bullet too. As for the lasers, they are just firing randomly as well, but I'd really like them to wait, fire, wait, fire, etc...

http://pastebin.com/KVNTQYfW

I'm really sorry for my naivete and I hope I can improve to the point where I'm not making stupid mistakes all the time...
Thanks again.

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #335 on: June 30, 2011, 03:49:47 PM »
I know, the script is a hot mess...I tried using task fire{ }, but the bullets just stopped firing (I'm undoubtedly doing something wrong). I know how to make the bullets delay firing, but the problem I'm having is that the bullets are just perpetually firing instead of say, one bullet every ten frames, so instead of a stream of butterflies, I get an unmoving streak of them. I have this same problem with any other type of bullet too. As for the lasers, they are just firing randomly as well, but I'd really like them to wait, fire, wait, fire, etc...

http://pastebin.com/KVNTQYfW

I'm really sorry for my naivete and I hope I can improve to the point where I'm not making stupid mistakes all the time...
Thanks again.

You must have an endless loop in the task for the bullets to never stop spawning. Like this:
Code: [Select]
task fire{

//stuff that's not supposed to loop, like let frame, let angle etc.

loop{

//stuff that's supposed to loop, like bullets firing.

//wait function after the action so it doesn't endlessly create bullets.
//The loop/task must contain atleast one yield/wait.
//Also remember to put a yield in maintask.
}
}

If you code in mainloop, you have to use frame/counter statements:
Code: [Select]
let frame = 0;

@MainLoop{

frame++;

if(frame==60){

//Fire bullets and do stuff after 60 frames.
//Then, after it's been done, reset the counter so it can count up to 60 again.

frame = 0;
}


EDIT: Oh, sorry. Misspelled.
« Last Edit: June 30, 2011, 04:47:12 PM by Darkness1 »

Fetch()tirade

  • serial time-waster
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #336 on: June 30, 2011, 04:20:50 PM »
You must have an endless loop in the task for the bullets to never stop spawning. Like this:

If you code in maintask, you have to use frame/counter statements:


Not to be picky, but there is a difference between maintask; and @MainLoop.

- Maintask; is a task that controls whatever is designated to it and is a product of the tutorials. It is not an essential part of the script, but it does help organize things a bit. It does not loop unless a loop(){} is put in it. A yield; or wait(); is not necessary unless there is a loop inside it.

Like this:
Code: [Select]
task maintask1{
stuff; // another task
}

task stuff{
loop{
ShootDownPlayer; // :P
wait(60);
}
}

Or this:
Code: [Select]
task maintask2{
loop{
destroyeverything; // another task
wait(120); // 2 second break
}
}

The @MainLoop is a loop that is integrated into the script and must always be there. As you said above, in order to implement this section of the script properly, you must use a variable and counter statements. If you are not going to be using the @MainLoop to script the actions, then you must leave a yield; in it. If there are no tasks in your script, then you do not need to add a yield; since it loops after one frame regardless. (However, leaving one in there does not affect the script in the slightest.)

It is possible to use both tasks and the @MainLoop to script: create the counter statements you want in the @MainLoop, integrate whatever tasks you want into those statements, and then drop a yield; at the beginning or end of the loop. Leaving out the yield; will make the script NOT check for any tasks outside of the @MainLoop.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #337 on: June 30, 2011, 06:06:32 PM »
You two didn't even look at his pastebin.  :wat:

ByakuganAce, I explained the concept of variables and control statements here. A little later, I show how to use them here to make bullets fire less often.
<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: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #338 on: June 30, 2011, 06:23:33 PM »
Yeah, I'm rather new to Danmakufu as well, though I have some prior experience with programming. (Python, I keep typing "rand_int" as "rand.int" >.>) Anyway, I was fiddling around with my first simple spellcard, and I wanted to try out Helepolis's custom cut-in script I saw the link to in the information thread. And I haven't been able to get it to work for some reason. There's no error message, there's just simply no cut-in at all, and it acts like a non-spell, except that it gives a spell bonus at the end when it does normally because of "SetScore".

The "function_cutin.txt" file is in the script folder ("tutorial"), and the spellcard picture is in a "system" folder inside the "tutorial" folder. I've put the relevant part of my script (up to the end of @Initialize) here: http://pastebin.com/wi2PQjmr, though I suspect that it has something to do with where I placed the function and picture files. In accordance to the readme, I extracted the .zip to the scripting directory ("tutorial"), but I think that something might be up there, as everything else seems to be in order. (Yes, the cut picture is in the proper place. Using the regular 'CutIn' works, by the way.)

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #339 on: June 30, 2011, 06:47:41 PM »
there's just simply no cut-in at all
You obviously didn't load the graphic with LoadGraphic before you declared the cutin function.

LOAD IT LIKE THIS DRYER.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #340 on: June 30, 2011, 07:06:55 PM »
You obviously didn't load the graphic with LoadGraphic before you declared the cutin function.

LOAD IT LIKE THIS DRYER.
Code: [Select]
   
                LoadGraphic(cut);
                LoadGraphic(bg);
                shotinit;
                cutin("NAZRIN","River Sign"\""Rippling Waves"\",cut,0,0,256,512);
It's in the pastebin I posted. Doesn't work. As I noted above, works perfectly with the regular 'CutIn' function when it's placed in the same spot, with only the first parameter changed.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #341 on: June 30, 2011, 07:13:07 PM »

It's in the pastebin I posted. Doesn't work. As I noted above, works perfectly with the regular 'CutIn' function when it's placed in the same spot, with only the first parameter changed.

let CSD = GetCurrentScriptDirectory;
let cut = CSD ~ "\system\face03ct.png";

cut = "script\tutorial\\system\face03ct.png"

Duh.



Quick note: the default CutIn function does not need to have loaded the cut graphic used in order to display it.
For custom cutin functions however you do have to load your graphics.
« Last Edit: June 30, 2011, 07:15:15 PM by Mewkkyuuri »

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #342 on: June 30, 2011, 08:09:12 PM »
Oh. Duh indeed. Weird how I did the same thing for the sprite and the background yet those still worked...

What the heck...it still doesn't work...

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #343 on: June 30, 2011, 08:45:39 PM »
Thank you for all of the help! I got the wait function to work, but the loop function causes my computer to freeze with the sprite about halfway through its descent.
http://pastebin.com/y2XM8FcE
Can anything be done to stop this?

Fetch()tirade

  • serial time-waster
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #344 on: June 30, 2011, 09:21:54 PM »
Code: [Select]
task fire{
loop{
CreateShotA(1, GetCenterX, GetCenterY-90, 10);
SetShotDataA(1, 0, 5, 0, 1.9, 0, 5, RED22);
ascent(i in 1..2){
CreateShotA(2, 0, 0, 10);
SetShotDataA_XY(2, 0, rand(-1, 1), rand(-1, 1), 0, 0.1, 0, 1, PURPLE31);
AddShot(i*0, 1, 2, 0);
i++; 
}
FireShot(1);
}
wait(60);
yield;
 
loop{
CreateLaserB(3, 800, 12, BLUE01, 130);
SetLaserDataB(3, 0, 0, 0, 0, rand(0, 360), 0, rand(0, 360), 0);
SetShotKillTime(3, 190);
       
FireShot(3);
 
}
wait(300);
yield;
}

(I have only changed the tabbing for readability purposes.)

Both of the loops have the waits/yields placed outside of them. Move them inside and it should work.
Also, just a little note: a wait(x) is an x number of yields, so you don't need the extra yield after a wait (unless you want to have x+1 number of yields).

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #345 on: June 30, 2011, 10:09:15 PM »
loop{} loops infinitely. Even if the yield/wait was moved inside them, it would never exit the first loop and the rest of the code would never be read. You're probably looking for loop(number) which loops number amount of times, or while(something) which loops while "something" is true (like while(GetLife>1000), for example).

Fetch()tirade

  • serial time-waster
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #346 on: June 30, 2011, 10:42:40 PM »
Or if you want both of them to run simultaneously, you can break the task into two.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #347 on: June 30, 2011, 10:46:09 PM »
So to break the task in two, I could just make another task fire function and name it somethiing like task fire2 and then in task mainTask, have fire2 after fire?

CK Crash

  • boozer
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #348 on: June 30, 2011, 11:47:48 PM »
Code: [Select]
@Initialize
{
mainTask;
}

task mainTask
{
Wait(120);
Fire1;  //You can put a pause between Fire1 and Fire2 if you want for some reason
Fire2;
}

task Fire1
{
loop{yield;}
}

task Fire2
{
loop{yield;}
}

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #349 on: July 01, 2011, 01:08:00 AM »
BRILLIANT!!! Thank you guys so much! I appreciate all of the help with this...I feel like I'm well on my way now :D

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #350 on: July 01, 2011, 12:45:24 PM »
I'm a complete noob at danmakufu and don't hurt me.
But.
Is there a tutorial on how to do bullet patterns like spirals and crud?
because all i can manage is erm...
singular bullets

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #351 on: July 01, 2011, 02:13:18 PM »
Look at this if you can handle straight bullets well already.

Look for the "tasks" part, especially. Once you understand that, it's all about geometry.

In particular you have several choices for a spiral :
   - Control angle for a bullet at a constant speed, by decreasing angular speed (each frame, add w to the angle, then reduce w a little);
   - Directly control the x and y coordinates by setting them to x=x0+R*t*cos(t*w) and y=y0+R*t*sin(t*w) with any value you like for those variables, increasing t each frame. (Note that if t increases linearly, the speed also does, you might prefer something like t=t+1/(t+1)...)
« Last Edit: July 01, 2011, 02:15:49 PM by Ginko »

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #352 on: July 02, 2011, 11:44:55 AM »
How do you make a bullet move in a circle around the boss at a given radius? I know that you're supposed to increase it's angle every frame by an amount depending on how long it will take for the bullet to complete a circle, but I don't know how to calculate how long it takes.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #353 on: July 02, 2011, 04:11:38 PM »
The way I prefer to do things is update the X and Y positions every frame using a formula based on time. For example:

X = CenterX + A*cos(6/b*frame+offset)
Y = CenterY + A*sin(6/b*frame+offset)

In this case, CenterX and Y will be GetX and GetY if you want them to move around the boss
A will be the radius of the circle in pixels
b will be the number of seconds to complete a rotation (you can also just use b*frame instead and calculate the revolution speed by finding the value frame needs to be so that b*frame = 360 and remembering that there are ~60 frames to a second)
offset is used if you want to make multiple bullets starting at different locations in the circle. If you want 4 evenly spaced bullets spawn one with offset 0, then 90, 180, and 270

« Last Edit: July 02, 2011, 08:42:42 PM by BajaBlood »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #354 on: July 02, 2011, 05:48:06 PM »
A simple object bullet for it too: http://pastebin.com/7shMFh77

A negative or positive value for speed determines the rotation direction.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #355 on: July 03, 2011, 10:32:52 AM »
Hi, I was wondering if it was possible at all to implement a database of high scores?
I've been considering using Danmakufu as the coding language for my senior computer studies project, but a necessary feature is a high scores database.

Is it possible at all to write to a .txt file? I was thinking the final score would be written on a new line and then to display the top 10 scores, coding would find all the scores in the file, put them in descending order and then display the top 10.
Or is it possible to link in an SQL database (although I doubt this would be possible).

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #356 on: July 03, 2011, 12:29:25 PM »
Is there anyway to  draw more than one graphic at once? I have a boss sprite, but I also would like to add in a sprite of an eye opening. The other problem is that I don't want this eye to have a hitbox...I tried simply placing it in the DrawLoop with braces around it and loading it as such, but it didn't seem to work. Creating multiple "task Draw"s has been unsuccessful as well. I would also like for this eye to go through the opening animation after 120 frames. Script is here: http://pastebin.com/0gQQE7mv

Any help is appreciated! Hope I'm not missing something obvious >.>

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #357 on: July 03, 2011, 01:02:23 PM »
Uh ? You don't even seem to try to draw anything else in the script you pasted ... ?

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #358 on: July 03, 2011, 01:14:44 PM »
Yes I did (at least I think so)...it's right in draw loop. I don't have the script for drawing in the eye, but that just because I can't figure it out. The sprite I'm using appears fine, but I just don't have the knowledge to draw in another graphic at the same time :/

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #359 on: July 03, 2011, 01:53:19 PM »
You could use effect objects, if you have the time to learn about it. If you're doing advanced programming for the graphic, you may think it's easier to use, even though it's harder to draw. Then you could just use:
Code: [Select]
while(!Obj_BeDeleted(EYE)){

wait(120);

//Animation coding.

Obj_Delete(EYE); // If you want to create it, delete it and later respawn the graphic.
}
« Last Edit: July 03, 2011, 01:57:32 PM by Darkness1 »