]> git.r.bdr.sh - rbdr/super-polarity/blame - SuperPolarityMac/Particle.cs
Works in win, compiles in mac
[rbdr/super-polarity] / SuperPolarityMac / Particle.cs
CommitLineData
95d7601b
BB
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace 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}