示例#1
0
        public virtual void Draw()
        {
            Sprite.Origin = Origin;

            //sets the parent transform if there is a requirement for one
            if (Parent != null)
            {
                if (RotateWithParent)
                {
                    Sprite.Position = Parent.Position + Vector2Extended.Rotate(Position, Parent.Rotation);
                    Sprite.Rotation = Parent.Rotation + Rotation;
                }
                else
                {
                    Sprite.Position = Parent.Position + Position;
                }
            }
            else
            {
                Sprite.Position = Position;
                Sprite.Rotation = Rotation;
            }

            G.Window.Draw(Sprite);
        }
示例#2
0
        public override void Think(Time dt)
        {
            if (_vectoringOn)
            {
                if (((Player)Parent).ADown)
                {// -
                    Rotation = _vectoringMinMax.X;
                }
                else if (((Player)Parent).DDown)
                {// +
                    Rotation = _vectoringMinMax.Y;
                }
                else
                {
                    Rotation = _restingRotation;
                }
            }

            if (((Player)Parent).WDown)
            {
                var force = new Vector2f(0, -_acceleration * dt.AsSeconds());
                force = Vector2Extended.Rotate(force, Parent.Rotation + Rotation);

                ((Dynamic)Parent).Body.ApplyForce(Vector2Extended.SFMLToXNA(force), ConvertUnits.ToSimUnits(Vector2Extended.SFMLToXNA(Sprite.Position)));
            }
            //((Ship)Parent).Velocity -= Vector2Extended.Rotate(new Vector2f(0, _acceleration), Rotation + Parent.Rotation) * dt.AsSeconds();

            base.Think(dt);
        }
示例#3
0
        public override void Draw()
        {
            base.Draw();

            var line = new Vertex[2];

            line[0] = new Vertex(Position, Color.Red);
            line[1] = new Vertex(Position + (Vector2Extended.XNAToSFML(Body.LinearVelocity) * 5), Color.Cyan);

            G.Window.Draw(line, 0, 2, PrimitiveType.Lines);
        }