7589b2bf60
The scripts were streamlined using more or less the following conventions: - space after a comma in lists of arguments - spaces around weak operators (+, -), no spaces around strong operators (*, /) - spaces around comparison operators and compound assignment operators - space after a comment start (#) - removed trailing spaces or tabs, apart from those that delimit the function indentation level (those could be removed too but since they are added automatically by the editor when typing code, keeping them for now) - function blocks separate by two newlines - comment sentences start with an upper-case letter
32 lines
779 B
GDScript
32 lines
779 B
GDScript
|
|
extends KinematicBody2D
|
|
|
|
# This is a simple collision demo showing how
|
|
# the kinematic controller 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.
|
|
|
|
# Member variables
|
|
const MOTION_SPEED = 160 # Pixels/second
|
|
|
|
|
|
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)
|