Files
godot-demo-projects/2d/hexagonal_map/troll.gd
Rémi Verschelde faae60ac2f Port 2D demos to Godot 3.1
Opened them, saved all scenes, ran the project. Did necessary fixes here and there,
fixed some warnings (but some remain in bigger demos).

Did not port JRPG demo yet (#306) nor the two platformer demos.
2019-02-26 14:22:02 +01:00

25 lines
561 B
GDScript

extends KinematicBody2D
# This is a demo showing how KinematicBody2D
# move_and_slide works.
# Member variables
const MOTION_SPEED = 160 # Pixels/second
func _physics_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
move_and_slide(motion)