On this episode, we will be fixing our Floaters so that they have more functionality.  Of course, this will come at a price: the 
floaters have to have their own structure, and all important members of this structure will have to be saved to and loaded from 
file when we save them.
Now, a Floater that moves in a circle is fine, but it would be nice if it moved in other shapes as well.  This, of 
course, requires us to make more periodic functions and, since we cannot store a function into a variable, we'll have to have a 
number to represent which function to use.  This screams "Enumeration", so we'll use an Enumeration to determine which function 
to use.  Of course, with all periodic functions, we need to determine an origin, a radius, and a frequency.  The origin is just 
the initial position of the floater, which can be represented as the initial rectangle values, so the origin can be omitted.  Our 
periodic functions are defining how much the floater moves during each frame, so we'll just call the radius a radispeed (or 
whatever).  Since there will be a periodic function for horizontal and another for vertical movement (right now we're using 
Cos for horizontal and Sin for vertical), we need to have a pair of enumeration variables, a pair of radispeed, and of frequency.
In order to make frequency values be stored in an integer, we will be dividing the frequency by a number like 64 or 128, so 
that we can have a value that represents a frequency of 1, and lower numbers will represent a frequency that is less than 1.

Side Note: Since our periodic functions are defining how much the floater moves each frame, the actual radius (let's call it r) 
is multiplied by the frequency of the periodic function (let's say f) to give us the new coefficient (radispeed) of the 
periodic function (s, let's say).  
In our last example, the coefficient which multiplied the sine and cosine was 5 and the frequency is 1/8, so the actual radius 
of the floater here is s/f = r.  So 5 divided by one-eighth (not divided by eight) gives us 40.

Now, let's get to declaring the floater function enumeration and structure.  First, the enumeration:

		public enum desgperiodic
		{
			stable = 0,
			cosinefxn,
			sinefxn
		}
		//Designates periodic functions that will be used to move a floater.
We just have three periodic functions that we can use, but when we get more, we'll add them here. Now, the structure:
		public struct levfloater 
		{
			private Rectangle rect;
			private desgperiodic hfxn;
			private desgperiodic vfxn;
			private int xrveloc;
			private int yrveloc;
			private int xfreq;
			private int yfreq;
		}
These are the private members. Now we get to add some accessor procedures to access these private variables. Why didn't I just make them Public variables? Because I want to get the gray icon for property for each of these items that I want to access. Rectangles have them, so why not us too?
			public Rectangle Loc
			{
				set 
				{
					rect = value;
				}
				get
				{
					return rect;
				}
			}
			public desgperiodic HorizFxn
			{
				get 
				{
					return hfxn;
				}
				set 
				{
					hfxn = value;
				}
			}
			public desgperiodic VertFxn 
			{
				get 
				{
					return vfxn;
				} 
				set 
				{
					vfxn = value;
				}
			}
			public int radispeedX
			{
				get 
				{
					return xrveloc;
				}
				set 
				{
					xrveloc = value;
				}
			}
			public int radispeedY 
			{
				get 
				{
					return yrveloc;
				}
				set 
				{
					yrveloc = value;
				}
			}
			public int XFrequency 
			{
				get 
				{
					return xfreq;
				}
				set 
				{
					xfreq = value;
				}
			}
			public int YFrequency 
			{
				get 
				{
					return yfreq;
				}
				set 
				{
					yfreq = value;
				}
			}
Wow. Thank goodness for long hand exercises - these aren't very fun to write. Now, of course, I have to add a constructor to initialize all of these properties.
			public levfloater(Rectangle Location, desgperiodic HFxn, desgperiodic VFxn, int XRadispeed, int YRadispeed, int XFrequency, int YFrequency) 
			{
				rect = Location;
				hfxn = HFxn;
				vfxn = VFxn;
				xrveloc = XRadispeed;
				yrveloc = YRadispeed;
				xfreq = XFrequency;
				yfreq = YFrequency;
			}
We will also need a subroutine that will offset the floater's rectangle, because we cannot use Offset on the property itself.
			public void Offset(int dx, int dy) 
			{
				// Moves the underlying location rectangle.
				rect.Offset(dx, dy);
			}
And that concludes our structure for now. Next, we need to get our floater to work on this structure. So, back to our form class, where we change our declaration.
		levfloater floater;
		// This holds the location and information of the floater.
And a constant.
		const int thefrequencydivider = 128;
		// This number will divide the integer frequencies of the floater to hopeful fractions.
And, of course, we have to change the code everywhere where we have used the original floater when it was a rectangle. In the Load event:
			floater = new levfloater(new Rectangle(480, 280, thefloatersize, thefloatersize), 5, 5, 16, 16, desgperiodic.cosinefxn, desgperiodic.sinefxn );
			// Set up floater information.
Artwork:
			gfx.DrawImage(floatbmp, floater.Loc);
			// Draw the floater.
In CharacterMovement:
				if (playerloc.IntersectsWith(floater.Loc )) 
				{
					// Touched the floater.
					isgoner = true;

					playerveloc = PFMain.thesbarinitialvelocity;
				}
And now, the culmination of all of the structure building that we discussed earlier. First, let's declare two variables in this charactermovement subroutine.
			int dx, dy;
			//Describes the amount by which a floater will move.
And now, replacing our original floater moving code:
			switch (floater.HorizFxn) 
			{
				case desgperiodic.cosinefxn:
					dx = (int)(floater.radispeedX * Math.Cos((double)floater.XFrequency * floattick / thefrequencydivider));
					break;
				case desgperiodic.sinefxn:
					dx = (int)(floater.radispeedX * Math.Sin((double)floater.XFrequency * floattick / thefrequencydivider));
					break;
				default:
					dx = 0;
					break;
			}
			//Calculates how much to move horizontally.
			switch (floater.VertFxn) 
			{
				case desgperiodic.cosinefxn:
					dy = (int)(floater.radispeedY * Math.Cos((double)floater.YFrequency * floattick / thefrequencydivider));
					break;
				case desgperiodic.sinefxn:
					dy = (int)(floater.radispeedY * Math.Sin((double)floater.YFrequency * floattick / thefrequencydivider));
					break;
				default:
					dy = 0;
					break;
			}
			//Calculates how much to move vertically.

			floater.Offset(dx, dy);
			//And then the floater is moved.
And now, our Floater moves in a circle (again), but now, you can customize the floater a bit by assigning different radispeeds, frequencies, and periodic functions. It will be even more customizable when we add different periodic functions. On the next episode, we'll add the floater information to the file.