But I think I'll stick to using only bomb resistant object bullets that change alpha value and character detection in accordance to its z-value
Hmm.. How can an object bullet change it's alpha value (without changing graphics) and interaction with player's hibox? :wat:
But the problem is that I'm not that great with advanced math yet @@. I've read the articles that you've linked to, but I'm confused by the symbols used in the diagrams/formulas. If it's possible, could you briefly explain some of the logic behind doing r * sin(a) * cos(b) and all of that stuff to find the coordinates? Rotation I'm not even going into yet, prolly. I'm the type of learner that learns best when I know the use of it, or how it's being applied or however you say it, apparently ._." Teachers get annoyed when I ask about the logic behind every single concept x.x
And who knows? Maybe understanding the mechanics of 3-d rotation will be easier once I manage to grasp 3-d placement/coordinates ^^
Oh well. It's not necessary to understand some advanced math just to use the formulas to calculate stuff. But ok, i'll try to describe "easily" how those functions work.
First, spherical coordinates. Imagine a globe where you have latitude and longitude to define a location on it's surface. Those are actually two angles, like shown on this picture
One - between Z axis and radius to point, another - between projection of that radius on XY plane and X axis.
So with two cycles for two angles and a given radius you can easily arrange them on a sphere surface (radius is processed in point task)
ascent(i in 0..30){
ascent(j in 0..15){
Point(i*12,j*12);
}
}
And to derive onscreen coordinates for those bullets (and their z for depth effect) here's a formula for coordinate conversion:
If you're confused how it works, it's pretty easy 2-step operation.
r * sin(a) is actually a length of radius projection on XY plane. And to find X coordinate of it you have to multiply it by cos(b) (and by sin(b) for Y). Just look one more time at the picture and you'll get it. This way the initial coordinates of bullets are calculated:
if(rad<272){
//Definition of sphere points. See http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
x0=rad*sin(a)*cos(b);
y0=rad*sin(a)*sin(b);
z0=rad*cos(a);
}
As i dont do any manipulation with them, and dont change the radius once it reaches maximum, there's no need to calculate them always, so there goes if.
Now we can proceed to rotation. From this point it doesnt matter if we have a perfect sphere of points or whatever. You can draw a cube if you want or something else (try to add a+=rand(-2,2); b+=rand(-2,2); before while in a task
)
The most common way to rotate a 3D point around one of axises is using
rotation matrices as described here
http://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions If you dont know what is
vector multiplication by matrix i'll describe it like that: Your certain point you want to rotate around some axis is represented by it's initial coordinates [x0, y0, z0]. To rotate it around X axis for example by an angle of a you have to do following equations:
x = M1,1 * x0 + M1,2 * y0 + M1,3 * z0
y = M2,1 * x0 + M2,2 * y0 + M2,3 * z0
z = M3,1 * x0 + M3,2 * y0 + M3,3 * z0 where M1,2 is a value from 1st row and 2nd column of rotaion matrix and so on.
The first one above is a rotation matrix for rotation around X axis, wich controlled by
ang1 value in my script. Omiting zeros, we'll get this
x=x0;
y=y0*cos(ang1)-z0*sin(ang1);
z=y0*sin(ang1)+z0*cos(ang1);
By applying this we'll get our sphere (or whatever bunch of points) rotatin around X axis on screen.
And then we're doing the same thing but for rotating around Y axis. Just use second matrix for it:
xtmp=x; // Needed to save x value for z calculation
x=x*cos(ang2)+z*sin(ang2);
z=-xtmp*sin(ang2)+z*cos(ang2);
I used an additional variable
xtmp to store x value so it wont get corrupt on z calculation.
And that's it! Now the complexity of the pattern highly depends on how are you going to rotate it. It can easily go from "omg it's so fun and confusing!" to "how the fuck should i dodge this mindfuck?!" Hope you understood my wall of text i've written here, cause i cant describe it any easier :yukkuri: