Hello guys
i have a problem with my for loop it should create a 100 by 100 field with 10x10 squares each squares are created by 4 vectorpositiontextures. it works fine until the 5th line there i have only 96 squares and then no more other squares. sry it is not commented very well but i hope you can help me. i am using xna 4.0 for a windows game. thx

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RockRaidersRecreation
{
    
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        public Camera camera {get; protected set; }
        ModelManager modelManager;
        Texture2D dottedLine;
        Texture2D ground1;
        Rectangle selectionBox;
        MouseState prevMouseState;
        VertexBuffer vertextBuffer;
        VertexPositionTexture[] verts;
        BasicEffect basicEffect;
        Vector3 vector1 = new Vector3(0, 0, 0);
        Vector3 vector2 = new Vector3(0, 0, -10);
        Vector3 vector3 = new Vector3(10, 0, 0);
        Vector3 vector4 = new Vector3(10, 0, -10);
        int vector1X = 0;
        int vector1Y = 0;
        int vector1Z = 0;
        int vector2X = 0;
        int vector2Y = 0;
        int vector2Z = -10;
        int vector3X = 10;
        int vector3Y = 0;
        int vector3Z = 0;
        int vector4X = 10;
        int vector4Y = 0;
        int vector4Z = -10;
        int vectorUV1X = 0;
        int vectorUV1Y = 0;
        int vectorUV2X = 1;
        int vectorUV2Y = 0;
        int vectorUV3X = 0;
        int vectorUV3Y = 1;
        int vectorUV4X = 1;
        int vectorUV4Y = 1;
        int vertsCheck0 = 0;
        int vertsCheck1 = 1;
        int vertsCheck2 = 2;
        int vertsCheck3 = 3;


       


        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            #if !DEBUG
                graphics.IsFullScreen = true;
            #endif



        }

       
        protected override void Initialize()
        {

            /* Set cullmode to none
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            GraphicsDevice.RasterizerState = rs;

             // Set cullmode to none*/

            

            //Add Component ModelManager
            modelManager = new ModelManager(this);
            Components.Add(modelManager);

           
            //Initialize Camera
            camera = new Camera(this, new Vector3(0, 75, 50), Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            //Mouse
            IsMouseVisible = true;
            prevMouseState = Mouse.GetState();

            //Box
            selectionBox = new Rectangle(-1, -1, 0, 0);

            base.Initialize();
        }

      
        protected override void LoadContent()
        {
            
            spriteBatch = new SpriteBatch(GraphicsDevice);
            dottedLine = Content.Load<Texture2D>(@"textures/2d/DottedLine");
            ground1 = Content.Load<Texture2D>(@"textures/2d/ground1");

            //vertsdefiniation
            verts = new VertexPositionTexture[4000];
           

            for (int i = 0; i < 4000;)
            {
                if (i == vertsCheck0)
                {
                    verts[i] = new VertexPositionTexture(new Vector3(vector1X, vector1Y, vector1Z), new Vector2(vectorUV1X, vectorUV1Y));

                    vertsCheck0 += 4;

                    if (vector1X < 1000)
                    {
                        vector1X += 10;
                    }
                    else
                    {
                        vector1X = 0;
                        if (vector1Z > -1000)
                        {
                            vector1Z += -10;
                        }
                    }

                    i++;
                }

                if (i == vertsCheck1)
                {
                    verts[i] = new VertexPositionTexture(new Vector3(vector2X, vector2Y, vector2Z), new Vector2(vectorUV2X, vectorUV2Y));
                    vertsCheck1 += 4;
                    if (vector2X < 1000)
                    {
                        vector2X += 10;
                    }
                    else
                    {
                        vector2X = 0;
                        if (vector2Z > -1000)
                        {
                            vector2Z += -10;
                        }
                    } 
                    i++;
                }

                if (i == vertsCheck2)
                {
                    verts[i] = new VertexPositionTexture(new Vector3(vector3X, vector3Y, vector3Z), new Vector2(vectorUV3X, vectorUV3Y));
                    vertsCheck2 += 4; 

                    if (vector3X < 1000)
                    {
                        vector3X += 10;
                    }
                    else
                    {
                        vector3X = 0;
                        if (vector3Z > -1000)
                        {
                            vector3Z += -10;
                        }
                    }
                    i++;
                }
               

                if (i == vertsCheck3)
                {
                    verts[i] = new VertexPositionTexture(new Vector3(vector4X, vector4Y, vector4Z), new Vector2(vectorUV4X, vectorUV4Y));
                    vertsCheck3 += 4;
                    if (vector4X < 1000)
                    {
                        vector4X += 10;
                    }
                    else
                    {
                        vector4X = 0;
                        if (vector4Z > -1000)
                        {
                            vector4Z += -10;
                        }
                    }
                    i++;
                }
            }

            //vertexBuffer
            vertextBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None);
            vertextBuffer.SetData(verts);

            //BasicEffect
            basicEffect = new BasicEffect(GraphicsDevice);


            
        }

        
        protected override void UnloadContent()
        {
           
        }

        private void DrawHorizontalLine(int thePositionY)
        {
            if (selectionBox.Width > 0)
            {
                for (int aCounter = 0; aCounter <= selectionBox.Width - 10; aCounter += 10)
                {
                    spriteBatch.Draw(dottedLine, new Rectangle(selectionBox.X + aCounter, thePositionY, 10, 5), Color.White);
                }
            }

            else if (selectionBox.Width < 0)
            {
                //Draw the line starting at the starting location and moving to the left
                for (int aCounter = -10; aCounter >= selectionBox.Width; aCounter -= 10)
                {
                    if (selectionBox.Width - aCounter <= 0)
                    {
                        spriteBatch.Draw(dottedLine, new Rectangle(selectionBox.X + aCounter, thePositionY, 10, 5), Color.White);
                    }
                }
            }
        }

        private void DrawVerticalLine(int thePositionX)
        {
            //When the height is greater than 0, the user is selecting an area below the starting point
            if (selectionBox.Height > 0)
            {
                //Draw the line starting at the starting location and moving down
                for (int aCounter = -2; aCounter <= selectionBox.Height; aCounter += 10)
                {
                    if (selectionBox.Height - aCounter >= 0)
                    {
                        spriteBatch.Draw(dottedLine, new Rectangle(thePositionX, selectionBox.Y + aCounter, 10, 5),
                        new Rectangle(0, 0, dottedLine.Width, dottedLine.Height), Color.White, MathHelper.ToRadians(90), new Vector2(0, 0), SpriteEffects.None, 0);
                    }
                }
            }
            //When the height is less than 0, the user is selecting an area above the starting point
            else if (selectionBox.Height < 0)
            {
                //Draw the line starting at the start location and moving up
                for (int aCounter = 0; aCounter >= selectionBox.Height; aCounter -= 10)
                {
                    if (selectionBox.Height - aCounter <= 0)
                    {
                       
                        spriteBatch.Draw(dottedLine, new Rectangle(thePositionX, selectionBox.Y + aCounter, 10, 5),
                        new Rectangle(0, 0, dottedLine.Width, dottedLine.Height), Color.White, MathHelper.ToRadians(90), new Vector2(0, 0), SpriteEffects.None, 0);
                        
                        
                    }
                }
            }
        }

        private void MouseOptionsForBox()
        {
            //MouseState
            MouseState aMouse = Mouse.GetState();
            if (aMouse.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released)
            {
                selectionBox = new Rectangle(aMouse.X, aMouse.Y, 0, 0);
            }

            if (aMouse.LeftButton == ButtonState.Pressed)
            {

                selectionBox = new Rectangle(selectionBox.X, selectionBox.Y, aMouse.X - selectionBox.X, aMouse.Y - selectionBox.Y);
            }

            if (aMouse.LeftButton == ButtonState.Released)
            {

                selectionBox = new Rectangle(-1, -1, 0, 0);
            }

            prevMouseState = aMouse;
        }

        
        protected override void Update(GameTime gameTime)
        {
           
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            MouseOptionsForBox();
            

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            GraphicsDevice.SetVertexBuffer(vertextBuffer);

            //camera info
            basicEffect.World = Matrix.Identity;
            basicEffect.View = camera.view;
            basicEffect.Projection = camera.projection;
            basicEffect.Texture = ground1;
            basicEffect.TextureEnabled = true;

            //draw triangle
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

                GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleStrip, verts, 0, 2000);
            }

            base.Draw(gameTime);


            spriteBatch.Begin();

            //Horizontal
            DrawHorizontalLine(selectionBox.Y);
            DrawHorizontalLine(selectionBox.Y + selectionBox.Height);

            //Vertical
            DrawVerticalLine(selectionBox.X);
            DrawVerticalLine(selectionBox.X + selectionBox.Width);


            spriteBatch.End();
        }
    }
}

solved at my own
dont need to reply anymore but thx if you had thought to reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.