summaryrefslogtreecommitdiff
path: root/demos/2d/lookat/lookat.gd
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2015-11-21 16:13:43 +0100
committerRémi Verschelde <rverschelde@gmail.com>2015-12-09 08:39:12 +0100
commit7589b2bf605b58fbb0e34dec8ae833708e9b54ea (patch)
tree6c6b6515be9d121127f738a586fd95299ca7018a /demos/2d/lookat/lookat.gd
parent323dde7f3164477b3d51fda8352d8b37a19f7f9d (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/lookat/lookat.gd')
-rw-r--r--demos/2d/lookat/lookat.gd37
1 files changed, 14 insertions, 23 deletions
diff --git a/demos/2d/lookat/lookat.gd b/demos/2d/lookat/lookat.gd
index 742c5b0671..25b5e638d7 100644
--- a/demos/2d/lookat/lookat.gd
+++ b/demos/2d/lookat/lookat.gd
@@ -1,43 +1,34 @@
extends Sprite
-# member variables here, example:
-# var a=2
-# var b="textvar"
-
-const MODE_DIRECT=0
-const MODE_CONSTANT=1
-const MODE_SMOOTH=2
+# Member variables
+const MODE_DIRECT = 0
+const MODE_CONSTANT = 1
+const MODE_SMOOTH = 2
const ROTATION_SPEED = 1
const SMOOTH_SPEED = 2.0
-export(int,"Direct","Constant","Smooth") var mode=MODE_DIRECT
+export(int, "Direct", "Constant", "Smooth") var mode = MODE_DIRECT
+
func _process(delta):
var mpos = get_viewport().get_mouse_pos()
- if (mode==MODE_DIRECT):
-
+ if (mode == MODE_DIRECT):
look_at(mpos)
-
- elif (mode==MODE_CONSTANT):
-
+ elif (mode == MODE_CONSTANT):
var ang = get_angle_to(mpos)
var s = sign(ang)
- ang=abs(ang)
-
- rotate( min(ang,ROTATION_SPEED*delta)*s )
+ ang = abs(ang)
- elif (mode==MODE_SMOOTH):
-
- var ang = get_angle_to(mpos)
+ rotate(min(ang, ROTATION_SPEED*delta)*s)
+ elif (mode == MODE_SMOOTH):
+ var ang = get_angle_to(mpos)
- rotate( ang*delta*SMOOTH_SPEED )
+ rotate(ang*delta*SMOOTH_SPEED)
+
func _ready():
# Initialization here
set_process(true)
- pass
-
-