-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathParticle.cs
More file actions
68 lines (60 loc) · 1.83 KB
/
Particle.cs
File metadata and controls
68 lines (60 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#region Header
//
// Project: WriteableBitmapEx - Silverlight WriteableBitmap extensions
// Description: Blit Sample for the WriteableBitmap extension methods.
//
// Changed by: $Author: unknown $
// Changed on: $Date: 2015-02-24 20:36:41 +0100 (Di, 24 Feb 2015) $
// Changed in: $Revision: 112951 $
// Project: $URL: https://writeablebitmapex.svn.codeplex.com/svn/trunk/Source/WriteableBitmapExBlitSample/Particle.cs $
// Id: $Id: Particle.cs 112951 2015-02-24 19:36:41Z unknown $
//
//
// Copyright © 2009-2015 Bill Reiss, Rene Schulte and WriteableBitmapEx Contributors
//
// This code is open source. Please read the License.txt for details. No worries, we won't sue you! ;)
//
#endregion
#if NETFX_CORE
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.Foundation;
using System.Collections.Generic;
using Windows.UI;
#else
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
#endif
namespace WriteableBitmapExBlitSample
{
public class Particle
{
#region Fields
public Point Position;
public Point Velocity;
public Color Color;
public double Lifespan;
public double Elapsed;
#endregion
#region Methods
public void Initiailize()
{
Elapsed = 0;
}
public void Update(double elapsedSeconds)
{
Elapsed += elapsedSeconds;
if (Elapsed > Lifespan)
{
Color.A = 0;
return;
}
Color.A = (byte)(255 - ((255 * Elapsed)) / Lifespan);
Position.X += Velocity.X * elapsedSeconds;
Position.Y += Velocity.Y * elapsedSeconds;
}
#endregion
}
}