Files
FOU/Scripts/Elements/Dirt.cs
2023-10-17 14:33:21 +02:00

28 lines
763 B
C#

using Godot;
namespace FOU.Scripts.Elements;
public class Dirt : Solid {
public Dirt(int x, int y, ref Level level) : base(x, y, ref level) {
Color = Colors.Brown;
Color.R += (GD.Randf() - 1) * MaxColorVariance;
Color.G += (GD.Randf() - 1) * MaxColorVariance;
Color.B += (GD.Randf() - 1) * MaxColorVariance;
}
public override bool Update(int currentFrame) {
if (!base.Update(currentFrame)) return false;
Vector2I freePos = Check(this, Vector2I.Down + Vector2I.Right);
if (freePos != Vector2I.Zero) { // diagonally right
Level.Swap(this, freePos);
return true;
}
return true; // not necessarily end, subclasses could do some more things
}
}