예제 #1
0
 public override void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     base.Animation_Update(sender, e);
     _posAuspuffPixel  = new Vector(Shape.Width * _posAuspuff.X, Shape.Height * _posAuspuff.Y);
     _posAuspuffPixel += (Vector)Shape.Location;
     PSAuspuff.Config.EmmissionArea = new Rect(_posAuspuffPixel.X - (0.5 * PSAuspuff.Config.EmmissionArea.Width), _posAuspuffPixel.Y - (0.5 * PSAuspuff.Config.EmmissionArea.Height), PSAuspuff.Config.EmmissionArea.Width, PSAuspuff.Config.EmmissionArea.Height);
 }
예제 #2
0
 public void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     foreach (var item in Children)
     {
         item.Animation_Update(sender, e);
     }
 }
예제 #3
0
 public virtual void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     foreach (var animation in Animations)
     {
         animation.Update(this, e);
     }
 }
예제 #4
0
 //[MethodImpl(MethodImplOptions.Synchronized)] // single threaded
 public void Check(IGameObject me, FrameUpdateEventArgs e)
 {
     Rect rme = me.Shape;
     bool hitsGround = false;
     foreach (var other in Obstacles)
     {
         if (other != me)
         {
             Rect rother = other.Shape;
             if (rme.IntersectsWith(rother))
             {
                 Rect overlap = Rect.Intersect(rme,rother);
                 if (other is GroundObject)
                     hitsGround = true;
                 if (other.IsObstacle)
                 {
                     ProcessCollision(me, other, overlap, rme, rother, e.ElapsedMilliseconds / 1000);
                 }
                 me.RaiseOnCollision(me, other, true); // bool: me = caller of CheckCollision
                 other.RaiseOnCollision(other, me, false);
             }
         }
     }
     me.IsGrounded = hitsGround;
 }
예제 #5
0
        //[MethodImpl(MethodImplOptions.Synchronized)] // single threaded
        public void Check(IGameObject me, FrameUpdateEventArgs e)
        {
            Rect rme        = me.Shape;
            bool hitsGround = false;

            foreach (var other in Obstacles)
            {
                if (other != me)
                {
                    Rect rother = other.Shape;
                    if (rme.IntersectsWith(rother))
                    {
                        Rect overlap = Rect.Intersect(rme, rother);
                        if (other is GroundObject)
                        {
                            hitsGround = true;
                        }
                        if (other.IsObstacle)
                        {
                            ProcessCollision(me, other, overlap, rme, rother, e.ElapsedMilliseconds / 1000);
                        }
                        me.RaiseOnCollision(me, other, true); // bool: me = caller of CheckCollision
                        other.RaiseOnCollision(other, me, false);
                    }
                }
            }
            me.IsGrounded = hitsGround;
        }
예제 #6
0
        public void Frame_Update(object sender, FrameUpdateEventArgs e)
        {// wenn e > min fps nur jeden 2./3.
         // hilft nix !!!!!!!
         //if (e.ElapsedMilliseconds > (1000 / DropFramesMinFPS))
         //{
         //    //frameDrop = Math.Min(frameDrop + 1, Particles.Count / 4);
            ////    frameDrop = Math.Min(frameDrop + 1, 2);
            //}
            //if (e.ElapsedMilliseconds < (1000 / DropFramesMaxFPS))
            //{
            ////    frameDrop = Math.Max(frameDrop - 1, 1);
            ////    frameShift = 0;
            //}
            //frameShift++;
            //if (frameShift > frameDrop - 1) frameShift = 0;
            //for (int i = frameShift; i < Particles.Count; i += frameDrop)
            //{
            //    Particles[i].Frame_Update(this, e);
            //}

            //// Todo: drawShape für PS !
            //if (Config.DrawShape)
            //using (DrawingContext dc = vis.RenderOpen())
            //{
            //    if (DrawShape)
            //        dc.DrawRectangle(null, new Pen(Brushes.Black, 2), rectangle: new Rect(Shape.Location + (_parent.DrawingOffset * ScrollScaling), Shape.Size));
            //}

            foreach (var particle in Particles)
            {
                particle.Frame_Update(this, e);
            }
        }
예제 #7
0
 public virtual void Update(object sender, FrameUpdateEventArgs e)
 {
     if (IsActive)
     {
         Update_Active(sender, e);
     }
 }
