diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-02-22 20:28:19 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-02-22 20:28:19 -0300 |
commit | 7ca29bfaa7a23d06374c2456e0360c911bd9aa3e (patch) | |
tree | dc615e0c7a55dff92af81be0ff2555e1f9485eba /demos/2d/kinematic_col | |
parent | b62ec387f340220e11902daab8484fcb85d28cda (diff) |
-added kinematic body
-added kinematic body demos
Diffstat (limited to 'demos/2d/kinematic_col')
-rw-r--r-- | demos/2d/kinematic_col/colworld.scn | bin | 0 -> 2941 bytes | |||
-rw-r--r-- | demos/2d/kinematic_col/engine.cfg | 12 | ||||
-rw-r--r-- | demos/2d/kinematic_col/icon.png | bin | 0 -> 1426 bytes | |||
-rw-r--r-- | demos/2d/kinematic_col/obstacle.png | bin | 0 -> 453 bytes | |||
-rw-r--r-- | demos/2d/kinematic_col/player.gd | 36 | ||||
-rw-r--r-- | demos/2d/kinematic_col/player.png | bin | 0 -> 502 bytes | |||
-rw-r--r-- | demos/2d/kinematic_col/player.scn | bin | 0 -> 1495 bytes |
7 files changed, 48 insertions, 0 deletions
diff --git a/demos/2d/kinematic_col/colworld.scn b/demos/2d/kinematic_col/colworld.scn Binary files differnew file mode 100644 index 0000000000..064ff12075 --- /dev/null +++ b/demos/2d/kinematic_col/colworld.scn diff --git a/demos/2d/kinematic_col/engine.cfg b/demos/2d/kinematic_col/engine.cfg new file mode 100644 index 0000000000..654288a9bd --- /dev/null +++ b/demos/2d/kinematic_col/engine.cfg @@ -0,0 +1,12 @@ +[application] + +name="Kinematic Collision" +main_scene="res://colworld.scn" +icon="res://icon.png" + +[input] + +move_up=[key(Up)] +move_left=[key(Left)] +move_right=[key(Right)] +move_bottom=[key(Down)] diff --git a/demos/2d/kinematic_col/icon.png b/demos/2d/kinematic_col/icon.png Binary files differnew file mode 100644 index 0000000000..2774de6110 --- /dev/null +++ b/demos/2d/kinematic_col/icon.png diff --git a/demos/2d/kinematic_col/obstacle.png b/demos/2d/kinematic_col/obstacle.png Binary files differnew file mode 100644 index 0000000000..693f115a98 --- /dev/null +++ b/demos/2d/kinematic_col/obstacle.png diff --git a/demos/2d/kinematic_col/player.gd b/demos/2d/kinematic_col/player.gd new file mode 100644 index 0000000000..36784a9d9f --- /dev/null +++ b/demos/2d/kinematic_col/player.gd @@ -0,0 +1,36 @@ + +extends KinematicBody2D + +# This is a simple collision demo showing how +# the kinematic cotroller works. +# move() will allow to move the node, and will +# always move it to a non-colliding spot, +# as long as it starts from a non-colliding spot too. + + +#pixels / second +const MOTION_SPEED=160 + +func _fixed_process(delta): + + var motion = Vector2() + + if (Input.is_action_pressed("move_up")): + motion+=Vector2(0,-1) + if (Input.is_action_pressed("move_bottom")): + motion+=Vector2(0,1) + if (Input.is_action_pressed("move_left")): + motion+=Vector2(-1,0) + if (Input.is_action_pressed("move_right")): + motion+=Vector2(1,0) + + motion = motion.normalized() * MOTION_SPEED * delta + move(motion) + + +func _ready(): + # Initalization here + set_fixed_process(true) + pass + + diff --git a/demos/2d/kinematic_col/player.png b/demos/2d/kinematic_col/player.png Binary files differnew file mode 100644 index 0000000000..0e7d843899 --- /dev/null +++ b/demos/2d/kinematic_col/player.png diff --git a/demos/2d/kinematic_col/player.scn b/demos/2d/kinematic_col/player.scn Binary files differnew file mode 100644 index 0000000000..e558bffe8e --- /dev/null +++ b/demos/2d/kinematic_col/player.scn |