added falling sand - dirt actually
This commit is contained in:
@@ -2,6 +2,44 @@
|
||||
|
||||
namespace FOU.Scripts.Elements;
|
||||
|
||||
public abstract class Element {
|
||||
public class Element {
|
||||
public Color Color = Colors.Black;
|
||||
|
||||
public int X;
|
||||
public int Y;
|
||||
|
||||
protected Level _level;
|
||||
|
||||
private int _lastUpdate = -1;
|
||||
|
||||
public Element(int x, int y, ref Level level) {
|
||||
X = x;
|
||||
Y = y;
|
||||
_level = level;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// base update method, checks if anything is to do at all
|
||||
/// </summary>
|
||||
/// <param name="currentFrame"></param>
|
||||
/// <returns>false if there is nothing to do</returns>
|
||||
public virtual bool Update(int currentFrame) {
|
||||
if (_lastUpdate == currentFrame) return false; // already updated this frame
|
||||
_lastUpdate = currentFrame;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"{X}:{Y}";
|
||||
}
|
||||
|
||||
protected bool CheckBelow(int x, int y) {
|
||||
if (y+1 >= _level.SizeY) return false;
|
||||
|
||||
if (_level.Get(x, y+1).GetType() == GetType())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user