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

Re: Danmakufu Q&A/Problem Thread
« Reply #990 on: October 19, 2009, 08:49:58 PM »
Quote from: PT8Sceptile link=topic=296
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:

I added the task, but then i noticed there was spawning only 1 bullet (Although it probably was spawning all of them in the same position), so i studied your code and noticed you were using the variable angle, which i already had defined earlier for something else, and since that variable isnt moving at all, then the bullets would spawn all at the same angle, so i changed angle with ang (as in the values it receives from when i call this task) and it worked.

Now on to test the bullet part...
EDIT1:
Code: [Select]
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);

<same code>
        CreateShotA(1,GetX,GetY,10);
SetShotDataA(1,0,1,GetAngleToPlayer,0,0.4,12,120);
// SetShotDataA(1,0,1,GetAngleToPlayer,0,0.4,12,BLUE03);
ascent(i in 1..60){
<same code>
Ok i edited this now i get this problem:

And if i click on Ok, it loads all other bullets normally but wont load the anchor, and just is like there wasnt any bullet there

EDIT3:  Nevermind i managed to fix the ghostly glow, the delay was too high, that's why,
here's how it ended up

EDIT6: Ok i managed to do it, not as pretty as the original but is something
« Last Edit: October 20, 2009, 05:47:26 AM by Sakura665 »

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread
« Reply #991 on: October 20, 2009, 06:01:20 AM »
Is there any way to make an object bullet not give any graze points, or any workaround to get this effect?

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #992 on: October 20, 2009, 08:24:50 AM »
Quote
Is there any way to make an object bullet not give any graze points, or any workaround to get this effect?

There is no way to prevent the graze from registering. To undo it, have the bullet continually check it's distance from the player, and do a AddGraze(-1) when it detects it is in graze range. Note that you will need to somehow find out the exact range at which graze is counted, and make sure it only checks for this once per bullet.

It's a pain in the ass, yeah.

Also just a heads up, when this hits 1000 posts and I'm not around, someone start a new thread since I'm gonna lock this one. (Actually, I think it might happen automatically. I have no idea. How exciting!)
« Last Edit: October 20, 2009, 08:40:50 AM by Stuffman »

PT8Sceptile

  • All hail Giant Catfish!
Re: Danmakufu Q&A/Problem Thread
« Reply #993 on: October 20, 2009, 08:44:37 AM »
I added the task, but then i noticed there was spawning only 1 bullet (Although it probably was spawning all of them in the same position), so i studied your code and noticed you were using the variable angle, which i already had defined earlier for something else, and since that variable isnt moving at all, then the bullets would spawn all at the same angle, so i changed angle with ang (as in the values it receives from when i call this task) and it worked.

And yet again, whenever I forget to check the code I write, a typo manages to sneak in. Yes, the angle was supposed to be replaced by ang, but I forgot to do that when hastily writing that down.

Okay, for the anchor part, I think I figured the problem out. For some mysterious reason, if you reference GetCurrentScriptDirectory in the ShotImage definition, that error seemingly gets thrown. Try replacing this:
Code: [Select]
ShotImage = GetCurrentScriptDirectory~"system\anchor.png"with:
Code: [Select]
ShotImage = ".\system\anchor.png"It should mean the exact same thing but not throw errors this time. If that doesn't work, then I'm as confused as you are.

Also, you probably have to edit the rect value of the bullet definition script. Your script indicates the anchor is contained in the upper left square of the image and is 32 pixels wide and tall. That's a pretty small anchor for Murasa, if you ask me. The rect variable should be changed to surround the anchor the same way as you're surrounding the boss's sprite in the main script's DrawLoop using SetGraphicRect. Also, if you don't want the anchor to rotate, change angular_velocity in the bullet definition file to 0.

And...

Is there any way to make an object bullet not give any graze points, or any workaround to get this effect?

You could remove collision detection with the player using Obj_SetCollisionToPlayer(objectname, false); (it stops the bullet from killing the player and giving the player any graze) and manually check the collision with player (as long as the bullet is alive, run the following every frame: if player is within a certain radius from the location of the bullet and GetTimeOfPlayerInvincibility == 0, call ShootDownPlayer). Or at least that's the best idea I can think of.

Re: Danmakufu Q&A/Problem Thread
« Reply #994 on: October 20, 2009, 03:49:35 PM »
Is there any way to make an object bullet not give any graze points, or any workaround to get this effect?
You could remove collision detection with the player using Obj_SetCollisionToPlayer(objectname, false); (it stops the bullet from killing the player and giving the player any graze) and manually check the collision with player (as long as the bullet is alive, run the following every frame: if player is within a certain radius from the location of the bullet and GetTimeOfPlayerInvincibility == 0, call ShootDownPlayer). Or at least that's the best idea I can think of.

This is correct, but how do you plan to get whether or not the player is within a certain radius? Got a function for this? I would just use:

if(GetPlayerX <= Obj_GetX(obj) + (right bound graphic rect of the bullet / 2) && GetPlayerX >= Obj_GetX(obj) - (left bound graphic rect of the bullet / 2) && GetPlayerY <= Obj_GetY(obj) + (lower bound graphic rect of bullet / 2) && GetPlayerY >= Obj_GetY(obj) - (upper bound graphic rect of the bullet /2) && GetTimeOfPlayerInvincibility==0){
   ShootDownPlayer;
}

Square hitbox, I know, but I don't know how to detect collision within a radius outside of ObjSpell's.

Re: Danmakufu Q&A/Problem Thread
« Reply #995 on: October 20, 2009, 05:25:53 PM »
After posting my question about recreating Cirno's Diamond Blizzard and what else I'd need to know to make it a success, I started messing around with what I already know, and I think I've got something pretty close.

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;
let movecount = -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) {
let leftright = rand(-100, 100);
let updown = rand(-50, 50);
loop(10) {
CreateShot01(GetX+leftright, GetY+updown, rand(0.5, 4), rand(0, 359), AQUA23, 20);
    }
frame = 0;
}
if(movecount == 120) {
SetMovePositionRandom01(50,20,5,GetClipMinX()+100,30,GetClipMaxX()-100,100);
movecount = 0;
}
frame++;
movecount++;
    }

    @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);
    }
}