예제 #8
0
        public virtual void Frame_Update(object sender, FrameUpdateEventArgs e)
        {
            DrawingVisual vis = Visuals[0] as DrawingVisual;

            using (DrawingContext dc = vis.RenderOpen())
            {
                if (Bmp != null)
                {
                    dc.PushTransform(new TranslateTransform(Position.X + (_parentContainer.DrawingOffset.X * ScrollScaling), Position.Y + _parentContainer.DrawingOffset.Y));
                    dc.PushTransform(new RotateTransform(Angle));
                    if (FlipHorizontal)
                    {
                        dc.PushTransform(new ScaleTransform(-1, 1));
                    }
                    dc.DrawImage(Bmp, new Rect((Point)(_deformationPos - _centerOfMassAbs), SizeV + _deformationSize));

                    if (FlipHorizontal)
                    {
                        dc.Pop();
                    }
                    dc.Pop();
                    dc.Pop();
                }
                if (DrawShape)
                {
                    DrawShapeAndMarkers(dc);
                }
            }
        }
예제 #9
0
 public override void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     if (IsAlive)
     {
         _spreadPos += _config.SubParticleSpread * (e.ElapsedMilliseconds/1000);
     }
     base.Animation_Update(sender, e);
 }
예제 #10
0
 public override void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     if (IsAlive)
     {
         _spreadPos += _config.SubParticleSpread * (e.ElapsedMilliseconds / 1000);
     }
     base.Animation_Update(sender, e);
 }
예제 #11
0
 void UpdateAnimation_Invoke(object sender, FrameUpdateEventArgs e)
 {
     currentAnimationFPS = e.CurrentFPS;
     // update the sender
     if (UpdateAnimation != null)
     {
         UpdateAnimation(this, e);
     }
 }
예제 #12
0
 void UpdateFrame_Invoke(object sender, FrameUpdateEventArgs e)
 {
     currentFrameFPS = e.CurrentFPS;
     // update the sender
     if (UpdateFrame != null)
     {
         UpdateFrame(this, e);
     }
     DrawOverlays();
 }
예제 #13
0
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     if (Sprite.IsMovable)
     {
         // F = k*v
         // dv = F/m *dt
         Vector A_drag = -Sprite.AirDrag * Sprite.NormSpeed;
         if (Sprite.Weight > 0)
                 A_drag /= Sprite.Weight;  // calculate without weight if there is none
         Vector dpos = (A_drag) * (e.ElapsedMilliseconds / 1000);
         Sprite.NormSpeed += dpos;
     }
 }
예제 #14
0
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     // Update damper power
     if (Gfx != null)
     {
         CarObject player = Gfx.FindObject("Player") as CarObject;
         if (player != null)
         {
             AnimKeyJump aniJump = player.GetAnimation("Jump") as AnimKeyJump;
             if (aniJump != null)
                 pgJumpRes.Value = aniJump.JumpReservoir / aniJump.JumpReservoirMax * 100;
         }
     } //  damper
 }
예제 #15
0
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     if (Sprite.IsMovable)
     {
         // F = k*v
         // dv = F/m *dt
         Vector A_drag = -Sprite.AirDrag * Sprite.NormSpeed;
         if (Sprite.Weight > 0)
         {
             A_drag /= Sprite.Weight;      // calculate without weight if there is none
         }
         Vector dpos = (A_drag) * (e.ElapsedMilliseconds / 1000);
         Sprite.NormSpeed += dpos;
     }
 }
예제 #16
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            //sinex += WobbleSpeed * e.ElapsedMilliseconds; // frame rate independend
            sinex += WobbleSpeed * 25;  // used for nonuniformly continuous behavior

            IElasticBody ESprite = Sprite as IElasticBody;
            if (ESprite != null)
            {
                Vector dpos = new Vector(Math.Sin(sinex)*2, Math.Sin(sinex)*5);
                dpos *= WobbleAmplitude;
                Vector dsize = new Vector(dpos.X / 2.0, -dpos.Y);

                ESprite.Deformation = new Rect(         ESprite.Deformation.Location + dpos,
                                                (Vector)ESprite.Deformation.Size + dsize);
            }
        }
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            IGameObject ThisObj  = Sprite as IGameObject;
            IGameObject OtherObj = null;

            if (ThisObj != null)
            {
                OtherObj = ThisObj.ParentContainer.FindObject(BoundSpriteName) as IGameObject;
            }
            if (ThisObj != null && OtherObj != null)
            {
                // begin binding / first start
                if (!oldValue.HasValue)
                {
                    switch (BoundProp)
                    {
                    case BindingProperty.PosX:
                        oldValue = OtherObj.Position.X;
                        break;

                    case BindingProperty.PosY:
                        oldValue = OtherObj.Position.Y;
                        break;

                    default:
                        break;
                    }
                }

                switch (BoundProp)
                {
                case BindingProperty.PosX:
                    ThisObj.Position += new Vector(OtherObj.Position.X - oldValue.Value, 0) * BindScaling;
                    oldValue          = OtherObj.Position.X;
                    break;

                case BindingProperty.PosY:
                    ThisObj.Position += new Vector(0, OtherObj.Position.Y - oldValue.Value) * BindScaling;
                    oldValue          = OtherObj.Position.Y;
                    break;
                }
            }
            else
            {
                oldValue = null;
            }
        }
