Don't copy and paste this exactly but it's going to look something like this when you split those classes:
namespace SpaceInvadersGame
{
class Player : Microsoft.Xna.Framework.Game
{
Texture2D PlayerTexture;
Vector2 PlayerPosition;
public Player()
{
}
protected override void LoadContent()
{
PlayerTexture = Content.Load<Texture2D>(@"Images/freshman2");;
PlayerPosition = Vector2.Zero;
base.LoadContent();
}
public Vector2 GetPosition()
{
return this.PlayerPosition;
}
public void Update()
{
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Left))
freshamPos.X -= freshmanSpeed;
if (keyboardState.IsKeyDown(Keys.Right))
freshamPos.X += freshmanSpeed;
if(keyboardState.IsKeyDown(Keys.Space))
theBullet = new Bullet(this);
}
public void Draw(SpriteBatch SpriteBatch)
{
}
}
}
namespace SpaceInvadersGame
{
class Bullet : Microsoft.Xna.Framework.Game
{
Texture2D BulletTexture;
Vector2 BulletPosition;
Player thePlayer;
public Bullet(Player player)
{
this.thePlayer = player;
}
protected override void LoadContent()
{
BulletTexture = Content.Load<Texture2D>(@"Images/bullet");;
BulletPosition = thePlayer.GetPosition();
base.LoadContent();
}
public void Update()
{
//in here is where you would just do something like:
//BulletPosition.Y += 1;
}
public void Draw(SpriteBatch SpriteBatch)
{
}
}
}