Now my question is, how can I clean this up so that it looks like the one from Embodiment of Scarlet Devil? Obviously, I need to figure out how to make a Cirno boss sprite so that it's not Rumia firing things, but what else could I change to make it a better match?

Re: Danmakufu Q&A/Problem Thread
« Reply #996 on: October 20, 2009, 05:30:47 PM »

Okay, for the anchor part, I think I figured the problem out. For some mysterious reason, if you reference GetCurrentScriptDirectory in the ShotImage definition, that error seemingly gets thrown. Try replacing this:
Code: [Select]
ShotImage = GetCurrentScriptDirectory~"system\anchor.png"with:
Code: [Select]
ShotImage = ".\system\anchor.png"It should mean the exact same thing but not throw errors this time. If that doesn't work, then I'm as confused as you are.

Also, you probably have to edit the rect value of the bullet definition script. Your script indicates the anchor is contained in the upper left square of the image and is 32 pixels wide and tall. That's a pretty small anchor for Murasa, if you ask me. The rect variable should be changed to surround the anchor the same way as you're surrounding the boss's sprite in the main script's DrawLoop using SetGraphicRect. Also, if you don't want the anchor to rotate, change angular_velocity in the bullet definition file to 0.

Well i downloaded yesterday before i went to sleep the shot_replace thingy, now i just need to know how to use it, as in, 1 - the readme file says which codes for which bullets, but then im not that good at recognizing some of them with their image to say "ah, this bullet is with this variable", some pic -> code would be nice. 2 - if i use that, can i add the anchor to that file and use it?, as for the size thingy, i just cut it from the rip from UFO sprites, considering is kinda small yeah i would need to increase it's size on MS_Paint (unless it allows me to scale it to a bigger size). 3 - if i were to use the shot_replace thingy wouldnt that mean that only people with the shot_replace would be able to use the script?, and if so, how can i edit it so that i can just include it in my script.

