public static void Create(Texture2D image, Vector2 position) { if (spaceShip != null) { throw new Exception("Object already created"); } spaceShip = new Ship(image, position); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spacefield = Content.Load<Texture2D>("Background\\stars"); //sun = new Objet2D(Content.Load<Texture2D>("Background\\sun"), new Vector2(SCREENWIDTH / 2, SCREENHEIGHT / 2)); Ship.Create(Content.Load<Texture2D>("Sprites\\PlayerShip"), new Vector2(SCREENWIDTH / 4, SCREENHEIGHT / 2)); playerShip = Ship.GetInstance(); asteroid = new Asteroid(Content.Load<Texture2D>("Sprites\\bigAsteroid"), new Vector2(500, 100), AsteroidSize.BIG); Random r = new Random(); double startAngle = r.NextDouble() * 2 * Math.PI; asteroidMovement.X = (float)Math.Cos(startAngle) * asteroidSpeed; asteroidMovement.Y = (float)Math.Sin(startAngle) * asteroidSpeed; // TODO: use this.Content to load your game content here }