~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
※ Danmakufu Q&A/Problem thread 3 ※
<< < (3/366) > >>
Lollipop:
Thanks!

But how would you shoot it? Can I have a code example from an actual script?

(Wow, I need to brush up on my advanced math skills)
Sparen:

--- Quote from: Lollipop on February 07, 2016, 05:04:14 PM ---Thanks!

But how would you shoot it? Can I have a code example from an actual script?

(Wow, I need to brush up on my advanced math skills)

--- End quote ---

This depends on how you want to spawn the bullets. If you want to spawn the actual shape, then do as Drake said, calculating the x and y coordinates to spawn the bullet at. If you want to fire a shape from the boss (rather than spawning the shape around the boss), then that's going to require a slightly different type of math.
Drake:
No, either way is fine, and I was actually specifically looking at shooting the shape outwards. Because this is already done in polar coordinates, it uses an angle (which you're already going to loop through just as though you were shooting a circle), and a "radius", which is given by the above equation. Like I wrote in the last post, you can interpret this radius as a speed and just plug it in, multiplying it for a faster shape. Basically "increase the radius of the shape by speed each frame".


--- Code: ---function CreateShotShapeOA1(obj, sides, gap, speed, angle_off, graphic, delay){
let x = ObjMove_GetX(obj);
let y = ObjMove_GetY(obj);
let t = 0;
while(t < 360){
let r = cos(180/sides) / cos(((t - angle_off) % (360/sides)) - (180/sides));
CreateShotA1(x, y, r * speed, t, graphic, delay);
t += gap;
}
}

--- End code ---

Meanwhile spawning the shape at a location and size is also a matter of multiplying ("give the shape a certain radius size") and converting back to x,y coordinates, so


--- Code: ---CreateShotA1(x + size*r*cos(t), y + size*r*sin(t), s, a, g, d);
--- End code ---

Lollipop:

--- Quote from: Drake on February 08, 2016, 02:48:46 AM ---No, either way is fine, and I was actually specifically looking at shooting the shape outwards. Because this is already done in polar coordinates, it uses an angle (which you're already going to loop through just as though you were shooting a circle), and a "radius", which is given by the above equation. Like I wrote in the last post, you can interpret this radius as a speed and just plug it in, multiplying it for a faster shape. Basically "increase the radius of the shape by speed each frame".


--- Code: ---function CreateShotShapeOA1(obj, sides, gap, speed, angle_off, graphic, delay){
let x = ObjMove_GetX(obj);
let y = ObjMove_GetY(obj);
let t = 0;
while(t < 360){
let r = cos(180/sides) / cos(((t - angle_off) % (360/sides)) - (180/sides));
CreateShotA1(x, y, r * speed, t, graphic, delay);
t += gap;
}
}

--- End code ---

Meanwhile spawning the shape at a location and size is also a matter of multiplying ("give the shape a certain radius size") and converting back to x,y coordinates, so


--- Code: ---CreateShotA1(x + size*r*cos(t), y + size*r*sin(t), s, a, g, d);
--- End code ---

--- End quote ---

Thanks alot  :)
Lollipop:
Is it possible to set a spawn point for the player i.e when you start the script, you start at the top of the screen or something like that.
Navigation
Message Index
Next page
Previous page

Go to full version