Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1.  
  2.  
  3. class SnowFlake
  4. {
  5.   private float x, y;
  6.   private float xspeed, yspeed;
  7.  
  8.   public SnowFlake()
  9.   {
  10.     Reset();    
  11.   }
  12.  
  13.   public void Reset()
  14.   {
  15.     this.x = rand() * SCREEN_WIDTH;
  16.     this.y = 0;
  17.     this.xspeed = rand() * 10.0 - 5.0;
  18.     this.yspeed = 1.0 + rand() * 2.0;
  19.   }
  20.  
  21.  
  22.   public void Update()
  23.   {
  24.     this.x += this.xspeed;
  25.     this.yspeed += this.yspeed;
  26.     if (/* PARTICLE OUTSIDE SCREEN */)
  27.       Seed();    
  28.   }
  29.  
  30.   public void Draw()
  31.   {
  32.     // Draw particle to screen somehow
  33.   }
  34. }
  35.  
  36.  
  37. flakes = new SnowFlake[100];
  38. for (int i=0;i<flakes.Count;i++)
  39.    flakes[i] = new SnowFlake();
  40.  
  41.  
  42. for(flake in flakes)
  43. {
  44.    flake.Update();
  45.    flake.Draw();
  46.    Sleep(10); // Slow down
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement