A Smoll game engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

35 строки
1.5 KiB

11 месяцев назад
10 месяцев назад
11 месяцев назад
11 месяцев назад
11 месяцев назад
11 месяцев назад
11 месяцев назад
11 месяцев назад
11 месяцев назад
  1. using Smoll;
  2. using Raylib_cs;
  3. using System.Numerics;
  4. using Smoll.Ex3;
  5. namespace Smoll.Ex1
  6. {
  7. class ExampleInputComponent : Component {
  8. InertiaComponent? transform;
  9. public float speedPixelPerSecond;
  10. public float angularSpeedTurnPerSecond;
  11. public ExampleInputComponent(float speedPixelPerSecond, float angularSpeedTurnPerSecond) {
  12. this.speedPixelPerSecond = speedPixelPerSecond;
  13. this.angularSpeedTurnPerSecond = angularSpeedTurnPerSecond;
  14. }
  15. public override void OnAttached()
  16. {
  17. base.OnAttached();
  18. transform = owner.GetComponent<InertiaComponent>();
  19. }
  20. public override void Update(float deltaTimeSeconds)
  21. {
  22. transform ??= owner.GetComponent<InertiaComponent>();
  23. if(transform == null) throw new Exception("Example Input used on immovable object");
  24. transform.transform.position -= Raylib.IsKeyDown(KeyboardKey.Up) * speedPixelPerSecond * deltaTimeSeconds * Complex.ImaginaryOne;
  25. transform.transform.position += Raylib.IsKeyDown(KeyboardKey.Down) * speedPixelPerSecond * deltaTimeSeconds * Complex.ImaginaryOne;
  26. transform.transform.position -= Raylib.IsKeyDown(KeyboardKey.Left) * speedPixelPerSecond * deltaTimeSeconds;
  27. transform.transform.position += Raylib.IsKeyDown(KeyboardKey.Right) * speedPixelPerSecond * deltaTimeSeconds;
  28. transform.transform.angle += Raylib.IsKeyDown(KeyboardKey.L) * angularSpeedTurnPerSecond * 2 * float.Pi * deltaTimeSeconds;
  29. }
  30. }
  31. }