Răsfoiți Sursa

added BasicElement for default usage

ncannasse 10 ani în urmă
părinte
comite
3f2fac4e05
1 a modificat fișierele cu 21 adăugiri și 0 ștergeri
  1. 21 0
      h2d/SpriteBatch.hx

+ 21 - 0
h2d/SpriteBatch.hx

@@ -56,6 +56,27 @@ class BatchElement {
 
 }
 
+class BasicElement extends BatchElement {
+
+	public var vx : Float = 0.;
+	public var vy : Float = 0.;
+	public var friction : Float = 1.;
+	public var gravity : Float = 0.;
+
+	override function update(dt:Float) {
+		vy += gravity * dt;
+		x += vx * dt;
+		y += vy * dt;
+		if( friction != 1 ) {
+			var p = Math.pow(friction, dt * 60);
+			vx *= p;
+			vy *= p;
+		}
+		return true;
+	}
+
+}
+
 class SpriteBatch extends Drawable {
 
 	public var tile : Tile;