From 0b806ee0fc9097fa7bda7ac0109191c9c5e0a1ac Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 9 Feb 2014 22:10:30 -0300 Subject: GODOT IS OPEN SOURCE --- demos/2d/platformer/moving_platform.gd | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 demos/2d/platformer/moving_platform.gd (limited to 'demos/2d/platformer/moving_platform.gd') diff --git a/demos/2d/platformer/moving_platform.gd b/demos/2d/platformer/moving_platform.gd new file mode 100644 index 0000000000..719d9e460e --- /dev/null +++ b/demos/2d/platformer/moving_platform.gd @@ -0,0 +1,27 @@ + +extends Node2D + +# member variables here, example: +# var a=2 +# var b="textvar" + +export var motion = Vector2() +export var cycle = 1.0 +var accum=0.0 + +func _fixed_process(delta): + + accum += delta * (1.0/cycle) * PI * 2.0 + accum = fmod(accum,PI*2.0) + var d = sin(accum) + var xf = Matrix32() + xf[2]= motion * d + get_node("platform").set_transform(xf) + + +func _ready(): + # Initalization here + set_fixed_process(true) + pass + + -- cgit v1.2.3