예제 #18
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            if (currentAccel == null)
            {
                currentAccel = new Vector(0, 0);
            }

            double fkt = 1;

            if (!NeedsGround || Sprite.IsGrounded)
            {
                fkt = 1;
            }
            else
            {
                fkt = 0.1; // drive "in air"
            }
            Vector dv = (currentAccel * fkt) * (e.ElapsedMilliseconds / 1000);

            // speed in currentAccel direction
            if ((dv.Length > 0) && (Sprite.NormSpeed.Length > 0))
            {
                double s = Vector.Multiply(Sprite.NormSpeed, currentAccel) / currentAccel.Length;
                if (s > VMax)
                {
                    dv = new Vector(0, 0);
                }
            }
            Sprite.NormSpeed += dv;
            // breaking
            double dbreak = AccBreak * (e.ElapsedMilliseconds / 1000);

            if ((breaking) && (!NeedsGround || Sprite.IsGrounded))
            {
                if (Sprite.NormSpeed.Length <= dbreak)
                {
                    Sprite.NormSpeed = new Vector(0, 0);
                }
                else
                {
                    dv = Sprite.NormSpeed;
                    dv.Normalize();
                    dv *= dbreak;
                    Sprite.NormSpeed -= dv;
                }
            }
        }
예제 #19
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            //sinex += WobbleSpeed * e.ElapsedMilliseconds; // frame rate independend
            sinex += WobbleSpeed * 25;  // used for nonuniformly continuous behavior

            IElasticBody ESprite = Sprite as IElasticBody;

            if (ESprite != null)
            {
                Vector dpos = new Vector(Math.Sin(sinex) * 2, Math.Sin(sinex) * 5);
                dpos *= WobbleAmplitude;
                Vector dsize = new Vector(dpos.X / 2.0, -dpos.Y);

                ESprite.Deformation = new Rect(ESprite.Deformation.Location + dpos,
                                               (Vector)ESprite.Deformation.Size + dsize);
            }
        }
예제 #20
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            // load reservoir
            JumpReservoir += JumpPowerRestore * e.ElapsedMilliseconds / 1000;
            JumpReservoir  = Math.Min(JumpReservoir, JumpReservoirMax);

            // load jump
            if (loadJump)
            {
                double dp = Math.Min(JumpFillSpeed * e.ElapsedMilliseconds / 1000, JumpReservoir);
                if (dp < 0)
                {
                    dp = 0;
                }
                JumpReservoir   -= dp;
                StoredJumpPower += dp;
                if (JumpReservoir < 0)
                {
                    JumpReservoir = 0;
                }
                StoredJumpPower = Math.Min(JumpReservoirMax, StoredJumpPower);
            }

            // release jump
            if (!loadJump)
            {
                if ((!NeedsGround || Sprite.IsGrounded) && (StoredJumpPower > 0))
                {
                    // Jump
                    Sprite.NormSpeed += StoredJumpPower * JumpDirection;
                }
                else
                {
                    JumpReservoir += StoredJumpPower; // Jump not working
                }
                StoredJumpPower = 0;
            }
            var el = Sprite as SpriteObjectElastic;

            if (el != null)
            {
                double bend = (StoredJumpPower / JumpReservoirMax) * 0.4;
                el.Deformation = new Rect(el.Deformation.X, el.Deformation.Y + bend, el.Deformation.Width, el.Deformation.Height - bend);
            }
        }
예제 #21
0
 public virtual void  Update(object sender, FrameUpdateEventArgs e)
 {
     // Left border
     if (CenteredObject.Position.X < (ViewWindow.Width / 2))
     {
         GContainer.DrawingOffset = new Vector(0, 0);
     }
     // Middle
     else if (CenteredObject.Position.X > (GContainer.Width - (ViewWindow.Width / 2)))
     {
         GContainer.DrawingOffset = new Vector((ViewWindow.Width - GContainer.Width), 0);
     }
     // Right border
     else
     {
         GContainer.DrawingOffset = new Vector((ViewWindow.Width / 2) - CenteredObject.Position.X, 0);
     }
 }
예제 #22
0
 public override void Frame_Update(object sender, FrameUpdateEventArgs e)
 {
     TimeAlive += e.ElapsedMilliseconds;
     mixupProperties();
     if (IsAlive)
     {
         if (TimeAlive > ThisLifetime)
         {
             IsAlive   = false;
             TimeAlive = 0;
             using (DrawingContext dc = DVisual.RenderOpen()) { }
         }
         else
         {
             DrawParticle();
         }
     }
 }
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     if (Sprite.IsMovable)
     {
         Vector nSpeed = new Vector();
         IElasticBody ESprite = Sprite as IElasticBody;
         if (ESprite != null)
             ESprite.Deformation = new Rect(0, 0, 1, 1);
         // check collisions first
         if (Sprite.IsObstacle)
             (Sprite as IGFXObject).ParentContainer.Collider.Check(Sprite as IGameObject, e);
         // speed threshold in order to avoid oscillations
         nSpeed.X = (Math.Abs(Sprite.NormSpeed.X) < 0.1) ? 0 : Sprite.NormSpeed.X;
         nSpeed.Y = (Math.Abs(Sprite.NormSpeed.Y) < 0.1) ? 0 : Sprite.NormSpeed.Y;
         Vector dpos = GFXAnimation.NormToPixelSpeed(nSpeed) * (e.ElapsedMilliseconds / 1000);
         Sprite.Position += dpos;
         // Reset deformation
     }
 }
예제 #24
0
        // info: mit sealed override kann überschreiben verhindert werden
        public override void Animation_Update(object sender, FrameUpdateEventArgs e)
        {
            // mixupProperties in Animation Thread
            //  nicht Threadsafe !
            //TimeAlive += e.ElapsedMilliseconds;
            // try
            //  {
            //     mixupProperties();
            //}
            //catch (Exception ex)
            //{

            //    //throw;
            //}
            if (IsAlive)
            {
                AnimLinTrans.Update(this, e);
                AnimAirDrag.Update(this, e);
            }
        }
예제 #25
0
 public virtual void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     if (Animated)
     {
         MillisSinceLastEmmission += e.ElapsedMilliseconds;
         if (MillisSinceLastEmmission > (1000 / GenerationRate))
         {
             int newparticles = (int)(MillisSinceLastEmmission / (1000 / GenerationRate));
             //Debug.WriteLine("=> New Particles" + newparticles);
             for (int i = 0; i < newparticles; i++)
             {
                 SpawnParticle();
             }
             MillisSinceLastEmmission = 0;
         }
         foreach (var particle in Particles)
         {
             particle.Animation_Update(this, e);
         }
     }
 }
        // info: mit sealed override kann überschreiben verhindert werden
        public override void Animation_Update(object sender, FrameUpdateEventArgs e)
        {
            mixupProperties();
            // Alternative: count time alive in Animation frame
            // Warning: implementation not thread safe
            //TimeAlive += e.ElapsedMilliseconds;  // here because Frame_Update can be dropped
            //try
            //{
            //    mixupProperties();
            //}
            //catch (Exception ex)
            //{

            //    //throw;
            //}
            if (IsAlive)
            {
                AnimLinTrans.Update(this, e);
                AnimAirDrag.Update(this, e);
            }
        }
예제 #27
0
        public override void Update(object sender, FrameUpdateEventArgs e)
        {
            if (Sprite == null)
            {
                this.Dispose();
                return;
            }

            sinex       %= 2 * Math.PI;
            sinex       += 2.5;
            SpriteAngle += 1.5;
            SpriteAngle %= 360;
            Vector dpos = new Vector(Math.Round(Math.Sin(sinex) * 1),
                                     Math.Round(Math.Sin(sinex) * 5));
            Vector dsize = new Vector(Math.Round(dpos.X / 2.0), -dpos.Y);

            Point newPos  = Point.Add(SpritePos, dpos);
            Size  newSize = (Size)Point.Add((Point)SpriteSize, dsize);

            Sprite.Angle    = SpriteAngle;
            Sprite.Position = new Vector(SpriteAngle, 100);
        }
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            IGameObject ThisObj  = Sprite as IGameObject;
            IGameObject OtherObj = null;
            if (ThisObj != null)
                OtherObj = ThisObj.ParentContainer.FindObject(BoundSpriteName) as IGameObject;
            if (ThisObj != null && OtherObj != null)
            {
                // begin binding / first start
                if (!oldValue.HasValue)
                {
                    switch (BoundProp)
                    {
                        case BindingProperty.PosX:
                            oldValue = OtherObj.Position.X;
                            break;
                        case BindingProperty.PosY:
                            oldValue = OtherObj.Position.Y;
                            break;
                        default:
                            break;
                    }
                }

                switch (BoundProp)
                {
                    case BindingProperty.PosX:
                        ThisObj.Position += new Vector(OtherObj.Position.X - oldValue.Value, 0) * BindScaling;
                        oldValue = OtherObj.Position.X;
                        break;
                    case BindingProperty.PosY:
                        ThisObj.Position += new Vector(0, OtherObj.Position.Y - oldValue.Value) * BindScaling;
                        oldValue = OtherObj.Position.Y;
                        break;
                }
            } else {
                oldValue = null;
            }
        }
