Пример #1
0
 // The Ship parameter should be changed to a general sprite which may involve changing the entire ship class into a class
 // but right now I'm not sure how it would be differentiated between which type of movement the sprite would get
 public void Update(GameTime gameTime, Ship ship)
 {
     // This is the top left corner of the view port I believe
     center = new Vector2(ship.position.X + (ship.rectangle.Width / 2) - GlobalClass.ScreenWidth / 2,
                          ship.position.Y + (ship.rectangle.Height / 2) - GlobalClass.ScreenHeight / 2);
     // No idea what this does
     transform = Matrix.CreateScale(new Vector3(1, 1, 0)) *
         Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0));
 }
Пример #2
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load textures
            backgroundTexture = Content.Load<Texture2D>(@"Textures/StarBackground");
            mainShipTexture = Content.Load<Texture2D>(@"Textures/Ship");
            bulletTexture = Content.Load<Texture2D>(@"Textures/Bullet");

            // Init screen size
            GlobalClass.ScreenWidth = GraphicsDevice.Viewport.Bounds.Width;
            GlobalClass.ScreenHeight = GraphicsDevice.Viewport.Bounds.Height;

            // Init starting positions
            mainShipPosition = new Vector2(GlobalClass.ScreenWidth / 2, GlobalClass.ScreenHeight / 2);
            backgroundPosition = new Vector2(0, 0);

            // Init the objects
            mainShip = new Ship(mainShipTexture, mainShipPosition);
            mainShip.SetBulletTexture(bulletTexture);
            mainCamera = new Camera(GraphicsDevice.Viewport);

            // Set mouse to being visible
            IsMouseVisible = true;
        }