Edit: Also, i think this is pretty close to the original Shooting Star from Th11(SA), but is there anyway to make it look better?:
Code: [Select]
#TouhouDanmakufu
#Title[Satori Spellcard 6]
#Text[Satori's 6th Spellcard]
#BGM[.\system\SatoriTheme.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
#include_function ".\cutin.txt"

let CSD = GetCurrentScriptDirectory;
let imgBoss= CSD ~ "system\satori.PNG";
let BossRight = CSD ~ "system\SatoriRight.PNG";
let BossLeft = CSD ~ "system\SatoriLeft.png";
let cut= CSD ~ "system\satoricut.png";
let bg = CSD ~ "system\SatoriBGa.png";
let bg2 = CSD ~ "system\SatoriBGb.png";
let bgN1 = CSD ~ "system\Nuclear.png";
let bgN2 = CSD ~ "system\CAUTION.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 ALERT = CSD ~"system\se_alert.wav";

let frame = 0;
let frame2 = 0;
let frame3 = 0;
let angle = 0;
let angleTilt = 0;
let speed=1;
let angle1 =0;
let angle2 =0;

@Initialize{
SetLife(1000);
SetDamageRate(30,0);
SetTimer(75);
SetScore(1200000);
SetMovePosition02(GetCenterX-150,GetCenterY-100,120);
SetInvincibility(180);
SetEnemyMarker(true);

LoadGraphic(imgBoss);
LoadGraphic(BossRight);
LoadGraphic(BossLeft);
LoadGraphic(cut);
LoadGraphic(bg);
LoadGraphic(bg2);
LoadGraphic(bgN1);
LoadGraphic(bgN2);
LoadSE(shotSE);
LoadSE(chargeSE);
LoadSE(ALERT);
LoadSE(TO1);
LoadSE(TO2);
CutIn(YOUMU,"Recolection ~ Shooting Star",cut,0,0,0,0);
cutin("NAZRIN",cut,0,0,256,512)

}

@MainLoop{
frame++;
frame2++;
frame3++;
if(!OnBomb){
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,21);
}
if(GetTimer>4&&GetTimer<=10&&frame3%60==0){
PlaySE(TO1);
}
if(GetTimer<=4&&frame3%60==0){
PlaySE(TO2);
}
if(frame3==10){
loop(4){
PlaySE(ALERT);
wait(4);
}
}

if(frame==120){
ShootingStar(20,5,RED03,15);
}
if(frame2==180){
angleTilt=rand(-5,5);
angle1=atan2(GetSpeedY,GetSpeedX)+90;
angle2=atan2(GetSpeedY,GetSpeedX)-90;
loop(20){
CreateShot01(GetX+50*cos(angle1),GetY+50*sin(angle1),speed/3,angle1+angleTilt,YELLOW02,0);
CreateShot01(GetX-50*cos(angle2),GetY-50*sin(angle2),speed/3,angle2+angleTilt,YELLOW02,0);
// CreateShot01(GetX+50,GetY+50,speed,92,bullet,0);
// CreateShot01(GetX+50,GetY+50,-(speed),92,bullet,0);
speed++;
}
speed=1;
frame2=166;
}

yield;
}
@DrawLoop{
SetColor(255,255,255);
SetRenderState(ALPHA);
if(OnBomb){
SetAlpha(150);
}else{
SetAlpha(255);
}
if(GetSpeedX==0){
SetTexture(imgBoss);
SetGraphicRect(0,0,47,64);
}
if(GetSpeedX>0){
SetTexture(BossRight);
SetGraphicRect(0,0,54,63);
}
if(GetSpeedX<0){
SetTexture(BossLeft);
SetGraphicRect(0,0,54,63);
}
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);

SetTexture(bgN1);
SetRenderState(ALPHA);
SetAlpha(155);
SetGraphicRect(frame3/2,0,GetClipMaxX+(frame3/2),131);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

SetTexture(bgN2);
SetRenderState(ALPHA);
SetAlpha(155);
SetGraphicRect(-frame3/2,0,GetClipMaxX-(frame3/2),230);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

}
    @Finalize {
DeleteGraphic(imgBoss);
DeleteGraphic(BossRight);
DeleteGraphic(BossLeft);
DeleteGraphic(cut);
DeleteGraphic(bg);
DeleteGraphic(bg2);
DeleteGraphic(bgN1);
DeleteGraphic(bgN2);
DeleteSE(shotSE);
DeleteSE(chargeSE);
DeleteSE(TO1);
DeleteSE(TO2);
    }
