Пример #1
0
        public override void Update(double dt)
        {
            Weapon1.Owner = this;
            Weapon2.Owner = this;
            base.Update(dt);
            t += SwingSpeed * dt;
            double vx = 0, vy = 0;

            if (Key.A.Pressed())
            {
                vx -= 1;
            }
            if (Key.D.Pressed())
            {
                vx += 1;
            }
            if (Key.W.Pressed())
            {
                vy += 1;
            }
            if (Key.S.Pressed())
            {
                vy -= 1;
            }
            if (MouseButton.Left.Pressed())
            {
                Weapon1.Shoot(World.Current.cam.FromWH(Mouse.Position, App.Width, App.Height));
            }
            if (MouseButton.Right.Pressed())
            {
                Weapon2.Shoot(World.Current.cam.FromWH(Mouse.Position, App.Width, App.Height));
            }
            var targetVel = new Vec2(vx, vy).Unit *Speed;

            Velocity += Vec2.Clamp(targetVel - Velocity, Accel * dt);
            Weapon2.Update(dt);
            Weapon1.Update(dt);
        }