예제 #29
0
        public override void Update(object sender, FrameUpdateEventArgs e)
        {
            if (Sprite == null)
            {
                this.Dispose();
                return;
            }

            sinex %= 2 * Math.PI;
            sinex += 2.5;
            SpriteAngle += 1.5;
            SpriteAngle %= 360;
            Vector dpos = new Vector(Math.Round(Math.Sin(sinex) * 1),
                      Math.Round(Math.Sin(sinex) * 5));
            Vector dsize = new Vector(Math.Round(dpos.X / 2.0), -dpos.Y);

            Point newPos = Point.Add(SpritePos, dpos);
            Size newSize = (Size)Point.Add((Point)SpriteSize, dsize);

            Sprite.Angle = SpriteAngle;
            Sprite.Position = new Vector(SpriteAngle, 100);
        }
예제 #30
0
        public override void Update(object sender, FrameUpdateEventArgs e)
        {
            // Left border
            if (CenteredObject.Position.X < (ViewWindow.Width / 2))
            {
                PrefXPos = 0;
            }
            // Middle
            else if (CenteredObject.Position.X > (GContainer.Width - (ViewWindow.Width / 2)))
            {
                PrefXPos = (ViewWindow.Width - GContainer.Width);
            }
            // Right border
            else
            {
                PrefXPos = (ViewWindow.Width / 2) - CenteredObject.Position.X;
            }

            double dx = PrefXPos - GContainer.DrawingOffset.X;
            double XPos = dx * IFkt * (e.ElapsedMilliseconds/1000);
            XPos += GContainer.DrawingOffset.X;
            GContainer.DrawingOffset = new Vector(XPos, 0);
        }
예제 #31
0
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     if (Sprite.IsMovable)
     {
         Vector       nSpeed  = new Vector();
         IElasticBody ESprite = Sprite as IElasticBody;
         if (ESprite != null)
         {
             ESprite.Deformation = new Rect(0, 0, 1, 1);
         }
         // check collisions first
         if (Sprite.IsObstacle)
         {
             (Sprite as IGFXObject).ParentContainer.Collider.Check(Sprite as IGameObject, e);
         }
         // speed threshold in order to avoid oscillations
         nSpeed.X = (Math.Abs(Sprite.NormSpeed.X) < 0.1) ? 0 : Sprite.NormSpeed.X;
         nSpeed.Y = (Math.Abs(Sprite.NormSpeed.Y) < 0.1) ? 0 : Sprite.NormSpeed.Y;
         Vector dpos = GFXAnimation.NormToPixelSpeed(nSpeed) * (e.ElapsedMilliseconds / 1000);
         Sprite.Position += dpos;
         // Reset deformation
     }
 }
예제 #32
0
        public override void Update(object sender, FrameUpdateEventArgs e)
        {
            // Left border
            if (CenteredObject.Position.X < (ViewWindow.Width / 2))
            {
                PrefXPos = 0;
            }
            // Middle
            else if (CenteredObject.Position.X > (GContainer.Width - (ViewWindow.Width / 2)))
            {
                PrefXPos = (ViewWindow.Width - GContainer.Width);
            }
            // Right border
            else
            {
                PrefXPos = (ViewWindow.Width / 2) - CenteredObject.Position.X;
            }

            double dx   = PrefXPos - GContainer.DrawingOffset.X;
            double XPos = dx * IFkt * (e.ElapsedMilliseconds / 1000);

            XPos += GContainer.DrawingOffset.X;
            GContainer.DrawingOffset = new Vector(XPos, 0);
        }