task ShootingStar(frames,speed,bulletB,numC){;
Concentration01(frames);
wait(frames);
SetMovePositionHermite(GetClipMaxX+120,GetY,150,90,-150,90,180);
wait(180);
SetMovePosition02(GetX,GetCenterY,60);
wait(60);
SetMovePosition02(GetClipMinX-120,GetCenterY-100,120);
wait(120);
SetMovePosition02(GetX,GetCenterY,30);
wait(30);
SetMovePosition02(GetClipMaxX+120,GetCenterY-120,120);
wait(120);
SetMovePosition02(GetX,GetCenterY,30);
wait(30);
SetMovePosition02(GetCenterX,GetCenterY-100,60);
wait(60);
ascent(i in 0..10){
loop(numC){
CreateShot01(GetX,GetY,speed,angle+GetAngleToPlayer,bulletB,0);
angle+=360/numC;
frame2=166;
}
wait(10);
}
Concentration01(frames);
wait(frames);
SetMovePositionHermite(GetClipMinX-120,GetY,150,90,-150,90,180);
wait(180);
SetMovePosition02(GetX,GetCenterY,60);
wait(60);
SetMovePosition02(GetClipMaxX+120,GetCenterY-100,120);
wait(120);
SetMovePosition02(GetX,GetCenterY,30);
wait(30);
SetMovePosition02(GetClipMinX-120,GetCenterY-120,120);
wait(120);
SetMovePosition02(GetX,GetCenterY,30);
wait(30);
SetMovePosition02(GetCenterX,GetCenterY-100,60);
wait(60);
ascent(i in 0..10){
loop(numC){
CreateShot01(GetX,GetY,speed,angle+GetAngleToPlayer,bulletB,0);
angle+=360/numC;
frame2=166;
}
wait(10);
}
ShootingStar(frames,speed,bulletB,numC);
yield;

}
task ShootIt(count,bullet,num){
let speed=1;
let angle1 =0;
let angle2 =0;
loop{
angle1=atan2(GetSpeedY,GetSpeedX)+90;
angle2=atan2(GetSpeedY,GetSpeedX)-90;
loop(num){
CreateShot01(GetX+50*cos(angle1),GetY+50*sin(angle1),speed,angle1,bullet,0);
CreateShot01(GetX-50*cos(angle2),GetY-50*sin(angle2),speed,angle2,bullet,0);
// CreateShot01(GetX+50,GetY+50,speed,92,bullet,0);
// CreateShot01(GetX+50,GetY+50,-(speed),92,bullet,0);
speed++;
}


speed=1;
wait(count);
}
yield;
}
function wait(w){
loop(w){yield;}
}
}
Dont mind the unused task, mostly because the task never worked for me and i had to use it in the mainloop, idk why with the mainloop it worked if it's basically the same thing, as an addition, why do i have to make a task recall itself so it can loop?

Edit 2: Is it possible to make the boss split in 2 and control both movements from 1 script? or do i have to make the other one as a familiar and control it in it's section

Edit 3: If i want to make a Point system do i have to add the task on every script, or only the stage script

Edit 4: If i want to change the BGM in mid of a fight, (a.k.a like Mystia on IN with dialogue included) i should delete the previous BGM before i Play the new one right?, assuming im using the song from the 1st dialogue, to delete it from memory in let's say 6 spellcards later, would it delete it even if the spellcard didnt load it on initialize? im kinda confused about that

Edit 5: Ehh it would be nice if someone could tell me the exact script for reflecting bullets for the X vertices and for the Y vertices (for each) so i can have an overall use of it whenever i need to make reflecting stuff.
« Last Edit: October 21, 2009, 08:12:10 AM by Sakura665 »

PT8Sceptile

  • All hail Giant Catfish!
