mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 12:35:53 +00:00
Fixes for prisms
This commit is contained in:
parent
dbb81b7642
commit
f25bce557d
3 changed files with 45 additions and 32 deletions
|
|
@ -8,6 +8,12 @@ public partial class Prism : Area2D
|
|||
[Export] public float RotationSpeed { get; set; } = 0f;
|
||||
|
||||
private Sprite2D _sprite;
|
||||
|
||||
[Export] public float[] Angles { get; set; } = [-90f, -45f, 180f, 45f, 90f];
|
||||
|
||||
private int _angleIndex = 0;
|
||||
|
||||
private double _rotateTimer = 0;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -22,13 +28,25 @@ public partial class Prism : Area2D
|
|||
{
|
||||
if (RotationSpeed > 0)
|
||||
{
|
||||
var angleDifference = (float)(RotationSpeed * delta);
|
||||
var newAngle = ReflectionAngle + angleDifference;
|
||||
if (newAngle > 360)
|
||||
_rotateTimer += delta;
|
||||
}
|
||||
|
||||
if (_rotateTimer > RotationSpeed)
|
||||
{
|
||||
_rotateTimer = 0;
|
||||
_angleIndex++;
|
||||
if (_angleIndex >= Angles.Length)
|
||||
{
|
||||
newAngle = 0;
|
||||
|
||||
_angleIndex = 0;
|
||||
}
|
||||
//var angleDifference = (float)(RotationSpeed * delta);
|
||||
//var newAngle = ReflectionAngle + angleDifference;
|
||||
// if (newAngle > 360)
|
||||
// {
|
||||
// newAngle = 0;
|
||||
//
|
||||
// }
|
||||
var newAngle = Angles[_angleIndex];
|
||||
SetReflectionAngle(newAngle);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue