浏览代码

added BasicElement for default usage

ncannasse 10 年之前
父节点
当前提交
3f2fac4e05
共有 1 个文件被更改,包括 21 次插入0 次删除
  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 {
 class SpriteBatch extends Drawable {
 
 
 	public var tile : Tile;
 	public var tile : Tile;