示例#1
0
文件: Player.cs 项目: AmilKey/AmilKey
        // Initialize the player
        public void Initialize(Animation animation, Vector2 position)
        {
            PlayerAnimation = animation;

            // Set the starting position of the player around the middle of the screen and to the back
            Position = position;

            // Set the player to be active
            Active = true;

            // Set the player health
            Health = 100;
        }
示例#2
0
文件: Game1.cs 项目: AmilKey/AmilKey
        /// <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);

            // Load the player resources
            Animation LocalPlayerAnimation = new Animation();
            Animation RemotePlayerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("shipAnimation");
            Texture2D RemotePlayerTexture = Content.Load<Texture2D>("RemoteshipAnimation");

            RemotePlayerAnimation.Initialize(RemotePlayerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);
            LocalPlayerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            Vector2 LocalPlayerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X+LocalPlayerAnimation.FrameWidth/3, GraphicsDevice.Viewport.TitleSafeArea.Y
            + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            LocalPlayer.Initialize(LocalPlayerAnimation, LocalPlayerPosition);

            Vector2 RemotePlayerPosition = new Vector2(
               GraphicsDevice.Viewport.TitleSafeArea.X + GraphicsDevice.Viewport.TitleSafeArea.Width - RemotePlayerAnimation.FrameWidth/3,
               GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            RemotePlayer.Initialize(RemotePlayerAnimation, RemotePlayerPosition);

            projectileTexture = Content.Load<Texture2D>("laser");
            // TODO: use this.Content to load your game content here

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);

            // Load the score font
            font = Content.Load<SpriteFont>("gameFont");

            mainBackground = Content.Load<Texture2D>("mainbackground");
        }