diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2015-11-21 16:13:43 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2015-12-09 08:39:12 +0100 |
commit | 7589b2bf605b58fbb0e34dec8ae833708e9b54ea (patch) | |
tree | 6c6b6515be9d121127f738a586fd95299ca7018a /demos/2d/hexamap | |
parent | 323dde7f3164477b3d51fda8352d8b37a19f7f9d (diff) |
Improve code formatting
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
Diffstat (limited to 'demos/2d/hexamap')
-rw-r--r-- | demos/2d/hexamap/troll.gd | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/demos/2d/hexamap/troll.gd b/demos/2d/hexamap/troll.gd index d118d3a2ba..0e4d7ce535 100644 --- a/demos/2d/hexamap/troll.gd +++ b/demos/2d/hexamap/troll.gd @@ -2,42 +2,38 @@ extends KinematicBody2D # This is a simple collision demo showing how -# the kinematic cotroller works. +# 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 -#pixels / second -const MOTION_SPEED=160 func _fixed_process(delta): - var motion = Vector2() if (Input.is_action_pressed("move_up")): - motion+=Vector2(0,-1) + motion += Vector2(0, -1) if (Input.is_action_pressed("move_bottom")): - motion+=Vector2(0,1) + motion += Vector2(0, 1) if (Input.is_action_pressed("move_left")): - motion+=Vector2(-1,0) + motion += Vector2(-1, 0) if (Input.is_action_pressed("move_right")): - motion+=Vector2(1,0) + motion += Vector2(1, 0) - motion = motion.normalized() * MOTION_SPEED * delta + motion = motion.normalized()*MOTION_SPEED*delta motion = move(motion) - #make character slide nicely through the world + # Make character slide nicely through the world var slide_attempts = 4 - while(is_colliding() and slide_attempts>0): + while(is_colliding() and slide_attempts > 0): motion = get_collision_normal().slide(motion) - motion=move(motion) - slide_attempts-=1 - + motion = move(motion) + slide_attempts -= 1 + func _ready(): # Initalization here set_fixed_process(true) - pass - - |