private Vector3 p1rot;
private Vector3 p1rotInput;
private float p1rotForce;
public Vector3 Player1Rotation
{
get { return p1rot; }
set { p1rot = value; }
}
private Vector2 p1;
public Vector2 Player1Location
{
get { return p1; }
set { p1 = value; }
}
private Vector2 p1force;
private Vector2 p1spring;
private Vector2 p1grav;
And the time had come to move it out into an object. Which ended up looking like this:
class Player
{
private Vector2 _position;
private Vector2 _force;
private Vector3 _rotation;
private Vector3 _rotationInput;
private float _thrust;
private float _rotationForce;
public Vector2 Position
{
get { return _position; }
set { _position = value; }
}
.. blah blah properties. Thankfully we can use CTRL-R,E in Visual Studio to make a private variable into a public property; no mess, no fuss. There was also dome debate as to where to put the public properties w.r.t. their privates, I went with Turner and used the C++ style approach.And I even gave the object its very own method to update it's internals. Lucky thing.
public void HandleInput(float dt)
{ ..blah.. }
}
This also meant that I can now make my property grid show only properties of Player p1.
Which is a lot more useful.
Also evident is the pretty point field I forgot to blog about; this is just a bunch of for loops adding the gravity vector at a point in the grid to the vector to that point.. the result is a point distorted by gravity.
0 comments:
Post a Comment