コード例 #1
0
ファイル: Game.cs プロジェクト: JazzSingh16/SnakeGame
        //private void StartUp()
        //{
        //    for (int i = 0; i <= label.Length - 1; i++)
        //    {
        //        label[i].vector = new Vector2(610, (10 + (15 * i)));
        //        label[i].text = "";
        //        label[i].color = Color.Black;
        //        label[i].visible = true;
        //    }
        //    RandomVector(ref Monster.position);
        //    Monster.facing = random.Next(1, 9);
        //    RandomVector(ref Food);
        //}
        /// <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);
            SnakeBodyTexture = Content.Load<Texture2D>("snakepart");
            SnakeHeadTexture = Content.Load<Texture2D>("snakehead");
            MonsterTexture = Content.Load<Texture2D>("monster");
            FoodTexture = Content.Load<Texture2D>("food");
            ControlFont = Content.Load<SpriteFont>("Courier New");
            LargeFont = Content.Load<SpriteFont>("Large");
            Texture2D HWallTexture = Content.Load<Texture2D>("HWall");
            Texture2D VWallTexture = Content.Load<Texture2D>("VWall");

            topWall = new Wall(HWallTexture, Vector2.Zero);
            bottomWall = new Wall(HWallTexture, new Vector2(0, 600 - HWallTexture.Height));
            leftWall = new Wall(VWallTexture, Vector2.Zero);
            rightWall = new Wall(VWallTexture, new Vector2(600 - VWallTexture.Width, 0));

            LControls = new Label(new Vector2(610, (10 + (15 * 1))), "Controls:", ControlFont);
            LRestart = new Label(new Vector2(610, (10 + (15 * 2))), "R-Restart", ControlFont);
            LPause = new Label(new Vector2(610, (10 + (15 * 3))), "P-Pause", ControlFont);
            LArrow = new Label(new Vector2(610, (10 + (15 * 4))), "Arrow Keys:", ControlFont);
            LMovement = new Label(new Vector2(610, (10 + (15 * 5))), "Movement", ControlFont);

            textCenter = new Vector2(GraphicsDevice.Viewport.Width / 2, 300f);
            LGameOver = new Label((textCenter - (LargeFont.MeasureString("GAME OVER") / 2)), "GAME OVER", LargeFont, false, Color.Crimson);
            LPaused = new Label((textCenter - (LargeFont.MeasureString("PAUSED") / 2)), "PAUSED", LargeFont, false, Color.Crimson);

            NewPlayer(ref PlayerOne);

            // TODO: use this.Content to load your game content here
        }