A Smoll game engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

40 lignes
1.3 KiB

using System.Numerics;
using Raylib_cs;
namespace Smoll.Ex1 {
class RectangleGizmoComponent : Smoll.Component {
Complex size;
Color color;
Transform2DComponent? ownerTransform;
public RectangleGizmoComponent(int width, int height, Color color)
{
this.size = width + Complex.ImaginaryOne*height;
this.color = color;
}
public override void OnAttached() {
ownerTransform = owner.GetComponent<Transform2DComponent>();
}
public override void Draw(Smoll.Layer.DrawMode drawMode) {
ownerTransform ??= owner.GetComponent<Transform2DComponent>();
ownerTransform ??= new Transform2DComponent();
var tr = ownerTransform.AbsoluteTransform();
Raylib.DrawRectanglePro(
new Rectangle(
(float)tr.position.Real,
(float)tr.position.Imaginary,
(float)(size.Real*tr.scale.Real),
(float)(size.Imaginary*tr.scale.Imaginary)
),
new Vector2(
(float)(tr.anchor.Real - tr.position.Real),
(float)(tr.anchor.Imaginary - tr.position.Imaginary)
),
tr.angle,
color
);
}
}
}