public void paint_the_ground() { int trailWidth = 10; int trailHeight = 10; int randomColor = random.Next(); Color trailBlockColor = Movable.get_random_color(random);; //Only paint if he is in burstMode and running. if (player.burstMode && level > 0) { //Set the color Color[] colorArray = new Color[trailWidth * trailHeight]; for (int i = 0; i < colorArray.Length; i++) { colorArray[i] = trailBlockColor; } //Place it behind him for (int i = 0; i < stages.Count(); i++) { if (player.rectangle.Intersects(stages.ElementAt(i).rectangle)) { Rectangle trailRect = new Rectangle((int)(player.position.X - stages.ElementAt(i).position.X), (int)(player.position.Y + player.spriteHeight), trailWidth, trailHeight); stages.ElementAt(i).color_map.SetData <Color>(0, trailRect, colorArray, 0, colorArray.Length); } } } }
public Fragment(Vector2 newPosition, GraphicsDevice graphicsDevice, Random random) { angle = random.Next(205, 405); speed = random.Next(1, 8); position = newPosition; //Creating the rectangle and using color. color = Movable.get_random_color(random); Color[] colorArray = new Color[width * height]; for (int i = 0; i < colorArray.Length; i++) { colorArray[i] = color; } rect = new Texture2D(graphicsDevice, width, height); rect.SetData <Color>(colorArray); }