예제 #1
0
파일: Game1.cs 프로젝트: YouriRombouts/Pong
        /// <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);
            // TODO: use this.Content to load your game content here
            m_Bar1   = new Bar(new Vector2(0, (graphics.GraphicsDevice.Viewport.Height / 2)));
            m_Bar2   = new Bar(new Vector2(0, (graphics.GraphicsDevice.Viewport.Height / 2)));
            m_Ball   = new Ball(new Vector2((graphics.GraphicsDevice.Viewport.Width / 2), (graphics.GraphicsDevice.Viewport.Height / 2)), 10, new Vector2(0, 0));
            m_Lives1 = new Lives();
            m_Lives2 = new Lives();
            m_Bar1.MoveVertical(-(m_Bar1.GetHeight()) / 2);
            m_Bar2.MoveVertical(-(m_Bar2.GetHeight()) / 2);
            m_Ball.MoveVertical(-m_Ball.GetSize() / 2);
            m_Bar2.MoveHorizontal(graphics.GraphicsDevice.Viewport.Width - m_Bar2.GetWidth());
            m_Ball.SetVel(new Vector2(m_Ball.GetStartVelX(), m_Ball.GetStartVelY()));

            Font = Content.Load <SpriteFont>("Score");
            m_Ball.MoveHorizontal(-m_Ball.GetSize() / 2);
            //SpriteFont font = Content.Load<SpriteFont>("Score.spritefont");

            m_BarShape1 = new Texture2D(graphics.GraphicsDevice, m_Bar1.GetWidth(), m_Bar1.GetHeight());
            m_BarShape2 = new Texture2D(graphics.GraphicsDevice, m_Bar2.GetWidth(), m_Bar2.GetHeight());
            m_BallShape = new Texture2D(graphics.GraphicsDevice, m_Ball.GetSize(), m_Ball.GetSize());
            Color[] data = new Color[80 * 30];
            for (int i = 0; i < data.Length; ++i)
            {
                data[i] = Color.White;
            }
            m_BarShape1.SetData(data);
            m_BarShape2.SetData(data);
            m_BallShape.SetData(data);

            Music = Content.Load <Song>("BeepBox-Song loop");
            MediaPlayer.Play(Music);
            MediaPlayer.IsRepeating = true;


            IsMouseVisible = true;

            PlayButton = new Button(Content.Load <Texture2D>("Play"), graphics.GraphicsDevice);
            PlayButton.SetPostion(new Vector2(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 16, GraphicsDevice.Viewport.Height / 2));

            Back      = new Button(Content.Load <Texture2D>("Back"), graphics.GraphicsDevice);
            Back.Size = new Vector2(graphics.GraphicsDevice.Viewport.Width / 9, graphics.GraphicsDevice.Viewport.Height / 18);
            Back.SetPostion(new Vector2(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 16, GraphicsDevice.Viewport.Height / 2 + 100));

            //Options = new Button(Content.Load<Texture2D>("Options"), graphics.GraphicsDevice);
            //Options.SetPostion(new Vector2(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 16, (GraphicsDevice.Viewport.Height / 2 + 20) + 10));

            //Full = new Button(Content.Load<Texture2D>("Fullscreen"), graphics.GraphicsDevice);
            //Full.SetPostion(new Vector2(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 16, GraphicsDevice.Viewport.Height / 2));

            Ping  = Content.Load <SoundEffect>("ping");
            Pong  = Content.Load <SoundEffect>("pong");
            Pang2 = Content.Load <SoundEffect>("pang2");
        }