コード例 #1
0
ファイル: Main.cs プロジェクト: akif-hossain/snake-game
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            grid = Content.Load<Texture2D>("grid");
            topMenu = Content.Load<Texture2D>("top");
            food.food = Content.Load<Texture2D>("food");
            font = Content.Load<SpriteFont>("font");

            body = new Body[100];
            for (int i = 0; i < body.Length; i++)
            {
                body[i] = new Body();
                body[i].body = Content.Load<Texture2D>("body");
            }
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: akif-hossain/snake-game
        private void updateBody2()
        {
            Body temp = new Body();
            Body temp2 = new Body();
            temp.setDX(body[0].dX());
            temp.setDY(body[0].dY());
            body[0].updateBody(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height);

            for (int i = 1; i < numOfElem; i++)
            {
                if (body[0].dX() == body[i].dX() && body[0].dY() == body[i].dY())
                    Initialize();
            }

            for (int i = 1; i < numOfElem; i++)
            {
                temp2.setDX(body[i].dX());
                temp2.setDY(body[i].dY());
                body[i].setDX(temp.dX());
                body[i].setDY(temp.dY());
                temp.setDX(temp2.dX());
                temp.setDY(temp2.dY());
            }
        }