Example #1
0
 protected override void Setup(nSprite display)
 {
     display.Texture = (Texture)Resources.Load("glow");
       display.Points.Set(new float[8] { 3, 3, 3, -3, -3, -3, -3, 3 });
       display.Color.Set(new float[4] { 1f, 1f, 1f, 0f });
       display.Depth = 20f;
 }
Example #2
0
        public void Update(nIDrawable Parent, nSprite[] sprites, float seconds)
        {
            var s = (Spark) Parent;
              var display = sprites [0];
              if (!_ready)
            Setup(display);

              /* position */
              s.Position [0] += s.Velocity [0] * seconds;
              s.Position [1] += s.Velocity [1] * seconds;
              s.Rotation += s.Velocity [2] * seconds;
              s.Scale[0] += s.ScaleChange[0] * seconds;
              s.Scale[1] += s.ScaleChange[1] * seconds;

              /* transparency */
              s.Lived += seconds;
              Alive = s.Alive;
              var visibility = 0f;
              if (Alive)
            visibility = 1.0f * (s.Lifespan - s.Lived) / s.Lifespan;
              s.Tint[3] = visibility;

              /* push changes into the display */
              if (display != null) {
            display.Color.Set(s.Tint);
            display.Rotation = s.Rotation;
            display.Position.Set(s.Position);
            display.Scale.Set(s.Scale);
              }
        }
Example #3
0
 public nQuad()
 {
     Data = new nSprite(0);
       Data.Points.Set(new float[8] { 0, 0, 0, 0, 0, 0, 0, 0 });
       Data.Position.Set(new float[2] { 0, 0 });
       Data.Color.Set(new float[4] { 1, 1, 1, 1 });
       Data.UV.Set(new float[8] { 1, 1, 1, 0, 0, 0, 0, 1 });
 }
Example #4
0
 public nAnim(nSprite target)
 {
     Target = target;
       _originalValue = Base();
 }
Example #5
0
 /** Set this box from a sprite marker */
 public void SetParent(nSprite parent)
 {
     Position.Set(parent.Position.Raw);
       Points.Set(parent.Points.Raw);
       Rotation = parent.Rotation;
       _data = null;
 }
Example #6
0
 public void Update(nIDrawable Parent, nSprite[] sprites, float seconds)
 {
 }
Example #7
0
 protected virtual void Setup(nSprite display)
 {
     display.Texture = (Texture) Resources.Load("star");
       display.Points.Set(new float[8] { 3, 3, 3, 0, 0, 0, 0, 3 });
       display.UV.Set(new float[8] { 1, 1, 1, 0, 0, 0, 0, 1 });
       display.Depth = 3f;
 }
Example #8
0
 /** Create a line segment */
 private void RebuildSegment(nSprite s, nGLine l, float offset1, float offset2)
 {
     var w1 = MinWidth + (MaxWidth - MinWidth) * offset1;
       var w2 = MinWidth + (MaxWidth - MinWidth) * offset2;
       var pnts = l.SPoints(w1, w2);
       s.Points.Set(pnts);
       s.Color[3] = (1.0f - offset1) * 0.2f;
 }
Example #9
0
        public void Update(nIDrawable Parent, nSprite[] sprites, float seconds)
        {
            _parent = (Twinkle)Parent;
              Life += seconds;
              var visible = 0.5f;
              var factor = 0f;
              if (Life < visible)
            factor = (Life / visible);
              else
            factor = 1.0f - (Life / (Lifespan - visible));

              sprites[0].Rotation += _parent.SpinRate * seconds;
              sprites[0].Color[3] = factor;
        }
Example #10
0
 public void Update(nIDrawable Parent, nSprite[] sprites, float seconds)
 {
     _parent = (ScoreDsp) Parent;
       Life += seconds;
       var factor = 1.0f - (Life / Lifespan);
       sprites[0].Color[3] = factor;
       sprites[0].Position[1] += _parent.Float * seconds;
 }
Example #11
0
 /** Copy all appropriate values from this source sprite */
 public void Load(nSprite src)
 {
     if (!src.Invalid)
     return;
       if ((src.Flags & nSpriteTags.COLOR) > 0)
     Color.Set(src.Color);
       if ((src.Flags & nSpriteTags.DEPTH) > 0)
     Depth = src.Depth;
       if ((src.Flags & nSpriteTags.POINTS) > 0)
     Points.Set(src.Points);
       if ((src.Flags & nSpriteTags.POSITION) > 0)
     Position.Set(src.Position);
       if ((src.Flags & nSpriteTags.SCALE) > 0)
     Scale.Set(src.Scale);
       if ((src.Flags & nSpriteTags.ROTATION) > 0)
     Rotation = src.Rotation;
       if ((src.Flags & nSpriteTags.TEXTURE) > 0)
     Texture = src.Texture;
       if ((src.Flags & nSpriteTags.UV) > 0)
     UV.Set(src.UV);
 }
Example #12
0
        /** Check if two sprites intersect */
        public static bool Intersects(nSprite a, nSprite b)
        {
            var q1 = new nGQuad();
              q1.Points = a.Points.Raw;
              q1.Offset(a.Position[0], a.Position[1]);

              var q2 = new nGQuad();
              q2.Points = b.Points.Raw;
              q2.Offset(b.Position[0], b.Position[1]);

              return q1.Intersects(q2);
        }