Re: Danmakufu Q&A/Problem Thread
« Reply #997 on: October 21, 2009, 09:25:09 AM »
Well i downloaded yesterday before i went to sleep the shot_replace thingy, now i just need to know how to use it, as in, 1 - the readme file says which codes for which bullets, but then im not that good at recognizing some of them with their image to say "ah, this bullet is with this variable", some pic -> code would be nice. 2 - if i use that, can i add the anchor to that file and use it?, as for the size thingy, i just cut it from the rip from UFO sprites, considering is kinda small yeah i would need to increase it's size on MS_Paint (unless it allows me to scale it to a bigger size). 3 - if i were to use the shot_replace thingy wouldnt that mean that only people with the shot_replace would be able to use the script?, and if so, how can i edit it so that i can just include it in my script.

1 - Trial and error is one way. Another is opening shot_All.dnh and shot_replace.dnh in Notepad/whatever code editor you use and opening shot_all.png in MSPaint/whatever graphics editor you use. Now, whenever you move your mouse in Paint, in the lower left corner there should be two numbers that represent the coordinates of the mouse in the picture. Find the numerical ID of the bullet referenced from shot_replace.dnh, locate the bullet with that ID in shot_All.dnh and look at the rect of that bullet. The first two coordinates define the upper-left corner of the bullet in the shot_all.png file you opened with MSPaint, so you can just go locate the corner and see which bullet is down-right from that point. Do note, though, that if the render type of the bullet is not ALPHA, it will look different in Danmakufu than in MSPaint.

However, as I initially said, trial and error is probably the best way. Try out different bullet types and you'll see what they look like.

2 - Technically, it's possible (I'm not knowledged enough of the copyright and general policy issues regarding that, so you should probably ask someone else. I'm just assuming editing the file is O.K. as long as you're not trying to claim the whole file is your work). Just insert the anchor into shot_all.png through whichever graphics editing program you're using (editing it in MSPaint is probably stupid, though, since unless it's been changed lately that program can't handle transparencies, but there are myriads of free graphics editors on the internet that do support transparency so finding one shouldn't be an issue) and change one of the shotdata blocks in shot_All.dnh into the required information for the anchor (adding one won't probably work since Danmakufu has a upper limit on the amount of bullets in shotdata files, but you can just remove one you most probably aren't using). Of course, that brings me into...

3 - If you are, in fact, going to modify the file, you probably have to distribute it alongside your code, too. You can do this by for example coyping the SHOT_REPLACE -folder to your script folder (I recommend doing this before editing the files, so that you still have the original) and just replace the include function command specified in the readme with:

Code: [Select]
#include_function ".\SHOT_REPLACE\shot_replace.dnh"
Then just call shotinit; in the initialization part of the code and it should work. Do note, though, that if you're not modifying the script, you're probably okay with only referencing that the shot replace script is required in whatever topic you're posting your cards in, since most of the people here on the forums have downloaded it.

Edit 3: If i want to make a Point system do i have to add the task on every script, or only the stage script

Edit 4: If i want to change the BGM in mid of a fight, (a.k.a like Mystia on IN with dialogue included) i should delete the previous BGM before i Play the new one right?, assuming im using the song from the 1st dialogue, to delete it from memory in let's say 6 spellcards later, would it delete it even if the spellcard didnt load it on initialize? im kinda confused about that

Edit 5: Ehh it would be nice if someone could tell me the exact script for reflecting bullets for the X vertices and for the Y vertices (for each) so i can have an overall use of it whenever i need to make reflecting stuff.

E3 - Depends entirely on the point system and it's complexity. Generally, if you use enough Common Data variables, you'll do well enough with just adding the processing system to the stage and adding any custom point items you've made on scripts that drop them (perhaps by importing a function from a general script).

E4 - Haven't had to do anything like this before, so I can't really comment on that.

E5 - There are multiple ways of doing this. The one I use (not necessarily the most simple and efficient one) is: Whenever the object hits a wall (X coordinate less than the left bound or greater than the right bound, or the same for Y), split the speed/angle combination into components (speedx = speed*cos(angle), speedy = speed*sin(angle)), and if the component is going out of the field (x < left bound and speedx < 0, or x > right bound and speedx > 0), multiply the corresponding speed by -1 (speedx = speedx*(-1)), and recalculate the angle (angle = atan2(speedy, speedx)). Here's an example code I've used in some spellcards:

