]> git.r.bdr.sh - rbdr/super-polarity/blob - SuperPolarity/Particle.cs
80abb094da280d4b0baed8d12112594030e78333
[rbdr/super-polarity] / SuperPolarity / Particle.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
7
8 namespace SuperPolarity
9 {
10 class Particle
11 {
12 public Texture2D Texture { get; set; }
13 public Vector2 Position { get; set; }
14 public Vector2 Velocity { get; set; }
15 public float Angle { get; set; }
16 public float AngularVelocity { get; set; }
17 public Color Color { get; set; }
18 public float Size { get; set; }
19 public int TTL { get; set; }
20
21 public Particle(Texture2D texture, Vector2 position, Vector2 velocity,
22 float angle, float angularVelocity, Color color, float size, int ttl)
23 {
24 Texture = texture;
25 Position = position;
26 Velocity = velocity;
27 Angle = angle;
28 AngularVelocity = angularVelocity;
29 Color = color;
30 Size = size;
31 TTL = ttl;
32 }
33
34 public void Update()
35 {
36 TTL--;
37 Position += Velocity;
38 Angle += AngularVelocity;
39 }
40
41 public void Draw(SpriteBatch spriteBatch)
42 {
43 Rectangle sourceRectangle = new Rectangle(0, 0, Texture.Width, Texture.Height);
44 Vector2 origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
45
46 spriteBatch.Draw(Texture, Position, sourceRectangle, Color,
47 Angle, origin, Size, SpriteEffects.None, 0f);
48 }
49
50 }
51 }