예제 #33
0
 /// <summary>
 /// like a Draw() function. Just Draw. Animation is done by Animation_Update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public virtual void Frame_Update(object sender, FrameUpdateEventArgs e)
 {
     throw new System.NotImplementedException();
 }
예제 #34
0
 public virtual void Update_Active(object sender, FrameUpdateEventArgs e)
 {
 }
예제 #35
0
        public void UpdateFrame_delme(Object sender, FrameUpdateEventArgs elapsedMillis)
        {
            //if (sinex > 2*Math.PI) sinex = 0;
            sinex %= 2 * Math.PI;
            sinex += 2.5;
            SpriteAngle += 1.5;
            SpriteAngle %= 360;
            SpriteBlur += 0.5;
            SpriteBlur %= 20;
            // wrappanel benutzen für crop?
            Vector dpos = new Vector(Math.Round(Math.Sin(sinex) * 1),
                      Math.Round(Math.Sin(sinex) * 5));
            Vector dsize = new Vector(Math.Round(dpos.X / 2.0), -dpos.Y);

            Point newPos = Point.Add(SpritePos, dpos);
            Size newSize = (Size)Point.Add((Point)SpriteSize, dsize);
            //Point newPos = SpritePoint;
            //Size newSize = new Size(50+sinex, 30+sinex);

            //newPos += dpos;
            //bmp = Properties.Resources.BaseCar.ToMediaBitmap();

            // Draw FPS infotext
            DrawingVisual visualText = (DrawingVisual)Visuals[3];
            //DrawingVisual visualText = vc[3];
            using (DrawingContext dc = visualText.RenderOpen())
            {
                dc.DrawText(
                      new FormattedText(String.Format("FPS: {0:#0.0}", currentFPS),
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      26, System.Windows.Media.Brushes.Black),
                    new Point(0, 0));
                // size of text
                // http://stackoverflow.com/questions/6717199/how-to-calculate-size-of-formattedtext-or-glyphrun-in-wpf
            }

               // using (DrawingContext dc = vis.RenderOpen()) { }
            DrawingVisual visual = (DrawingVisual)Visuals[2];

            //DrawingVisual visual = vc[1];
            using (DrawingContext dc = visual.RenderOpen())
            {
                //dc.PushTransform(new TranslateTransform(newPos.X, newPos.Y));
                dc.PushTransform(new RotateTransform(SpriteAngle));
                dc.DrawImage(bmp, new Rect(newPos, newSize));

                dc.Pop();
                //dc.Pop();
            }
            //BlurBitmapEffect myBlurEffectObsolete = new BlurBitmapEffect();  // obsolete check new!!
            //visual.BitmapEffect = myBlurEffectObsolete;
            BlurEffect myBlurEffect = new BlurEffect();
            myBlurEffect.Radius = SpriteBlur;
            visual.Effect = myBlurEffect;

              /*
             Bitmap newImage = new Bitmap(newWidth, newHeight);
            using (Graphics gr = Graphics.FromImage(newImage))
            {
            gr.SmoothingMode = SmoothingMode.HighQuality;
            gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
            gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
            gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
            }
             */
        }
예제 #36
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            // load reservoir
            JumpReservoir += JumpPowerRestore * e.ElapsedMilliseconds/1000;
            JumpReservoir = Math.Min(JumpReservoir, JumpReservoirMax);

            // load jump
            if (loadJump)
            {
                double dp = Math.Min(JumpFillSpeed * e.ElapsedMilliseconds / 1000, JumpReservoir);
                if (dp < 0) dp = 0;
                JumpReservoir -= dp;
                StoredJumpPower += dp;
                if (JumpReservoir < 0) JumpReservoir = 0;
                StoredJumpPower = Math.Min(JumpReservoirMax, StoredJumpPower);
            }

            // release jump
            if (!loadJump)
            {
                if ((!NeedsGround || Sprite.IsGrounded) && (StoredJumpPower > 0))
                {
                    // Jump
                    Sprite.NormSpeed += StoredJumpPower * JumpDirection;
                }
                else
                {
                    JumpReservoir += StoredJumpPower; // Jump not working
                }
                StoredJumpPower = 0;
            }
            var el = Sprite as SpriteObjectElastic;
            if (el != null)
            {
                double bend = (StoredJumpPower / JumpReservoirMax) * 0.4;
                el.Deformation = new Rect(el.Deformation.X, el.Deformation.Y + bend, el.Deformation.Width, el.Deformation.Height - bend);
            }
        }
