mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
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.
25 lines
561 B
GDScript
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)
|