コード例 #1
0
ファイル: Game1.cs プロジェクト: mafficraft/MonoPong
        /// <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);

            t_wall = new Texture2D(GraphicsDevice,1,1);
            t_wall.SetData(new Color[] {Color.Black});

            t_goal = new Texture2D(GraphicsDevice, 1, 1);
            t_goal.SetData(new Color[] { Color.Pink });

            Dictionary<Keys, Command> p1Dict = new Dictionary<Keys, Command>();            
            player1 = new Player(Content.Load<Texture2D>(@"png/bar"), new Vector2(0, 0), 1,p1Dict);
            player1.Position = new Vector2(boundingBoxLeft.Width, boundingBoxTop.Height);
            p1Dict.Add(Keys.W, new MoveUpCommand(player1));
            p1Dict.Add(Keys.S, new MoveDownCommand(player1));

            Dictionary<Keys, Command> p2Dict = new Dictionary<Keys, Command>();        
            player2 = new Player(Content.Load<Texture2D>(@"png/bar"), new Vector2(0, 0), 2, p2Dict);
            player2.Position = new Vector2(WIDTH-boundingBoxRight.Width-player2.BoundingBox.Width,boundingBoxTop.Height);
            p2Dict.Add(Keys.Up, new MoveUpCommand(player2));
            p2Dict.Add(Keys.Down, new MoveDownCommand(player2));
           
            ball = new Ball(Content.Load<Texture2D>(@"png/ball"),new Vector2(300,100),new Vector2(1,0));
            ball.setToStartPosition();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: RedGhoul/MonoPong
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // have to save png files to 24bit and have copy if fewer enabled
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // need to make better images for the textures

            var gameBoundaries = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);
            var textureOfPaddles = Content.Load<Texture2D>("paddle");
            paddle = new Paddle(textureOfPaddles, Vector2.Zero, gameBoundaries, PlayerTypes.Human);
            ball = new Ball(Content.Load<Texture2D>("Ball"), Vector2.Zero, gameBoundaries);
            ball.AttachTo(paddle);
            var p2Local = new Vector2(gameBoundaries.Width - textureOfPaddles.Width, 0);
            paddle2 = new Paddle(textureOfPaddles, p2Local, gameBoundaries, PlayerTypes.COMPUTER);
            // TODO: use this.Content to load your game content here

            gameObjects = new GameObjects { PlayerPaddle = paddle, ComputerPaddle = paddle2, Ball = ball };
        }