All pastes #776470 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-16 02:24 UTC
rendered paste body
float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
                
            int dispSizeOver2 = displaySize / 2;

            int startX = (int)PlayerLocation.X - dispSizeOver2;
            int startY = (int)PlayerLocation.Y - dispSizeOver2;
            int maxX = (int)PlayerLocation.X + dispSizeOver2;
            int maxY = (int)PlayerLocation.Y + dispSizeOver2;
            
            if (displaySize % 2 != 0)
            {
                maxX++;
                maxY++;
            }

            for (int x = startX; x < maxX; x++)
            {
                for (int y = startY; y < maxY; y++)
                {
                    Vector3 drawOffset = new Vector3();
                    Tile tile = tileMatrix.GetLandTile(x, y);

                    int xIndex = x - startX;
                    int yIndex = y - startY;

                    drawOffset.X = xIndex * 44;
                    drawOffset.Y = yIndex * 44;

                    int vertexIndex = (yIndex * 6) + ((xIndex * displaySize) * 6);
                    int textureIndex = (yIndex) + (xIndex * displaySize);

                    textureBuffer[textureIndex] = Artwork.GetTextmap(GraphicsDevice, tile.ID);

                    if (PlayerLocation.X == x && PlayerLocation.Y == y)
                    {
                        textureBuffer[textureIndex] = Artwork.GetTextmap(GraphicsDevice, 0);
                    }

                    vertices[vertexIndex].Position = drawOffset + new Vector3(0, 0, 0);
                    vertices[vertexIndex].TextureCoordinate = new Vector2(0, 0);
                    vertices[vertexIndex + 1].Position = drawOffset + new Vector3(44, 0, 0);
                    vertices[vertexIndex + 1].TextureCoordinate = new Vector2(1, 0);
                    vertices[vertexIndex + 2].Position = drawOffset + new Vector3(44, 44, 0);
                    vertices[vertexIndex + 2].TextureCoordinate = new Vector2(1, 1);
                    vertices[vertexIndex + 3].Position = drawOffset + new Vector3(0, 44, 0);
                    vertices[vertexIndex + 3].TextureCoordinate = new Vector2(0, 1);
                    vertices[vertexIndex + 4] = vertices[vertexIndex];
                    vertices[vertexIndex + 5] = vertices[vertexIndex + 2];

                }
            }

            vertexBuffer.SetData<VertexPositionTexture>(vertices);