예제 #37
0
 public void Frame_Update(object sender, FrameUpdateEventArgs e)
 {
     foreach (var item in Children)
     {
         item.Frame_Update(sender, e);
     }
 }
예제 #38
0
        public void UpdateFrame_delme(Object sender, FrameUpdateEventArgs elapsedMillis)
        {
            //if (sinex > 2*Math.PI) sinex = 0;
            sinex       %= 2 * Math.PI;
            sinex       += 2.5;
            SpriteAngle += 1.5;
            SpriteAngle %= 360;
            SpriteBlur  += 0.5;
            SpriteBlur  %= 20;
            // wrappanel benutzen für crop?
            Vector dpos = new Vector(Math.Round(Math.Sin(sinex) * 1),
                                     Math.Round(Math.Sin(sinex) * 5));
            Vector dsize = new Vector(Math.Round(dpos.X / 2.0), -dpos.Y);

            Point newPos  = Point.Add(SpritePos, dpos);
            Size  newSize = (Size)Point.Add((Point)SpriteSize, dsize);
            //Point newPos = SpritePoint;
            //Size newSize = new Size(50+sinex, 30+sinex);

            //newPos += dpos;
            //bmp = Properties.Resources.BaseCar.ToMediaBitmap();

            // Draw FPS infotext
            DrawingVisual visualText = (DrawingVisual)Visuals[3];

            //DrawingVisual visualText = vc[3];
            using (DrawingContext dc = visualText.RenderOpen())
            {
                dc.DrawText(
                    new FormattedText(String.Format("FPS: {0:#0.0}", currentFPS),
                                      CultureInfo.GetCultureInfo("en-us"),
                                      FlowDirection.LeftToRight,
                                      new Typeface("Verdana"),
                                      26, System.Windows.Media.Brushes.Black),
                    new Point(0, 0));
                // size of text
                // http://stackoverflow.com/questions/6717199/how-to-calculate-size-of-formattedtext-or-glyphrun-in-wpf
            }


            // using (DrawingContext dc = vis.RenderOpen()) { }
            DrawingVisual visual = (DrawingVisual)Visuals[2];

            //DrawingVisual visual = vc[1];
            using (DrawingContext dc = visual.RenderOpen())
            {
                //dc.PushTransform(new TranslateTransform(newPos.X, newPos.Y));
                dc.PushTransform(new RotateTransform(SpriteAngle));
                dc.DrawImage(bmp, new Rect(newPos, newSize));

                dc.Pop();
                //dc.Pop();
            }
            //BlurBitmapEffect myBlurEffectObsolete = new BlurBitmapEffect();  // obsolete check new!!
            //visual.BitmapEffect = myBlurEffectObsolete;
            BlurEffect myBlurEffect = new BlurEffect();

            myBlurEffect.Radius = SpriteBlur;
            visual.Effect       = myBlurEffect;


            /*
             *         Bitmap newImage = new Bitmap(newWidth, newHeight);
             * using (Graphics gr = Graphics.FromImage(newImage))
             * {
             * gr.SmoothingMode = SmoothingMode.HighQuality;
             * gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
             * gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
             * gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
             * }
             */
        }
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            Vector dpos = Acceleration * (e.ElapsedMilliseconds / 1000);

            Sprite.NormSpeed += dpos;
        }
예제 #40
0
 /// <summary>
 /// like a Draw() function. Just Draw. Animation is done by Animation_Update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public virtual void Frame_Update(object sender, FrameUpdateEventArgs e)
 {
     throw new System.NotImplementedException();
 }
예제 #41
0
 void UpdateAnimation_Invoke(object sender, FrameUpdateEventArgs e)
 {
     currentAnimationFPS = e.CurrentFPS;
     // update the sender
     if (UpdateAnimation != null) UpdateAnimation(this, e);
 }
 public override void Update_Active(object sender, FrameUpdateEventArgs e)
 {
     Vector dpos = Acceleration * (e.ElapsedMilliseconds / 1000);
     Sprite.NormSpeed += dpos;
 }
예제 #43
0
 void UpdateFrame_Invoke(object sender, FrameUpdateEventArgs e)
 {
     currentFrameFPS = e.CurrentFPS;
     // update the sender
     if (UpdateFrame != null) UpdateFrame(this, e);
     DrawOverlays();
 }
 public override void Frame_Update(object sender, FrameUpdateEventArgs e)
 {
     TimeAlive += e.ElapsedMilliseconds;
     //mixupProperties();
     if (IsAlive)
     {
         if (TimeAlive > ThisLifetime)
         {
             IsAlive = false;
             TimeAlive = 0;
             using (DrawingContext dc = DVisual.RenderOpen()) { }
         } else
             DrawParticle();
     }
 }
