I'm Trying to make a purple rain in c# windows forms, just like the one in this video https://www.youtube.com/watch?v=KkyIDI6rQJI Hes using an ide called processing with java programming language.
Here's my code so far:
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace PurpleRain
{
public partial class MainForm : Form
{
public MainForm()
{
}
float x=150;
float y=1;
float yspeed=1;
public void fall()
{
y=y+yspeed;
if (y>=350)
{
y=0;
}
}
public void show(float a,float b)
{
Graphics g;
g = this.CreateGraphics();
Pen myPen = new Pen(Color.MediumPurple);
myPen.Width = 2;
Pen myErase = new Pen(Color.Lavender);
myErase.Width = 2;
g.DrawLine(myErase, a, b-1, a, b+15);
g.DrawLine(myPen, a, b, a, b+15);
}
void draw()
{
for (int i=0;i<10;i++){
show(x,y);
fall();
}
}
void Timer1Tick(object sender, EventArgs e)
{
draw();
}
}
What this code does is draw a single purple line and make it fall to the bottom by erasing the previous drawn line. My problem is adding this purple line maybe a hundred to simulate a rain like in the video and having them start at random x and y positions as well. I've tried loops, list to no avail.
Not the best code, but it can be a good start for something better: