Microsoft DirectX 8.0 (Visual Basic) |
Setting up the direction for a single-axis effect is easy because you need to specify only the direction of the axis. Put the DIEFF_CARTESIAN flag in the lFlags member of the DIEFFECT structure and set the x or y member to either 1 or -1, depending on the direction you want the effect to come from.
The following code example sets an x-axis effect with a right to left direction:
Dim eff As DIEFFECT eff.lFlags = DIEFF_CARTESIAN Or DIEFF_OBJECTOFFSETS eff.x = 1 eff.y = 0
The same effect could be set up just as easily using polar coordinates. Put the DIEFF_POLAR flag in the lFlags member of the DIEFFECT structure and set the x member to either 0, 90, 180, or 270 degrees.
The following code example sets the same x-axis effect as in the previous example:
Dim eff As DIEFFECT eff.lFlags = DIEFF_POLAR Or DIEFF_OBJECTOFFSETS eff.x = 90 * DI_DEGREES eff.y = 0
Setting up the direction for a polar two-axis effect is no different than a polar one-axis effect. The only difference is that the range of degree values is not restricted to the four axis values.
The following code example sets an effect originating from the user's upper right:
Dim eff As DIEFFECT eff.lFlags = DIEFF_POLAR Or DIEFF_OBJECTOFFSETS eff.x = 45 * DI_DEGREES eff.y = 0
Setting up the direction for a Cartesian two-axis effect is straightforward as well. First, set the DIEFF_CARTESIAN flag in lFlags. The x and y members will be filled with the x and y coordinates of any point on a line of direction through that point and the origin (0,0).
The following code example sets the same effect as in the previous sample:
Dim eff As DIEFFECT eff.lFlags = DIEFF_CARTESIAN Or DIEFF_OBJECTOFFSETS eff.x = 1 eff.y = 2