예제 #45
0
        public override void Update_Active(object sender, FrameUpdateEventArgs e)
        {
            if (currentAccel == null) currentAccel = new Vector(0, 0);

            double fkt = 1;
            if (!NeedsGround || Sprite.IsGrounded)
                fkt = 1;
            else
                fkt = 0.1; // drive "in air"

            Vector dv = (currentAccel * fkt) * (e.ElapsedMilliseconds / 1000);
            // speed in currentAccel direction
            if ((dv.Length > 0) && (Sprite.NormSpeed.Length > 0))
            {
                double s = Vector.Multiply(Sprite.NormSpeed, currentAccel) / currentAccel.Length;
                if (s > VMax) dv = new Vector(0, 0);
            }
            Sprite.NormSpeed += dv;
            // breaking
            double dbreak = AccBreak * (e.ElapsedMilliseconds / 1000);
            if ((breaking) && (!NeedsGround || Sprite.IsGrounded))
            {
                if (Sprite.NormSpeed.Length <= dbreak)
                    Sprite.NormSpeed = new Vector(0, 0);
                else
                {
                    dv = Sprite.NormSpeed;
                    dv.Normalize();
                    dv *= dbreak;
                    Sprite.NormSpeed -= dv;
                }
            }
        }
예제 #46
0
 public override void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     base.Animation_Update(sender, e);
     _posAuspuffPixel = new Vector(Shape.Width * _posAuspuff.X, Shape.Height * _posAuspuff.Y);
     _posAuspuffPixel += (Vector)Shape.Location;
     PSAuspuff.Config.EmmissionArea = new Rect(_posAuspuffPixel.X - (0.5 * PSAuspuff.Config.EmmissionArea.Width), _posAuspuffPixel.Y - (0.5* PSAuspuff.Config.EmmissionArea.Height), PSAuspuff.Config.EmmissionArea.Width, PSAuspuff.Config.EmmissionArea.Height);
 }
예제 #47
0
 public virtual void Animation_Update(object sender, FrameUpdateEventArgs e)
 {
     foreach (var animation in Animations)
     {
         animation.Update(this, e);
     }
 }
예제 #48
0
        public virtual void Frame_Update(object sender, FrameUpdateEventArgs e)
        {
            DrawingVisual vis = Visuals[0] as DrawingVisual;

            using (DrawingContext dc = vis.RenderOpen())
            {
                if (Bmp != null)
                {
                    dc.PushTransform(new TranslateTransform(Position.X + (_parentContainer.DrawingOffset.X * ScrollScaling), Position.Y + _parentContainer.DrawingOffset.Y));
                    dc.PushTransform(new RotateTransform(Angle));
                    if (FlipHorizontal)
                        dc.PushTransform(new ScaleTransform(-1, 1));
                    dc.DrawImage(Bmp, new Rect((Point)(_deformationPos - _centerOfMassAbs), SizeV + _deformationSize));

                    if (FlipHorizontal)
                        dc.Pop();
                    dc.Pop();
                    dc.Pop();
                }
                if (DrawShape)
                {
                    DrawShapeAndMarkers(dc);
                }
            }
        }
예제 #49
0
        // info: mit sealed override kann überschreiben verhindert werden
        public override void Animation_Update(object sender, FrameUpdateEventArgs e)
        {
            // mixupProperties in Animation Thread
            //  nicht Threadsafe !
               //TimeAlive += e.ElapsedMilliseconds;
               // try
              //  {
               //     mixupProperties();
            //}
            //catch (Exception ex)
            //{

            //    //throw;
            //}
            if (IsAlive)
            {
                AnimLinTrans.Update(this, e);
                AnimAirDrag.Update(this, e);
            }
        }
        // info: mit sealed override kann überschreiben verhindert werden
        public override void Animation_Update(object sender, FrameUpdateEventArgs e)
        {
            mixupProperties();
            // Alternative: count time alive in Animation frame
            // Warning: implementation not thread safe
            //TimeAlive += e.ElapsedMilliseconds;  // here because Frame_Update can be dropped
            //try
            //{
            //    mixupProperties();
            //}
            //catch (Exception ex)
            //{

            //    //throw;
            //}
            if (IsAlive)
            {
                AnimLinTrans.Update(this, e);
                AnimAirDrag.Update(this, e);
            }
        }