Hello, I'm trying to draw a terrain using the points given by this function:
public static Level GenerateDummyLevel(int width, int height)
{
Level level = new Level();
bool up = false;
for (int i = 0; i <= width; i += 20)
{
level.Terrain.Add(new Vector2(i, height / 2 + (up ? -10 : 10)));
up = !up;
}
return level;
}
and this function draws the terrain:
public void Draw(GraphicsDeviceManager graphics, SpriteBatch spriteBatch, PrimitiveBatch primitiveBatch)
{
this.Lander.Draw(graphics, spriteBatch, primitiveBatch);
primitiveBatch.Begin(PrimitiveType.TriangleList);
if (this.Terrain.Count > 1)
{
for (int i = 0; i < (this.Terrain.Count - 1); i++)
{
primitiveBatch.AddVertex(new Vector2(this.Terrain[i].X, this.Terrain[i].Y), Color.Black);
primitiveBatch.AddVertex(new Vector2(this.Terrain[i + 1].X, graphics.PreferredBackBufferHeight), Color.Black);
primitiveBatch.AddVertex(new Vector2(this.Terrain[i].X, graphics.PreferredBackBufferHeight), Color.Black);
primitiveBatch.AddVertex(new Vector2(this.Terrain[i].X, this.Terrain[i].Y), Color.Black);
primitiveBatch.AddVertex(new Vector2(this.Terrain[i + 1].X, this.Terrain[i + 1].Y), Color.Black);
primitiveBatch.AddVertex(new Vector2(this.Terrain[i + 1].X, graphics.PreferredBackBufferHeight), Color.Black);
}
}
primitiveBatch.End();
}
The terrain drawn by this function begins from the bottom of screen and ends in the middle how can i start the terrain from the top of the screen instead of the bottom? Is there any way to simply mirror the terrain along x-axis?