Code: [Select]
task SpinShot(xpos, ypos, speed, angle, avel, aacc, minavel, bounces, graph) {
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, xpos, ypos);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, graph);
ObjShot_SetDelay(obj, 0);
ObjShot_SetBombResist(obj, false);
Obj_SetAutoDelete(obj, true);

while (!Obj_BeDeleted(obj)) {
angle += avel;
avel += aacc;
if ((avel < minavel && aacc < 0) || (avel > minavel && aacc > 0)) {
avel = minavel;
}

let velx = speed*cos(angle);
let vely = speed*sin(angle);

if (Obj_GetX(obj) < 5 && velx < 0 && bounces > 0) {
velx *= -1;
bounces--;
}
if (Obj_GetX(obj) > 443 && velx > 0 && bounces > 0) {
velx *= -1;
bounces--;
}
if (Obj_GetY(obj) < 5 && vely < 0 && bounces > 0) {
vely *= -1;
bounces--;
}
if (Obj_GetY(obj) > 475 && vely > 0 && bounces > 0) {
vely *= -1;
bounces--;
}

angle = atan2(vely, velx);

Obj_SetAngle(obj, angle);
yield;
}
}

That's a task for a bouncing bullet with variable set location, speed, angle, angular velocity (avel), angular acceleration (aacc), maximum/minimum angular velocity (minavel), amount of bounces the bullet does and the graphic of the bullet. It bounces off of all 4 walls, so that should be enough for example code.

However, there's also a second, possibly slightly easier, faster and overall more efficient method than mine, that I unfortunately haven't had the will to learn for, due to it requiring a bit more memorization that this one in my opinion. If someone here could post the general formula that works only with angles, you'll probably want to use that instead.

Re: Danmakufu Q&A/Problem Thread
« Reply #998 on: October 21, 2009, 09:36:01 AM »
Yeah that could work i basically want to make bullets that bounce off all walls except the bottom one

EDIT: but having the angles and all that stuff for every wall is nice to have so i can just copy it everytime i need bouncing

EDIT 2:
Quote
2 - Technically, it's possible (I'm not knowledged enough of the copyright and general policy issues regarding that, so you should probably ask someone else. I'm just assuming editing the file is O.K. as long as you're not trying to claim the whole file is your work). Just insert the anchor into shot_all.png through whichever graphics editing program you're using (editing it in MSPaint is probably stupid, though, since unless it's been changed lately that program can't handle transparencies, but there are myriads of free graphics editors on the internet that do support transparency so finding one shouldn't be an issue) and change one of the shotdata blocks in shot_All.dnh into the required information for the anchor (adding one won't probably work since Danmakufu has a upper limit on the amount of bullets in shotdata files, but you can just remove one you most probably aren't using). Of course, that brings me into...

Actually i just wanted to use it to be able to add the anchor without having to make another shot file, not to claim anything about it, since if i have this file i can just add a new id and assing the anchor to it, so this would help
« Last Edit: October 21, 2009, 09:39:52 AM by Sakura665 »

PT8Sceptile

  • All hail Giant Catfish!
Re: Danmakufu Q&A/Problem Thread
« Reply #999 on: October 21, 2009, 09:59:59 AM »
Just remove this and it won't bounce off the bottom one:

Code: [Select]
if (Obj_GetY(obj) > 475 && vely > 0 && bounces > 0) {
            vely *= -1;
            bounces--;
         }

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #1000 on: October 21, 2009, 10:17:04 AM »
Make the anchor a familiar. I told DgBarca the same thing when he started immitating Murasa. An anchor as a shot is a bad idea :V It looks so fake and hard to control. If you turn it into a familiar you can give it all kind of functions and effects (also code wise it is more overview)

Re: Danmakufu Q&A/Problem Thread
« Reply #1001 on: October 21, 2009, 04:19:48 PM »
Yeah it looks like a nice idea to me, although now i hope i dont end up with the same problem trying to imitate Utsuho's 2nd non-spell. (As seen in the code i provided earlier... might end up providing a video too)

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #1002 on: October 21, 2009, 04:44:06 PM »
New thread!

If you have active questions please repost them there.