From 8c4f19e79d3e8ac8bc8c283073dce5ccfbf222b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 21 Nov 2015 13:31:25 +0100 Subject: Use upper-cased first letter at the start of comment sentences --- demos/3d/kinematic_char/cubio.gd | 10 ++-- demos/3d/kinematic_char/follow_camera.gd | 14 ++--- demos/3d/mousepick_test/mousepick.gd | 4 +- demos/3d/navmesh/navmesh.gd | 4 +- demos/3d/platformer/bullet.gd | 4 +- demos/3d/platformer/coin.gd | 4 +- demos/3d/platformer/enemy.gd | 6 +-- demos/3d/platformer/follow_camera.gd | 89 +++++++++++++------------------- demos/3d/platformer/player.gd | 34 ++++++------ demos/3d/truck_town/car_select.gd | 2 +- demos/3d/truck_town/follow_camera.gd | 14 ++--- demos/3d/truck_town/vehicle.gd | 2 +- 12 files changed, 86 insertions(+), 101 deletions(-) (limited to 'demos/3d') diff --git a/demos/3d/kinematic_char/cubio.gd b/demos/3d/kinematic_char/cubio.gd index d2bd00bd0f..c4d8276181 100644 --- a/demos/3d/kinematic_char/cubio.gd +++ b/demos/3d/kinematic_char/cubio.gd @@ -1,7 +1,7 @@ extends KinematicBody -# member variables +# Member variables var g = -9.8 var vel = Vector3() const MAX_SPEED = 5 @@ -12,7 +12,7 @@ const MAX_SLOPE_ANGLE = 30 func _fixed_process(delta): - var dir = Vector3() #where does the player intend to walk to + var dir = Vector3() # Where does the player intend to walk to var cam_xform = get_node("target/camera").get_global_transform() if (Input.is_action_pressed("move_forward")): @@ -49,13 +49,13 @@ func _fixed_process(delta): var on_floor = false var original_vel = vel var floor_velocity = Vector3() - var attempts=4 + var attempts = 4 while(is_colliding() and attempts): var n = get_collision_normal() if (rad2deg(acos(n.dot(Vector3(0, 1, 0)))) < MAX_SLOPE_ANGLE): - # if angle to the "up" vectors is < angle tolerance + # If angle to the "up" vectors is < angle tolerance, # char is on floor floor_velocity = get_collider_velocity() on_floor = true @@ -63,7 +63,7 @@ func _fixed_process(delta): motion = n.slide(motion) vel = n.slide(vel) if (original_vel.dot(vel) > 0): - # do not allow to slide towads the opposite direction we were coming from + # Do not allow to slide towads the opposite direction we were coming from motion=move(motion) if (motion.length() < 0.001): break diff --git a/demos/3d/kinematic_char/follow_camera.gd b/demos/3d/kinematic_char/follow_camera.gd index 852b20a398..37a1402053 100644 --- a/demos/3d/kinematic_char/follow_camera.gd +++ b/demos/3d/kinematic_char/follow_camera.gd @@ -1,7 +1,7 @@ extends Camera -# member variables +# Member variables var collision_exception = [] export var min_distance = 0.5 export var max_distance = 4.0 @@ -19,15 +19,15 @@ func _fixed_process(dt): var delta = pos - target - # regular delta follow + # Regular delta follow - # check ranges + # Check ranges if (delta.length() < min_distance): delta = delta.normalized()*min_distance elif (delta.length() > max_distance): delta = delta.normalized()*max_distance - # check upper and lower height + # Check upper and lower height if (delta.y > max_height): delta.y = max_height if (delta.y < min_height): @@ -37,14 +37,14 @@ func _fixed_process(dt): look_at_from_pos(pos, target, up) - # turn a little up or down + # Turn a little up or down var t = get_transform() t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis set_transform(t) func _ready(): - # find collision exceptions for ray + # Find collision exceptions for ray var node = self while(node): if (node extends RigidBody): @@ -53,5 +53,5 @@ func _ready(): else: node = node.get_parent() set_fixed_process(true) - # this detaches the camera transform from the parent spatial node + # This detaches the camera transform from the parent spatial node set_as_toplevel(true) diff --git a/demos/3d/mousepick_test/mousepick.gd b/demos/3d/mousepick_test/mousepick.gd index c250c7f084..674ec7ff6f 100644 --- a/demos/3d/mousepick_test/mousepick.gd +++ b/demos/3d/mousepick_test/mousepick.gd @@ -1,9 +1,9 @@ extends RigidBody -# member variables +# Member variables var gray_mat = FixedMaterial.new() -var selected=false +var selected = false func _input_event(camera, event, pos, normal, shape): diff --git a/demos/3d/navmesh/navmesh.gd b/demos/3d/navmesh/navmesh.gd index 87b0e1d2cc..f3eaf766d2 100644 --- a/demos/3d/navmesh/navmesh.gd +++ b/demos/3d/navmesh/navmesh.gd @@ -1,7 +1,7 @@ extends Navigation -# member variables +# Member variables const SPEED = 4.0 var camrot = 0.0 @@ -11,7 +11,7 @@ var end = Vector3() var m = FixedMaterial.new() var path = [] -var draw_path=false +var draw_path = false func _process(delta): diff --git a/demos/3d/platformer/bullet.gd b/demos/3d/platformer/bullet.gd index 4709273535..29219403bd 100644 --- a/demos/3d/platformer/bullet.gd +++ b/demos/3d/platformer/bullet.gd @@ -1,5 +1,5 @@ extends RigidBody -# member variables -var disabled=false +# Member variables +var disabled = false diff --git a/demos/3d/platformer/coin.gd b/demos/3d/platformer/coin.gd index ef84014931..bd2eea81e2 100644 --- a/demos/3d/platformer/coin.gd +++ b/demos/3d/platformer/coin.gd @@ -1,11 +1,11 @@ extends Area -# member variables +# Member variables var taken = false func _on_coin_body_enter(body): if (not taken and body extends preload("res://player.gd")): get_node("anim").play("take") - taken=true + taken = true diff --git a/demos/3d/platformer/enemy.gd b/demos/3d/platformer/enemy.gd index 61671c7bd3..55c79e4858 100644 --- a/demos/3d/platformer/enemy.gd +++ b/demos/3d/platformer/enemy.gd @@ -1,7 +1,7 @@ extends RigidBody -# member variables +# Member variables const STATE_WALKING = 0 const STATE_DYING = 1 @@ -20,9 +20,9 @@ func _integrate_forces(state): var lv = state.get_linear_velocity() var g = state.get_total_gravity() - lv += g*delta # apply gravity + lv += g*delta # Apply gravity var up = -g.normalized() - + if (dying): state.set_linear_velocity(lv) return diff --git a/demos/3d/platformer/follow_camera.gd b/demos/3d/platformer/follow_camera.gd index 3d18327df0..d0d531b9a5 100644 --- a/demos/3d/platformer/follow_camera.gd +++ b/demos/3d/platformer/follow_camera.gd @@ -1,95 +1,80 @@ extends Camera -# member variables here, example: -# var a=2 -# var b="textvar" - -var collision_exception=[] -export var min_distance=0.5 -export var max_distance=4.0 -export var angle_v_adjust=0.0 -export var autoturn_ray_aperture=25 -export var autoturn_speed=50 +# Member variables +var collision_exception = [] +export var min_distance = 0.5 +export var max_distance = 4.0 +export var angle_v_adjust = 0.0 +export var autoturn_ray_aperture = 25 +export var autoturn_speed = 50 var max_height = 2.0 var min_height = 0 func _fixed_process(dt): - var target = get_parent().get_global_transform().origin + var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin - var up = Vector3(0,1,0) + var up = Vector3(0, 1, 0) var delta = pos - target - #regular delta follow - - #check ranges + # Regular delta follow + # Check ranges if (delta.length() < min_distance): - delta = delta.normalized() * min_distance + delta = delta.normalized()*min_distance elif (delta.length() > max_distance): - delta = delta.normalized() * max_distance + delta = delta.normalized()*max_distance - #check upper and lower height - if ( delta.y > max_height): + # Check upper and lower height + if (delta.y > max_height): delta.y = max_height - if ( delta.y < min_height): + if (delta.y < min_height): delta.y = min_height - #check autoturn - - var ds = PhysicsServer.space_get_direct_state( get_world().get_space() ) - + # Check autoturn + var ds = PhysicsServer.space_get_direct_state(get_world().get_space()) - var col_left = ds.intersect_ray(target,target+Matrix3(up,deg2rad(autoturn_ray_aperture)).xform(delta),collision_exception) - var col = ds.intersect_ray(target,target+delta,collision_exception) - var col_right = ds.intersect_ray(target,target+Matrix3(up,deg2rad(-autoturn_ray_aperture)).xform(delta),collision_exception) + var col_left = ds.intersect_ray(target, target + Matrix3(up, deg2rad(autoturn_ray_aperture)).xform(delta), collision_exception) + var col = ds.intersect_ray(target, target + delta, collision_exception) + var col_right = ds.intersect_ray(target, target + Matrix3(up, deg2rad(-autoturn_ray_aperture)).xform(delta), collision_exception) if (!col.empty()): - #if main ray was occluded, get camera closer, this is the worst case scenario + # If main ray was occluded, get camera closer, this is the worst case scenario delta = col.position - target elif (!col_left.empty() and col_right.empty()): - #if only left ray is occluded, turn the camera around to the right - delta = Matrix3(up,deg2rad(-dt*autoturn_speed)).xform(delta) + # If only left ray is occluded, turn the camera around to the right + delta = Matrix3(up, deg2rad(-dt*autoturn_speed)).xform(delta) elif (col_left.empty() and !col_right.empty()): - #if only right ray is occluded, turn the camera around to the left - delta = Matrix3(up,deg2rad(dt*autoturn_speed)).xform(delta) + # If only right ray is occluded, turn the camera around to the left + delta = Matrix3(up, deg2rad(dt*autoturn_speed)).xform(delta) else: - #do nothing otherwise, left and right are occluded but center is not, so do not autoturn + # Do nothing otherwise, left and right are occluded but center is not, so do not autoturn pass - #apply lookat - if (delta==Vector3()): - delta = (pos - target).normalized() * 0.0001 + # Apply lookat + if (delta == Vector3()): + delta = (pos - target).normalized()*0.0001 pos = target + delta - look_at_from_pos(pos,target,up) + look_at_from_pos(pos, target, up) - #turn a little up or down + # Turn a little up or down var t = get_transform() - t.basis = Matrix3(t.basis[0],deg2rad(angle_v_adjust)) * t.basis + t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis set_transform(t) - - -func _ready(): -#find collision exceptions for ray +func _ready(): + # Find collision exceptions for ray var node = self while(node): if (node extends RigidBody): collision_exception.append(node.get_rid()) break else: - node=node.get_parent() - # Initalization here + node = node.get_parent() set_fixed_process(true) - #this detaches the camera transform from the parent spatial node + # This detaches the camera transform from the parent spatial node set_as_toplevel(true) - - - - - - diff --git a/demos/3d/platformer/player.gd b/demos/3d/platformer/player.gd index f299f885ed..4cac1817e4 100644 --- a/demos/3d/platformer/player.gd +++ b/demos/3d/platformer/player.gd @@ -1,7 +1,7 @@ extends RigidBody -# member variables +# Member variables const ANIM_FLOOR = 0 const ANIM_AIR_UP = 1 const ANIM_AIR_DOWN = 2 @@ -14,14 +14,14 @@ const CHAR_SCALE = Vector3(0.3, 0.3, 0.3) var facing_dir = Vector3(1, 0, 0) var movement_dir = Vector3() -var jumping=false +var jumping = false var turn_speed = 40 var keep_jump_inertia = true var air_idle_deaccel = false var accel = 19.0 var deaccel = 14.0 -var sharp_turn_threshhold = 140 +var sharp_turn_threshold = 140 var max_speed = 3.1 var on_floor = false @@ -34,7 +34,7 @@ var shoot_blend = 0 func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): - var n = p_target # normal + var n = p_target # Normal var t = n.cross(current_gn).normalized() var x = n.dot(p_facing) @@ -42,7 +42,7 @@ func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): var ang = atan2(y,x) - if (abs(ang) < 0.001): # too small + if (abs(ang) < 0.001): # Too small return p_facing var s = sign(ang) @@ -59,22 +59,22 @@ func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): func _integrate_forces(state): - var lv = state.get_linear_velocity() # linear velocity + var lv = state.get_linear_velocity() # Linear velocity var g = state.get_total_gravity() var delta = state.get_step() # var d = 1.0 - delta*state.get_total_density() # if (d < 0): # d = 0 - lv += g*delta # apply gravity + lv += g*delta # Apply gravity var anim = ANIM_FLOOR var up = -g.normalized() # (up is against gravity) - var vv = up.dot(lv) # vertical velocity - var hv = lv - up*vv # horizontal velocity + var vv = up.dot(lv) # Vertical velocity + var hv = lv - up*vv # Horizontal velocity - var hdir = hv.normalized() # horizontal direction - var hspeed = hv.length() # horizontal speed + var hdir = hv.normalized() # Horizontal direction + var hspeed = hv.length() # Horizontal speed var floor_velocity var onfloor = false @@ -90,7 +90,7 @@ func _integrate_forces(state): floor_velocity = state.get_contact_collider_velocity_at_pos(i) break - var dir = Vector3() # where does the player intend to walk to + var dir = Vector3() # Where does the player intend to walk to var cam_xform = get_node("target/camera").get_global_transform() if (Input.is_action_pressed("move_forward")): @@ -108,7 +108,7 @@ func _integrate_forces(state): var target_dir = (dir - up*dir.dot(up)).normalized() if (onfloor): - var sharp_turn = hspeed > 0.1 and rad2deg(acos(target_dir.dot(hdir))) > sharp_turn_threshhold + var sharp_turn = hspeed > 0.1 and rad2deg(acos(target_dir.dot(hdir))) > sharp_turn_threshold if (dir.length() > 0.1 and !sharp_turn): if (hspeed > 0.001): @@ -130,7 +130,7 @@ func _integrate_forces(state): hv = hdir*hspeed - var mesh_xform = get_node("Armature").get_transform() + var mesh_xform = get_node("Armature").get_transform() var facing_mesh = -mesh_xform.basis[0].normalized() facing_mesh = (facing_mesh - up*facing_mesh.dot(up)).normalized() facing_mesh = adjust_facing(facing_mesh, target_dir, delta, 1.0/hspeed*turn_speed, up) @@ -171,7 +171,7 @@ func _integrate_forces(state): #lv += floor_velocity last_floor_velocity = floor_velocity else: - if (on_floor) : + if (on_floor): #if (keep_jump_inertia): # lv += last_floor_velocity pass @@ -180,7 +180,7 @@ func _integrate_forces(state): movement_dir = lv on_floor = onfloor - + state.set_linear_velocity(lv) if (shoot_blend > 0): @@ -194,7 +194,7 @@ func _integrate_forces(state): bullet.set_transform(get_node("Armature/bullet").get_global_transform().orthonormalized()) get_parent().add_child(bullet) bullet.set_linear_velocity(get_node("Armature/bullet").get_global_transform().basis[2].normalized()*20) - PS.body_add_collision_exception(bullet.get_rid(), get_rid()) # add it to bullet + PS.body_add_collision_exception(bullet.get_rid(), get_rid()) # Add it to bullet get_node("sfx").play("shoot") prev_shoot = shoot_attempt diff --git a/demos/3d/truck_town/car_select.gd b/demos/3d/truck_town/car_select.gd index 62383a8b9a..4efcf63426 100644 --- a/demos/3d/truck_town/car_select.gd +++ b/demos/3d/truck_town/car_select.gd @@ -1,7 +1,7 @@ extends Control -# member variables +# Member variables var town = null diff --git a/demos/3d/truck_town/follow_camera.gd b/demos/3d/truck_town/follow_camera.gd index 5e6324db73..7c6a0a2ba6 100644 --- a/demos/3d/truck_town/follow_camera.gd +++ b/demos/3d/truck_town/follow_camera.gd @@ -1,7 +1,7 @@ extends Camera -# member variables +# Member variables var collision_exception = [] export var min_distance = 0.5 export var max_distance = 4.0 @@ -19,15 +19,15 @@ func _fixed_process(dt): var delta = pos - target - # regular delta follow + # Regular delta follow - # check ranges + # Check ranges if (delta.length() < min_distance): delta = delta.normalized()*min_distance elif (delta.length() > max_distance): delta = delta.normalized()*max_distance - # check upper and lower height + # Check upper and lower height if ( delta.y > max_height): delta.y = max_height if ( delta.y < min_height): @@ -37,14 +37,14 @@ func _fixed_process(dt): look_at_from_pos(pos, target, up) - # turn a little up or down + # Turn a little up or down var t = get_transform() t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis set_transform(t) func _ready(): - # find collision exceptions for ray + # Find collision exceptions for ray var node = self while(node): if (node extends RigidBody): @@ -53,5 +53,5 @@ func _ready(): else: node = node.get_parent() set_fixed_process(true) - # this detaches the camera transform from the parent spatial node + # This detaches the camera transform from the parent spatial node set_as_toplevel(true) diff --git a/demos/3d/truck_town/vehicle.gd b/demos/3d/truck_town/vehicle.gd index 1c9bd2e891..22c5b7f0d4 100644 --- a/demos/3d/truck_town/vehicle.gd +++ b/demos/3d/truck_town/vehicle.gd @@ -1,7 +1,7 @@ extends VehicleBody -# member variables +# Member variables const STEER_SPEED = 1 const STEER_LIMIT = 0.4 -- cgit v1.2.3