Welcome. In the last episode, you'll notice that I didn't give you enough to make any of the sample shapes that
I created in the periodic functions list.
For example, in order to make a square, you have to be able to call the HxgnDif function with a phase shift of 1
added to it, and a lot of the other functions deal with other various offsets.
But implementing these offsets are easy. Sure, adding an extra offset parameter to the floater data would make
this job simpler, but there is an easier way.
Our enumeration is an integer, and its unlikely that we'll need thousands of separate functions (much less millions),
so instead of having our enumeration represent unique functions, we'll have our enumeration to represent a function
and its phase shift.
For example:
Public Enum PeriodicDesignation
Stable = 0 'Denotes that the object will not move in this direction.
CosineFxn 'Moves using the cosine function.
SineFxn 'Moves using the sine function.
Triangle
Hexagon
Trapezoid
Scalene
TriangleforSquare 'Trianglewave with offset of 0.5
End Enum |
Note the last element which I have just added to the enumeration. This TriangleforSquare specifies the
TriangleWave with the phase shift of 0.5 added onto it.
Then, if we want to implement this, we do:
Case PeriodicDesignation.TriangleforSquare
dX = Convert.ToInt32(Floater.RadispeedX * TrglDif(0.5F + Convert.ToSingle(FloatTick) * Floater.FrequencyX / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.TriangleforSquare
dY = Convert.ToInt32(Floater.RadispeedY * TrglDif(0.5F + Convert.ToSingle(FloatTick) * Floater.FrequencyY / Me.FREQUENCYDIVIDER)) |
And we can now have our Floaters with an offset already calculated so that squares are possible once again.
Public Enum PeriodicDesignation
Stable = 0 'Denotes that the object will not move in this direction.
CosineFxn 'Moves using the cosine function.
SineFxn 'Moves using the sine function.
Triangle
Hexagon
Trapezoid
Scalene
TriangleforSquare 'Trianglewave with offset of 0.5
HexagonforSquare 'Hexagonwave with offset of 1.
TrapezoidforRightTriangle 'Trapezoid, offset 1.
ScaleneforWedge 'Scalene, offset 1.
End Enum |
... more enumeration members.
Case PeriodicDesignation.HexagonforSquare
dX = Convert.ToInt32(Floater.RadispeedX * HxgnDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyX / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.ScaleneforWedge
dX = Convert.ToInt32(Floater.RadispeedX * SclnDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyX / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.TrapezoidforRightTriangle
dX = Convert.ToInt32(Floater.RadispeedX * TrpzDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyX / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.HexagonforSquare
dY = Convert.ToInt32(Floater.RadispeedY * HxgnDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyY / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.ScaleneforWedge
dY = Convert.ToInt32(Floater.RadispeedY * SclnDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyY / Me.FREQUENCYDIVIDER))
Case PeriodicDesignation.TrapezoidforRightTriangle
dY = Convert.ToInt32(Floater.RadispeedY * TrpzDif(1.0F + Convert.ToSingle(FloatTick) * Floater.FrequencyY / Me.FREQUENCYDIVIDER)) |
... and more implementations.
Here's a little form that will show the information for your levels.
Platform Diag.