From 238b5f001c8d330f83cad33a843a54ebc358530c Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 2 Oct 2025 15:47:59 -0700 Subject: [PATCH] [2.1] Simplify list of branches in the README (#1255) --- .editorconfig | 2 + .github/workflows/static_checks.yml | 19 +++++ .gitignore | 1 + 2d/area_input/input.gd | 1 - 2d/dynamic_collision_shapes/ball.gd | 1 - .../dynamic_colobjs.gd | 1 - 2d/fog_of_war/fog.gd | 11 ++- 2d/fog_of_war/troll.gd | 7 +- 2d/hdr/beach_cave.gd | 1 - 2d/hexamap/troll.gd | 9 ++- 2d/isometric/troll.gd | 9 ++- 2d/isometric_light/cubio.gd | 11 ++- 2d/isometric_light/map.gd | 1 - 2d/isometric_light/shoot.gd | 1 - 2d/kinematic_char/colworld.gd | 1 - 2d/kinematic_char/player.gd | 43 ++++++----- 2d/kinematic_col/player.gd | 7 +- 2d/lookat/lookat.gd | 7 +- 2d/motion/motion.gd | 1 - 2d/navpoly/navigation.gd | 7 +- 2d/platformer/bullet.gd | 1 - 2d/platformer/coin.gd | 1 - 2d/platformer/enemy.gd | 17 +++-- 2d/platformer/moving_platform.gd | 3 +- 2d/platformer/player.gd | 53 +++++++------- 2d/platformer_kcc/bullet.gd | 3 +- 2d/platformer_kcc/coin.gd | 7 +- 2d/platformer_kcc/enemy.gd | 25 ++++--- 2d/platformer_kcc/moving_platform.gd | 3 +- 2d/platformer_kcc/player.gd | 55 +++++++------- 2d/pong/pong.gd | 23 +++--- 2d/screen_space_shaders/screen_shaders.gd | 1 - 2d/shower_of_bullets/bullets.gd | 15 ++-- 2d/shower_of_bullets/shower.gd | 1 - 2d/space_shooter/README.md | 6 +- 2d/space_shooter/enemies/asteroid/asteroid.gd | 2 +- 2d/space_shooter/enemies/shooter/enemy2.gd | 8 +-- .../enemies/shooter/enemy_shot.gd | 2 +- 2d/space_shooter/enemies/ufo/enemy1.gd | 3 +- 2d/space_shooter/enemies/ufo/enemy1_rail.gd | 2 +- 2d/space_shooter/game_screen/hud/game_hud.gd | 8 +-- 2d/space_shooter/game_screen/level/level.gd | 4 +- .../game_screen/level/level_map.gd | 2 +- 2d/space_shooter/game_state.gd | 8 +-- 2d/space_shooter/main_menu/main_menu.gd | 2 +- 2d/space_shooter/player/ship.gd | 17 +++-- 2d/split_screen_platformer/bullet.gd | 1 - 2d/split_screen_platformer/coin.gd | 1 - 2d/split_screen_platformer/enemy.gd | 17 +++-- 2d/split_screen_platformer/moving_platform.gd | 3 +- 2d/split_screen_platformer/player.gd | 53 +++++++------- 2d/split_screen_platformer/split_stage.gd | 2 +- 2d/tetris/grid.gd | 17 +++-- 2d/texscreen/bubbles.gd | 1 - 2d/texscreen/lens.gd | 7 +- 3d/fixed_materials/s.xml | 2 +- 3d/kinematic_char/cubio.gd | 31 ++++---- 3d/kinematic_char/follow_camera.gd | 15 ++-- 3d/mousepick_test/mousepick.gd | 3 +- 3d/navmesh/navmesh.gd | 11 ++- 3d/platformer/bullet.gd | 1 - 3d/platformer/coin.gd | 2 - 3d/platformer/enemy.gd | 23 +++--- 3d/platformer/follow_camera.gd | 23 +++--- 3d/platformer/player.gd | 71 +++++++++---------- 3d/shader_materials/s.xml | 2 +- 3d/truck_town/car_select.gd | 1 - 3d/truck_town/follow_camera.gd | 15 ++-- 3d/truck_town/vehicle.gd | 9 ++- README.md | 21 ++---- file_format.sh | 55 ++++++++++++++ gui/drag_and_drop/drag_drop_script.gd | 1 - gui/rich_text_bbcode/OFL.txt | 2 +- gui/rich_text_bbcode/rich_text_bbcode.gd | 1 - gui/translation/controls.gd | 1 - gui/translation/main.gd | 1 - gui/translation/text.csv | 2 +- misc/android_iap/iap.gd | 1 - misc/android_iap/iap_demo.gd | 3 +- misc/autoload/global.gd | 12 ++-- misc/pause/spinpause.gd | 1 - misc/regex/regex.gd | 1 - misc/scene_changer/scene_a.gd | 1 - misc/scene_changer/scene_b.gd | 1 - misc/threads/thread.gd | 1 - misc/tween/main.gd | 46 ++++++------ misc/udp_chat/chat.gd | 5 +- misc/window_management/control.gd | 70 +++++++++--------- misc/window_management/observer/observer.gd | 1 - plugins/custom_dock/dock_plugin.gd | 7 +- plugins/custom_import_plugin/import_plugin.gd | 1 - .../custom_import_plugin/material_dialog.gd | 18 ++--- .../custom_import_plugin/material_import.gd | 13 ++-- plugins/custom_node/heart_plugin.gd | 1 - plugins/readme.txt | 2 +- viewport/2d_in_3d/pong.gd | 23 +++--- viewport/2d_in_3d/pong3d.gd | 1 - viewport/gui_in_3d/gui_3d.gd | 1 - viewport/screen_capture/screen_capture.gd | 1 - 99 files changed, 500 insertions(+), 519 deletions(-) create mode 100644 .github/workflows/static_checks.yml create mode 100755 file_format.sh diff --git a/.editorconfig b/.editorconfig index 20f8d9a0..2d69cd4d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,8 @@ # Top-most EditorConfig file. root = true +# Unix-style newlines with a newline ending every file. [*] charset = utf-8 end_of_line = lf +insert_final_newline = true diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 00000000..ff91de42 --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,19 @@ +name: Static Checks +on: [push, pull_request] + +jobs: + format: + name: File formatting (file_format.sh) + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq dos2unix recode + + - name: File formatting checks (file_format.sh) + run: | + bash ./file_format.sh diff --git a/.gitignore b/.gitignore index e0b51db7..2b039c25 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ mono_crash.*.json # System/tool-specific ignores .directory +.DS_Store *~ diff --git a/2d/area_input/input.gd b/2d/area_input/input.gd index e9cc9f3c..dcca40e2 100644 --- a/2d/area_input/input.gd +++ b/2d/area_input/input.gd @@ -1,4 +1,3 @@ - extends Area2D diff --git a/2d/dynamic_collision_shapes/ball.gd b/2d/dynamic_collision_shapes/ball.gd index 169079ea..c9833f78 100644 --- a/2d/dynamic_collision_shapes/ball.gd +++ b/2d/dynamic_collision_shapes/ball.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Member variables diff --git a/2d/dynamic_collision_shapes/dynamic_colobjs.gd b/2d/dynamic_collision_shapes/dynamic_colobjs.gd index c43b82a7..bafd62cb 100644 --- a/2d/dynamic_collision_shapes/dynamic_colobjs.gd +++ b/2d/dynamic_collision_shapes/dynamic_colobjs.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables diff --git a/2d/fog_of_war/fog.gd b/2d/fog_of_war/fog.gd index 3ac8df0e..52e5fd06 100644 --- a/2d/fog_of_war/fog.gd +++ b/2d/fog_of_war/fog.gd @@ -1,4 +1,3 @@ - extends TileMap # Member variables @@ -30,7 +29,7 @@ var l = range(2, 5) # Process that runs in realtime func _fixed_process(delta): position = get_node("../troll").get_pos() - + # Calculate the corresponding tile # from the players position x = int(position.x/get_cell_size().x) @@ -38,11 +37,11 @@ func _fixed_process(delta): # causes problems because of rounding problems if position.x < 0: x -= 1 # Correct negative values - + y = int(position.y/get_cell_size().y) if (position.y < 0): y -= 1 - + # Check if the player moved one tile further if ((x_old != x) or (y_old != y)): # Create the transparent part (visited area) @@ -55,7 +54,7 @@ func _fixed_process(delta): set_cell(m, n, 1, 0, 0) end -= 1 start += 1 - + # Create the actual and active visible part var end = l.size() - 1 var start = 0 @@ -65,7 +64,7 @@ func _fixed_process(delta): set_cell(m, n, -1) end -= 1 start += 1 - + x_old = x y_old = y diff --git a/2d/fog_of_war/troll.gd b/2d/fog_of_war/troll.gd index 6f40072e..fc4ec57d 100644 --- a/2d/fog_of_war/troll.gd +++ b/2d/fog_of_war/troll.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D # This is a simple collision demo showing how @@ -13,7 +12,7 @@ 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")): @@ -22,10 +21,10 @@ func _fixed_process(delta): motion += Vector2(-1, 0) if (Input.is_action_pressed("move_right")): motion += Vector2(1, 0) - + motion = motion.normalized()*MOTION_SPEED*delta motion = move(motion) - + # Make character slide nicely through the world var slide_attempts = 4 while(is_colliding() and slide_attempts > 0): diff --git a/2d/hdr/beach_cave.gd b/2d/hdr/beach_cave.gd index fcc878e5..2ad0fa71 100644 --- a/2d/hdr/beach_cave.gd +++ b/2d/hdr/beach_cave.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables diff --git a/2d/hexamap/troll.gd b/2d/hexamap/troll.gd index 82938fdf..fc4ec57d 100644 --- a/2d/hexamap/troll.gd +++ b/2d/hexamap/troll.gd @@ -1,10 +1,9 @@ - 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, +# always move it to a non-colliding spot, # as long as it starts from a non-colliding spot too. # Member variables @@ -13,7 +12,7 @@ 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")): @@ -22,10 +21,10 @@ func _fixed_process(delta): motion += Vector2(-1, 0) if (Input.is_action_pressed("move_right")): motion += Vector2(1, 0) - + motion = motion.normalized()*MOTION_SPEED*delta motion = move(motion) - + # Make character slide nicely through the world var slide_attempts = 4 while(is_colliding() and slide_attempts > 0): diff --git a/2d/isometric/troll.gd b/2d/isometric/troll.gd index d8d4880d..f9c2b9f1 100644 --- a/2d/isometric/troll.gd +++ b/2d/isometric/troll.gd @@ -1,10 +1,9 @@ - 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, +# always move it to a non-colliding spot, # as long as it starts from a non-colliding spot too. # Member variables @@ -13,7 +12,7 @@ const MOTION_SPEED = 160 # Pixels/seconds 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")): @@ -22,10 +21,10 @@ func _fixed_process(delta): motion += Vector2(-1, 0) if (Input.is_action_pressed("move_right")): motion += Vector2(1, 0) - + motion = motion.normalized()*MOTION_SPEED*delta motion = move(motion) - + # Make character slide nicely through the world var slide_attempts = 4 while(is_colliding() and slide_attempts > 0): diff --git a/2d/isometric_light/cubio.gd b/2d/isometric_light/cubio.gd index a26d5ae6..a7dfb502 100644 --- a/2d/isometric_light/cubio.gd +++ b/2d/isometric_light/cubio.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D # Member variables @@ -37,14 +36,14 @@ func _fixed_process(delta): dir += Vector2(-1, 0) if (Input.is_action_pressed("right")): dir += Vector2(1, 0) - + if (dir != Vector2()): dir = dir.normalized() speed = speed.linear_interpolate(dir*MAX_SPEED, delta*ACCEL) var motion = speed*delta motion.y *= VSCALE motion = move(motion) - + if (is_colliding()): var n = get_collision_normal() motion = n.slide(motion) @@ -52,13 +51,13 @@ func _fixed_process(delta): var next_anim = "" var next_mirror = false - + if (dir == Vector2() and speed.length() < IDLE_SPEED): next_anim = "idle" next_mirror = false elif (speed.length() > IDLE_SPEED*0.1): var angle = atan2(abs(speed.x), speed.y) - + next_mirror = speed.x > 0 if (angle < PI/8): next_anim = "bottom" @@ -72,7 +71,7 @@ func _fixed_process(delta): else: next_anim = "top" next_mirror = false - + if (next_anim != current_anim or next_mirror != current_mirror): get_node("frames").set_flip_h(next_mirror) get_node("anim").play(next_anim) diff --git a/2d/isometric_light/map.gd b/2d/isometric_light/map.gd index 6b790ddf..8d2f3bfe 100644 --- a/2d/isometric_light/map.gd +++ b/2d/isometric_light/map.gd @@ -1,4 +1,3 @@ - extends Node2D diff --git a/2d/isometric_light/shoot.gd b/2d/isometric_light/shoot.gd index b48d4ad3..a1f60d37 100644 --- a/2d/isometric_light/shoot.gd +++ b/2d/isometric_light/shoot.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D # Member variables diff --git a/2d/kinematic_char/colworld.gd b/2d/kinematic_char/colworld.gd index 7926ef9d..c5048dff 100644 --- a/2d/kinematic_char/colworld.gd +++ b/2d/kinematic_char/colworld.gd @@ -1,4 +1,3 @@ - extends Node2D diff --git a/2d/kinematic_char/player.gd b/2d/kinematic_char/player.gd index 2890cc2c..33226a56 100644 --- a/2d/kinematic_char/player.gd +++ b/2d/kinematic_char/player.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D # This is a simple collision demo showing how @@ -32,13 +31,13 @@ var prev_jump_pressed = false func _fixed_process(delta): # Create forces var force = Vector2(0, GRAVITY) - + var walk_left = Input.is_action_pressed("move_left") var walk_right = Input.is_action_pressed("move_right") var jump = Input.is_action_pressed("jump") - + var stop = true - + if (walk_left): if (velocity.x <= WALK_MIN_SPEED and velocity.x > -WALK_MAX_SPEED): force.x -= WALK_FORCE @@ -47,50 +46,50 @@ func _fixed_process(delta): if (velocity.x >= -WALK_MIN_SPEED and velocity.x < WALK_MAX_SPEED): force.x += WALK_FORCE stop = false - + if (stop): var vsign = sign(velocity.x) var vlen = abs(velocity.x) - + vlen -= STOP_FORCE*delta if (vlen < 0): vlen = 0 - + velocity.x = vlen*vsign - + # Integrate forces to velocity velocity += force*delta - + # Integrate velocity into motion and move var motion = velocity*delta - + # Move and consume motion motion = move(motion) - + var floor_velocity = Vector2() - + if (is_colliding()): # You can check which tile was collision against with this # print(get_collider_metadata()) - + # Ran against something, is it the floor? Get normal var n = get_collision_normal() - + if (rad2deg(acos(n.dot(Vector2(0, -1)))) < FLOOR_ANGLE_TOLERANCE): # If angle to the "up" vectors is < angle tolerance # char is on floor on_air_time = 0 floor_velocity = get_collider_velocity() - + if (on_air_time == 0 and force.x == 0 and get_travel().length() < SLIDE_STOP_MIN_TRAVEL and abs(velocity.x) < SLIDE_STOP_VELOCITY and get_collider_velocity() == Vector2()): - # Since this formula will always slide the character around, - # a special case must be considered to to stop it from moving + # Since this formula will always slide the character around, + # a special case must be considered to to stop it from moving # if standing on an inclined floor. Conditions are: # 1) Standing on floor (on_air_time == 0) # 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL) # 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY) # 4) Collider is not moving - + revert_motion() velocity.y = 0.0 else: @@ -100,21 +99,21 @@ func _fixed_process(delta): velocity = n.slide(velocity) # Then move again move(motion) - + if (floor_velocity != Vector2()): # If floor moves, move with floor move(floor_velocity*delta) - + if (jumping and velocity.y > 0): # If falling, no longer jumping jumping = false - + if (on_air_time < JUMP_MAX_AIRBORNE_TIME and jump and not prev_jump_pressed and not jumping): # Jump must also be allowed to happen if the character left the floor a little bit ago. # Makes controls more snappy. velocity.y = -JUMP_SPEED jumping = true - + on_air_time += delta prev_jump_pressed = jump diff --git a/2d/kinematic_col/player.gd b/2d/kinematic_col/player.gd index ce09e150..bfbbbf49 100644 --- a/2d/kinematic_col/player.gd +++ b/2d/kinematic_col/player.gd @@ -1,10 +1,9 @@ - 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, +# always move it to a non-colliding spot, # as long as it starts from a non-colliding spot too. # Member variables @@ -13,7 +12,7 @@ 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")): @@ -22,7 +21,7 @@ func _fixed_process(delta): motion += Vector2(-1, 0) if (Input.is_action_pressed("move_right")): motion += Vector2(1, 0) - + motion = motion.normalized()*MOTION_SPEED*delta move(motion) diff --git a/2d/lookat/lookat.gd b/2d/lookat/lookat.gd index c45c3ad6..20cb928b 100644 --- a/2d/lookat/lookat.gd +++ b/2d/lookat/lookat.gd @@ -1,4 +1,3 @@ - extends Sprite # Member variables @@ -14,18 +13,18 @@ export(int, "Direct", "Constant", "Smooth") var mode = MODE_DIRECT func _process(delta): var mpos = get_viewport().get_mouse_pos() - + if (mode == MODE_DIRECT): look_at(mpos) elif (mode == MODE_CONSTANT): var ang = get_angle_to(mpos) var s = sign(ang) ang = abs(ang) - + rotate(min(ang, ROTATION_SPEED*delta)*s) elif (mode == MODE_SMOOTH): var ang = get_angle_to(mpos) - + rotate(ang*delta*SMOOTH_SPEED) diff --git a/2d/motion/motion.gd b/2d/motion/motion.gd index f9bbd6f9..4c9f8275 100644 --- a/2d/motion/motion.gd +++ b/2d/motion/motion.gd @@ -1,4 +1,3 @@ - extends Sprite # Member variables diff --git a/2d/navpoly/navigation.gd b/2d/navpoly/navigation.gd index 4cfa2ad7..c46e3745 100644 --- a/2d/navpoly/navigation.gd +++ b/2d/navpoly/navigation.gd @@ -1,4 +1,3 @@ - extends Navigation2D # Member variables @@ -22,10 +21,10 @@ func _process(delta): else: path[path.size() - 1] = pfrom.linear_interpolate(pto, to_walk/d) to_walk = 0 - + var atpos = path[path.size() - 1] get_node("agent").set_pos(atpos) - + if (path.size() < 2): path = [] set_process(false) @@ -37,7 +36,7 @@ func _update_path(): var p = get_simple_path(begin, end, true) path = Array(p) # Vector2array too complex to use, convert to regular array path.invert() - + set_process(true) diff --git a/2d/platformer/bullet.gd b/2d/platformer/bullet.gd index 3aee6971..9d585260 100644 --- a/2d/platformer/bullet.gd +++ b/2d/platformer/bullet.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Member variables diff --git a/2d/platformer/coin.gd b/2d/platformer/coin.gd index 11187327..3c39f777 100644 --- a/2d/platformer/coin.gd +++ b/2d/platformer/coin.gd @@ -1,4 +1,3 @@ - extends Area2D # Member variables diff --git a/2d/platformer/enemy.gd b/2d/platformer/enemy.gd index 5a4d8af5..ed267bcf 100644 --- a/2d/platformer/enemy.gd +++ b/2d/platformer/enemy.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Member variables @@ -36,13 +35,13 @@ func _integrate_forces(s): new_anim = "explode" elif (state == STATE_WALKING): new_anim = "walk" - + var wall_side = 0.0 - + for i in range(s.get_contact_count()): var cc = s.get_contact_collider_object(i) var dp = s.get_contact_local_normal(i) - + if (cc): if (cc extends bullet_class and not cc.disabled): set_mode(MODE_RIGID) @@ -53,12 +52,12 @@ func _integrate_forces(s): cc.disable() get_node("sound").play("hit") break - + if (dp.x > 0.9): wall_side = 1.0 elif (dp.x < -0.9): wall_side = -1.0 - + if (wall_side != 0 and wall_side != direction): direction = -direction get_node("sprite").set_scale(Vector2(-direction, 1)) @@ -68,13 +67,13 @@ func _integrate_forces(s): elif (direction > 0 and not rc_right.is_colliding() and rc_left.is_colliding()): direction = -direction get_node("sprite").set_scale(Vector2(-direction, 1)) - + lv.x = direction*WALK_SPEED - + if(anim != new_anim): anim = new_anim get_node("anim").play(anim) - + s.set_linear_velocity(lv) diff --git a/2d/platformer/moving_platform.gd b/2d/platformer/moving_platform.gd index 21c312d5..e5f17029 100644 --- a/2d/platformer/moving_platform.gd +++ b/2d/platformer/moving_platform.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables @@ -12,7 +11,7 @@ func _fixed_process(delta): accum = fmod(accum, PI*2.0) var d = sin(accum) var xf = Matrix32() - xf[2]= motion*d + xf[2]= motion*d get_node("platform").set_transform(xf) diff --git a/2d/platformer/player.gd b/2d/platformer/player.gd index 693f93a0..9d666031 100644 --- a/2d/platformer/player.gd +++ b/2d/platformer/player.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Character Demo, written by Juan Linietsky. @@ -14,12 +13,12 @@ extends RigidBody2D # -Interaction with other physics-based objects is free # -Only have to deal with the object linear velocity, not position # -All collision/area framework available -# +# # But also has the following disadvantages: -# +# # -Objects may bounce a little bit sometimes # -Going up ramps sends the chracter flying up, small hack is needed. -# -A ray collider is needed to avoid sliding down on ramps and +# -A ray collider is needed to avoid sliding down on ramps and # undesiderd bumps, small steps and rare numerical precision errors. # (another alternative may be to turn on friction when the character is not moving). # -Friction cant be used, so floor velocity must be considered @@ -56,38 +55,38 @@ var enemy func _integrate_forces(s): var lv = s.get_linear_velocity() var step = s.get_step() - + var new_anim = anim var new_siding_left = siding_left - + # Get the controls var move_left = Input.is_action_pressed("move_left") var move_right = Input.is_action_pressed("move_right") var jump = Input.is_action_pressed("jump") var shoot = Input.is_action_pressed("shoot") var spawn = Input.is_action_pressed("spawn") - + if spawn: var e = enemy.instance() var p = get_pos() p.y = p.y - 100 e.set_pos(p) get_parent().add_child(e) - + # Deapply prev floor velocity lv.x -= floor_h_velocity floor_h_velocity = 0.0 - + # Find the floor (a contact with upwards facing collision normal) var found_floor = false var floor_index = -1 - + for x in range(s.get_contact_count()): var ci = s.get_contact_local_normal(x) if (ci.dot(Vector2(0, -1)) > 0.6): found_floor = true floor_index = x - + # A good idea when impementing characters of all kinds, # compensates for physics imprecission, as well as human reaction delay. if (shoot and not shooting): @@ -99,22 +98,22 @@ func _integrate_forces(s): else: ss = 1.0 var pos = get_pos() + get_node("bullet_shoot").get_pos()*Vector2(ss, 1.0) - + bi.set_pos(pos) get_parent().add_child(bi) - + bi.set_linear_velocity(Vector2(800.0*ss, -80)) get_node("sprite/smoke").set_emitting(true) get_node("sound").play("shoot") PS2D.body_add_collision_exception(bi.get_rid(), get_rid()) # Make bullet and this not collide else: shoot_time += step - + if (found_floor): airborne_time = 0.0 else: airborne_time += step # Time it spent in the air - + var on_floor = airborne_time < MAX_FLOOR_AIRBORNE_TIME # Process jump @@ -132,10 +131,10 @@ func _integrate_forces(s): jumping = false elif (not jump): stopping_jump = true - + if (stopping_jump): lv.y += STOP_JUMP_FORCE*step - + if (on_floor): # Process logic when character is on floor if (move_left and not move_right): @@ -150,14 +149,14 @@ func _integrate_forces(s): if (xv < 0): xv = 0 lv.x = sign(lv.x)*xv - + # Check jump if (not jumping and jump): lv.y = -JUMP_VELOCITY jumping = true stopping_jump = false get_node("sound").play("jump") - + # Check siding if (lv.x < 0 and move_left): new_siding_left = true @@ -189,7 +188,7 @@ func _integrate_forces(s): if (xv < 0): xv = 0 lv.x = sign(lv.x)*xv - + if (lv.y < 0): if (shoot_time < MAX_SHOOT_POSE_TIME): new_anim = "jumping_weapon" @@ -200,28 +199,28 @@ func _integrate_forces(s): new_anim = "falling_weapon" else: new_anim = "falling" - + # Update siding if (new_siding_left != siding_left): if (new_siding_left): get_node("sprite").set_scale(Vector2(-1, 1)) else: get_node("sprite").set_scale(Vector2(1, 1)) - + siding_left = new_siding_left - + # Change animation if (new_anim != anim): anim = new_anim get_node("anim").play(anim) - + shooting = shoot - + # Apply floor velocity if (found_floor): floor_h_velocity = s.get_contact_collider_velocity_at_pos(floor_index).x lv.x += floor_h_velocity - + # Finally, apply gravity and set back the linear velocity lv += s.get_total_gravity()*step s.set_linear_velocity(lv) @@ -229,7 +228,7 @@ func _integrate_forces(s): func _ready(): enemy = ResourceLoader.load("res://enemy.tscn") - + # if !Globals.has_singleton("Facebook"): # return # var Facebook = Globals.get_singleton("Facebook") diff --git a/2d/platformer_kcc/bullet.gd b/2d/platformer_kcc/bullet.gd index 5bfa2505..b1a84e75 100644 --- a/2d/platformer_kcc/bullet.gd +++ b/2d/platformer_kcc/bullet.gd @@ -1,9 +1,8 @@ - extends RigidBody2D func _on_bullet_body_enter( body ): if (body.has_method("hit_by_bullet")): body.call("hit_by_bullet") - + func _on_Timer_timeout(): get_node("anim").play("shutdown") diff --git a/2d/platformer_kcc/coin.gd b/2d/platformer_kcc/coin.gd index f7c0e44b..c93f0f6f 100644 --- a/2d/platformer_kcc/coin.gd +++ b/2d/platformer_kcc/coin.gd @@ -1,11 +1,10 @@ - extends Area2D - + var taken=false func _on_coin_body_enter( body ): - + if (not taken and body extends preload("res://player.gd")): get_node("anim").play("taken") taken=true - + diff --git a/2d/platformer_kcc/enemy.gd b/2d/platformer_kcc/enemy.gd index 4c1375db..8b02ec7d 100644 --- a/2d/platformer_kcc/enemy.gd +++ b/2d/platformer_kcc/enemy.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D @@ -22,35 +21,35 @@ onready var detect_wall_right = get_node("detect_wall_right") onready var sprite = get_node("sprite") func _fixed_process(delta): - + var new_anim="idle" - + if (state==STATE_WALKING): - + linear_velocity+= GRAVITY_VEC*delta linear_velocity.x = direction * WALK_SPEED linear_velocity = move_and_slide( linear_velocity, FLOOR_NORMAL ) - + if (not detect_floor_left.is_colliding() or detect_wall_left.is_colliding()): direction=1.0 - + if (not detect_floor_right.is_colliding() or detect_wall_right.is_colliding()): direction=-1.0 - + sprite.set_scale( Vector2(direction,1.0) ) - + new_anim="walk" else: new_anim="explode" - + if (anim!=new_anim): anim=new_anim get_node("anim").play(anim) - - - + + + func hit_by_bullet(): - state=STATE_KILLED + state=STATE_KILLED func _ready(): set_fixed_process(true) diff --git a/2d/platformer_kcc/moving_platform.gd b/2d/platformer_kcc/moving_platform.gd index 21c312d5..e5f17029 100644 --- a/2d/platformer_kcc/moving_platform.gd +++ b/2d/platformer_kcc/moving_platform.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables @@ -12,7 +11,7 @@ func _fixed_process(delta): accum = fmod(accum, PI*2.0) var d = sin(accum) var xf = Matrix32() - xf[2]= motion*d + xf[2]= motion*d get_node("platform").set_transform(xf) diff --git a/2d/platformer_kcc/player.gd b/2d/platformer_kcc/player.gd index f7ef7d23..039388d2 100644 --- a/2d/platformer_kcc/player.gd +++ b/2d/platformer_kcc/player.gd @@ -1,4 +1,3 @@ - extends KinematicBody2D const GRAVITY_VEC = Vector2(0,900) @@ -12,7 +11,7 @@ const BULLET_VELOCITY = 1000 const SHOOT_TIME_SHOW_WEAPON = 0.2 var linear_vel = Vector2() -var onair_time = 0 # +var onair_time = 0 # var on_floor = false var shoot_time=99999 #time since last shot var shooting = false @@ -23,69 +22,69 @@ var anim="" onready var sprite = get_node("sprite") func _fixed_process(delta): - + #increment counters - + onair_time+=delta shoot_time+=delta - - + + ### MOVEMENT ### - + # Apply Gravity linear_vel += delta * GRAVITY_VEC # Move and Slide linear_vel = move_and_slide( linear_vel, FLOOR_NORMAL, SLOPE_SLIDE_STOP ) # Detect Floor if (is_move_and_slide_on_floor()): - onair_time=0 - + onair_time=0 + on_floor = onair_time < MIN_ONAIR_TIME - + ### CONTROL ### - + # Horizontal Movement var target_speed = 0 if (Input.is_action_pressed("move_left")): target_speed += -1 if (Input.is_action_pressed("move_right")): target_speed += 1 - + target_speed *= WALK_SPEED linear_vel.x = lerp( linear_vel.x, target_speed, 0.1 ) - + # Jumping if (on_floor and Input.is_action_pressed("jump")): linear_vel.y=-JUMP_SPEED get_node("sound").play("jump") - - # Shooting - + + # Shooting + var shoot = Input.is_action_pressed("shoot") - + if (shoot and not shooting): - + var bullet = preload("res://bullet.tscn").instance() bullet.set_pos( get_node("sprite/bullet_shoot").get_global_pos() ) #use node for shoot position - bullet.set_linear_velocity( Vector2( sprite.get_scale().x * BULLET_VELOCITY,0 ) ) + bullet.set_linear_velocity( Vector2( sprite.get_scale().x * BULLET_VELOCITY,0 ) ) bullet.add_collision_exception_with(self) # don't want player to collide with bullet get_parent().add_child( bullet ) #don't want bullet to move with me, so add it as child of parent get_node("sound").play("shoot") shoot_time=0 - + ### ANIMATION ### - + var new_anim="idle" - + if (on_floor): if (linear_vel.x < -SIDING_CHANGE_SPEED): sprite.set_scale( Vector2( -1, 1 ) ) new_anim="run" - + if (linear_vel.x > SIDING_CHANGE_SPEED): sprite.set_scale( Vector2( 1, 1 ) ) new_anim="run" - + else: # We want the character to immediately change facing side when the player # tries to change direction, during air control. @@ -99,16 +98,16 @@ func _fixed_process(delta): new_anim="jumping" else: new_anim="falling" - + if (shoot_time < SHOOT_TIME_SHOW_WEAPON): new_anim+="_weapon" - + if (new_anim!=anim): anim=new_anim get_node("anim").play(anim) - + shooting = shoot - + func _ready(): set_fixed_process(true) diff --git a/2d/pong/pong.gd b/2d/pong/pong.gd index 81afbd99..009d6cff 100644 --- a/2d/pong/pong.gd +++ b/2d/pong/pong.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables @@ -17,47 +16,47 @@ func _process(delta): var ball_pos = get_node("ball").get_pos() var left_rect = Rect2(get_node("left").get_pos() - pad_size*0.5, pad_size) var right_rect = Rect2(get_node("right").get_pos() - pad_size*0.5, pad_size) - + # Integrate new ball postion ball_pos += direction*ball_speed*delta - + # Flip when touching roof or floor if ((ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > screen_size.y and direction.y > 0)): direction.y = -direction.y - + # Flip, change direction and increase speed when touching pads if ((left_rect.has_point(ball_pos) and direction.x < 0) or (right_rect.has_point(ball_pos) and direction.x > 0)): direction.x = -direction.x ball_speed *= 1.1 direction.y = randf()*2.0 - 1 direction = direction.normalized() - + # Check gameover if (ball_pos.x < 0 or ball_pos.x > screen_size.x): ball_pos = screen_size*0.5 ball_speed = INITIAL_BALL_SPEED direction = Vector2(-1, 0) - + get_node("ball").set_pos(ball_pos) - + # Move left pad var left_pos = get_node("left").get_pos() - + if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")): left_pos.y += -PAD_SPEED*delta if (left_pos.y < screen_size.y and Input.is_action_pressed("left_move_down")): left_pos.y += PAD_SPEED*delta - + get_node("left").set_pos(left_pos) - + # Move right pad var right_pos = get_node("right").get_pos() - + if (right_pos.y > 0 and Input.is_action_pressed("right_move_up")): right_pos.y += -PAD_SPEED*delta if (right_pos.y < screen_size.y and Input.is_action_pressed("right_move_down")): right_pos.y += PAD_SPEED*delta - + get_node("right").set_pos(right_pos) diff --git a/2d/screen_space_shaders/screen_shaders.gd b/2d/screen_space_shaders/screen_shaders.gd index b847a9c9..0cf2bf81 100644 --- a/2d/screen_space_shaders/screen_shaders.gd +++ b/2d/screen_space_shaders/screen_shaders.gd @@ -1,4 +1,3 @@ - extends Control diff --git a/2d/shower_of_bullets/bullets.gd b/2d/shower_of_bullets/bullets.gd index e0eba268..1d09bb91 100644 --- a/2d/shower_of_bullets/bullets.gd +++ b/2d/shower_of_bullets/bullets.gd @@ -1,4 +1,3 @@ - extends Node2D # This demo is an example of controling a high number of 2D objects with logic and collision without using scene nodes. @@ -35,37 +34,37 @@ func _process(delta): if (b.pos.x < -30): b.pos.x += width mat.o = b.pos - + Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat) - + update() func _ready(): shape = Physics2DServer.shape_create(Physics2DServer.SHAPE_CIRCLE) Physics2DServer.shape_set_data(shape, 8) # Radius - + for i in range(BULLET_COUNT): var b = Bullet.new() b.speed = rand_range(SPEED_MIN, SPEED_MAX) b.body = Physics2DServer.body_create(Physics2DServer.BODY_MODE_KINEMATIC) Physics2DServer.body_set_space(b.body, get_world_2d().get_space()) Physics2DServer.body_add_shape(b.body, shape) - + b.pos = Vector2(get_viewport_rect().size * Vector2(randf()*2.0, randf())) # Twice as long b.pos.x += get_viewport_rect().size.x # Start outside var mat = Matrix32() mat.o = b.pos Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat) - + bullets.append(b) - + set_process(true) func _exit_tree(): for b in bullets: Physics2DServer.free_rid(b.body) - + Physics2DServer.free_rid(shape) bullets.clear() diff --git a/2d/shower_of_bullets/shower.gd b/2d/shower_of_bullets/shower.gd index 50c11094..41e877ae 100644 --- a/2d/shower_of_bullets/shower.gd +++ b/2d/shower_of_bullets/shower.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables diff --git a/2d/space_shooter/README.md b/2d/space_shooter/README.md index d951dbea..63cff305 100644 --- a/2d/space_shooter/README.md +++ b/2d/space_shooter/README.md @@ -1,9 +1,9 @@ # Space Shooter ## Introduction -In this on-rails shoot-em-up demo, the player gets to control a Space ship flying through a 2D version of Space, while firing their lasers by hitting the Space bar. -Various enemies will enter the screen from the right and try their hardest to destroy the player's ship. -Shooting these enemies will award points and the highest score achieved is kept in a one-entry leaderboard. +In this on-rails shoot-em-up demo, the player gets to control a Space ship flying through a 2D version of Space, while firing their lasers by hitting the Space bar. +Various enemies will enter the screen from the right and try their hardest to destroy the player's ship. +Shooting these enemies will award points and the highest score achieved is kept in a one-entry leaderboard. Avoiding the blocky obstacles and the enemies is key to survival and high scores, so good luck and have fun! ## Controls diff --git a/2d/space_shooter/enemies/asteroid/asteroid.gd b/2d/space_shooter/enemies/asteroid/asteroid.gd index e6dee047..5e1c1edf 100644 --- a/2d/space_shooter/enemies/asteroid/asteroid.gd +++ b/2d/space_shooter/enemies/asteroid/asteroid.gd @@ -34,7 +34,7 @@ func destroy(): # skip if already destroyed if (destroyed): return - + # set the state to destroyed destroyed = true # stop processing diff --git a/2d/space_shooter/enemies/shooter/enemy2.gd b/2d/space_shooter/enemies/shooter/enemy2.gd index 99bf653a..8f04e478 100644 --- a/2d/space_shooter/enemies/shooter/enemy2.gd +++ b/2d/space_shooter/enemies/shooter/enemy2.gd @@ -35,14 +35,14 @@ func _ready(): func _fixed_process(delta): # the enemy constantly moves translate(motion * delta) - + # count down the time until the next shot if shoot_timeout > 0.0: shoot_timeout -= delta - + if (shoot_timeout <= 0): shoot_timeout = SHOOT_INTERVAL - + if projectile_container != null: # Instance a shot var shot = Shot.instance() @@ -59,7 +59,7 @@ func destroy(): if (destroyed): return destroyed = true - + # stop processing set_fixed_process(false) # play on-death effects diff --git a/2d/space_shooter/enemies/shooter/enemy_shot.gd b/2d/space_shooter/enemies/shooter/enemy_shot.gd index 05e2d972..d91b6dbd 100644 --- a/2d/space_shooter/enemies/shooter/enemy_shot.gd +++ b/2d/space_shooter/enemies/shooter/enemy_shot.gd @@ -29,4 +29,4 @@ func _on_visibility_exit_screen(): func _on_enemy_shot_area_enter(area): if area.is_in_group("player"): - area.take_damage() \ No newline at end of file + area.take_damage() diff --git a/2d/space_shooter/enemies/ufo/enemy1.gd b/2d/space_shooter/enemies/ufo/enemy1.gd index 2ac38c48..234a3514 100644 --- a/2d/space_shooter/enemies/ufo/enemy1.gd +++ b/2d/space_shooter/enemies/ufo/enemy1.gd @@ -18,7 +18,7 @@ func destroy(): # skip if already destroyed if (destroyed): return - + # set the state to destroyed destroyed = true # play on-death effects @@ -38,4 +38,3 @@ func _on_visibility_enter_screen(): get_node("anim").seek(randf()*2.0) # as mentioned in _ready, show the node after seeking to the random start point in the animation show() - \ No newline at end of file diff --git a/2d/space_shooter/enemies/ufo/enemy1_rail.gd b/2d/space_shooter/enemies/ufo/enemy1_rail.gd index 2f06cdc0..f3275db3 100644 --- a/2d/space_shooter/enemies/ufo/enemy1_rail.gd +++ b/2d/space_shooter/enemies/ufo/enemy1_rail.gd @@ -21,7 +21,7 @@ func _ready(): # once the ship leaves the screen, remove the entire node visibility.connect("exit_screen", self, "queue_free") motion = Vector2(SPEED, 0) - + func _fixed_process(delta): # constant movement translate(motion * delta) diff --git a/2d/space_shooter/game_screen/hud/game_hud.gd b/2d/space_shooter/game_screen/hud/game_hud.gd index 3623f7b1..eb1db946 100644 --- a/2d/space_shooter/game_screen/hud/game_hud.gd +++ b/2d/space_shooter/game_screen/hud/game_hud.gd @@ -14,12 +14,12 @@ func _ready(): func _process(delta): if Input.is_action_pressed("ui_cancel"): _on_return_to_menu() - + func update_score(score): score_label.set_text(str(score)) - + func _on_return_to_menu(): emit_signal("return_to_menu") - + func game_over(): - game_over_label.show() \ No newline at end of file + game_over_label.show() diff --git a/2d/space_shooter/game_screen/level/level.gd b/2d/space_shooter/game_screen/level/level.gd index c13295ef..9f1463d5 100644 --- a/2d/space_shooter/game_screen/level/level.gd +++ b/2d/space_shooter/game_screen/level/level.gd @@ -28,6 +28,6 @@ func on_player_died(): func on_enemy_died(score): game_state.points += score hud.update_score(game_state.points) - + func on_return_to_menu(): - game_state.abort_game() \ No newline at end of file + game_state.abort_game() diff --git a/2d/space_shooter/game_screen/level/level_map.gd b/2d/space_shooter/game_screen/level/level_map.gd index 9e4485cf..89284cee 100644 --- a/2d/space_shooter/game_screen/level/level_map.gd +++ b/2d/space_shooter/game_screen/level/level_map.gd @@ -9,4 +9,4 @@ func _ready(): # find all enemies who need a projectile container because they can shoot if enemy.has_method("set_projectile_container"): # tell those enemies about the container - enemy.set_projectile_container(enemy_projectile_container) \ No newline at end of file + enemy.set_projectile_container(enemy_projectile_container) diff --git a/2d/space_shooter/game_state.gd b/2d/space_shooter/game_state.gd index d035c770..65f3b2b4 100644 --- a/2d/space_shooter/game_state.gd +++ b/2d/space_shooter/game_state.gd @@ -35,7 +35,7 @@ func start_game(): func abort_game(): _reset_game() - + menu = main_menu_scene.instance() get_tree().get_root().add_child(menu) @@ -50,7 +50,7 @@ func _reset_game(): game.hide() game.queue_free() game = null - + if menu != null: menu.hide() menu.queue_free() @@ -69,7 +69,7 @@ func _load_high_score(): max_points = f.get_var() # always close the file handle f.close() - + func _save_high_score(): var f = File.new() # try to open the highscore file in WRITE mode, which creates a new file if it doesn't exist @@ -77,4 +77,4 @@ func _save_high_score(): # store the max points as a godot Variant f.store_var(max_points) # always close the file handle - f.close() \ No newline at end of file + f.close() diff --git a/2d/space_shooter/main_menu/main_menu.gd b/2d/space_shooter/main_menu/main_menu.gd index faa2e3ec..18b8e63c 100644 --- a/2d/space_shooter/main_menu/main_menu.gd +++ b/2d/space_shooter/main_menu/main_menu.gd @@ -15,4 +15,4 @@ func _ready(): # the connection is set up on the "play" node, using the "Signals" sub-tab in the "Node" dock func _on_play_pressed(): # tell the game_state to start a new game, which resets the current score to 0 and switches to the level scene - game_state.start_game() \ No newline at end of file + game_state.start_game() diff --git a/2d/space_shooter/player/ship.gd b/2d/space_shooter/player/ship.gd index e71fd180..74bdd04b 100644 --- a/2d/space_shooter/player/ship.gd +++ b/2d/space_shooter/player/ship.gd @@ -29,29 +29,29 @@ func _fixed_process(delta): if Input.is_action_pressed("move_right"): motion += Vector2(1, 0) var shooting = Input.is_action_pressed("shoot") - + var pos = get_pos() - + # normally you would normalize the motion vector using motion.normalized(), so diagonal movement isn't faster # in this case, the base speed would make dodging the tilemap impossible in some places # additionally, it could be explained as the ship using both horizontal and vertical thrusters at once # the better solution in the long run would be to playtest the level and make sure that every passage is playable # pos += motion.normalized() * delta * SPEED pos += motion * delta * SPEED - + # limit the resulting position to the screen's dimensions, so the player can't fly off screen pos.x = clamp(pos.x, 0, screen_size.x) pos.y = clamp(pos.y, 0, screen_size.y) - + set_pos(pos) - + # tick down the shot cooldown if shot_timer > 0.0: shot_timer -= delta - + # the player can shoot if the timer is back to zero can_shoot = shot_timer <= 0.0 - + # if the player is alive, allowed to shoot and pressing space to shoot.. if (can_shoot and shooting and not killed): # instance a shot @@ -82,7 +82,7 @@ func _hit_something(): get_node("sfx").play("sound_explode") # notify listeners that the player died emit_signal("player_died") - # disable processing + # disable processing set_fixed_process(false) # the block tiles in a level have StaticBody2D colliders, touching them kills the player ship @@ -102,4 +102,3 @@ func set_projectile_container(container): # other objects (enemy projectiles) use this to tell the player ship that it was hit func take_damage(): _hit_something() - \ No newline at end of file diff --git a/2d/split_screen_platformer/bullet.gd b/2d/split_screen_platformer/bullet.gd index 3aee6971..9d585260 100644 --- a/2d/split_screen_platformer/bullet.gd +++ b/2d/split_screen_platformer/bullet.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Member variables diff --git a/2d/split_screen_platformer/coin.gd b/2d/split_screen_platformer/coin.gd index 11187327..3c39f777 100644 --- a/2d/split_screen_platformer/coin.gd +++ b/2d/split_screen_platformer/coin.gd @@ -1,4 +1,3 @@ - extends Area2D # Member variables diff --git a/2d/split_screen_platformer/enemy.gd b/2d/split_screen_platformer/enemy.gd index 5a4d8af5..ed267bcf 100644 --- a/2d/split_screen_platformer/enemy.gd +++ b/2d/split_screen_platformer/enemy.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Member variables @@ -36,13 +35,13 @@ func _integrate_forces(s): new_anim = "explode" elif (state == STATE_WALKING): new_anim = "walk" - + var wall_side = 0.0 - + for i in range(s.get_contact_count()): var cc = s.get_contact_collider_object(i) var dp = s.get_contact_local_normal(i) - + if (cc): if (cc extends bullet_class and not cc.disabled): set_mode(MODE_RIGID) @@ -53,12 +52,12 @@ func _integrate_forces(s): cc.disable() get_node("sound").play("hit") break - + if (dp.x > 0.9): wall_side = 1.0 elif (dp.x < -0.9): wall_side = -1.0 - + if (wall_side != 0 and wall_side != direction): direction = -direction get_node("sprite").set_scale(Vector2(-direction, 1)) @@ -68,13 +67,13 @@ func _integrate_forces(s): elif (direction > 0 and not rc_right.is_colliding() and rc_left.is_colliding()): direction = -direction get_node("sprite").set_scale(Vector2(-direction, 1)) - + lv.x = direction*WALK_SPEED - + if(anim != new_anim): anim = new_anim get_node("anim").play(anim) - + s.set_linear_velocity(lv) diff --git a/2d/split_screen_platformer/moving_platform.gd b/2d/split_screen_platformer/moving_platform.gd index 21c312d5..e5f17029 100644 --- a/2d/split_screen_platformer/moving_platform.gd +++ b/2d/split_screen_platformer/moving_platform.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables @@ -12,7 +11,7 @@ func _fixed_process(delta): accum = fmod(accum, PI*2.0) var d = sin(accum) var xf = Matrix32() - xf[2]= motion*d + xf[2]= motion*d get_node("platform").set_transform(xf) diff --git a/2d/split_screen_platformer/player.gd b/2d/split_screen_platformer/player.gd index efe23bae..7be3ad88 100644 --- a/2d/split_screen_platformer/player.gd +++ b/2d/split_screen_platformer/player.gd @@ -1,4 +1,3 @@ - extends RigidBody2D # Character Demo, written by Juan Linietsky. @@ -14,12 +13,12 @@ extends RigidBody2D # -Interaction with other physics-based objects is free # -Only have to deal with the object linear velocity, not position # -All collision/area framework available -# +# # But also has the following disadvantages: -# +# # -Objects may bounce a little bit sometimes # -Going up ramps sends the chracter flying up, small hack is needed. -# -A ray collider is needed to avoid sliding down on ramps and +# -A ray collider is needed to avoid sliding down on ramps and # undesiderd bumps, small steps and rare numerical precision errors. # (another alternative may be to turn on friction when the character is not moving). # -Friction cant be used, so floor velocity must be considered @@ -57,38 +56,38 @@ export(int, "Player 1", "Player 2") var index = 0 func _integrate_forces(s): var lv = s.get_linear_velocity() var step = s.get_step() - + var new_anim = anim var new_siding_left = siding_left - + # Get the controls var move_left = Input.is_action_pressed("move_left" + str(index)) var move_right = Input.is_action_pressed("move_right" + str(index)) var jump = Input.is_action_pressed("jump" + str(index)) var shoot = Input.is_action_pressed("shoot" + str(index)) var spawn = Input.is_action_pressed("spawn" + str(index)) - + if spawn: var e = enemy.instance() var p = get_pos() p.y = p.y - 100 e.set_pos(p) get_parent().add_child(e) - + # Deapply prev floor velocity lv.x -= floor_h_velocity floor_h_velocity = 0.0 - + # Find the floor (a contact with upwards facing collision normal) var found_floor = false var floor_index = -1 - + for x in range(s.get_contact_count()): var ci = s.get_contact_local_normal(x) if (ci.dot(Vector2(0, -1)) > 0.6): found_floor = true floor_index = x - + # A good idea when impementing characters of all kinds, # compensates for physics imprecission, as well as human reaction delay. if (shoot and not shooting): @@ -100,22 +99,22 @@ func _integrate_forces(s): else: ss = 1.0 var pos = get_pos() + get_node("bullet_shoot").get_pos()*Vector2(ss, 1.0) - + bi.set_pos(pos) get_parent().add_child(bi) - + bi.set_linear_velocity(Vector2(800.0*ss, -80)) get_node("sprite/smoke").set_emitting(true) get_node("sound").play("shoot") PS2D.body_add_collision_exception(bi.get_rid(), get_rid()) # Make bullet and this not collide else: shoot_time += step - + if (found_floor): airborne_time = 0.0 else: airborne_time += step # Time it spent in the air - + var on_floor = airborne_time < MAX_FLOOR_AIRBORNE_TIME # Process jump @@ -125,10 +124,10 @@ func _integrate_forces(s): jumping = false elif (not jump): stopping_jump = true - + if (stopping_jump): lv.y += STOP_JUMP_FORCE*step - + if (on_floor): # Process logic when character is on floor if (move_left and not move_right): @@ -143,14 +142,14 @@ func _integrate_forces(s): if (xv < 0): xv = 0 lv.x = sign(lv.x)*xv - + # Check jump if (not jumping and jump): lv.y = -JUMP_VELOCITY jumping = true stopping_jump = false get_node("sound").play("jump") - + # Check siding if (lv.x < 0 and move_left): new_siding_left = true @@ -182,7 +181,7 @@ func _integrate_forces(s): if (xv < 0): xv = 0 lv.x = sign(lv.x)*xv - + if (lv.y < 0): if (shoot_time < MAX_SHOOT_POSE_TIME): new_anim = "jumping_weapon" @@ -193,28 +192,28 @@ func _integrate_forces(s): new_anim = "falling_weapon" else: new_anim = "falling" - + # Update siding if (new_siding_left != siding_left): if (new_siding_left): get_node("sprite").set_scale(Vector2(-1, 1)) else: get_node("sprite").set_scale(Vector2(1, 1)) - + siding_left = new_siding_left - + # Change animation if (new_anim != anim): anim = new_anim get_node("anim").play(anim) - + shooting = shoot - + # Apply floor velocity if (found_floor): floor_h_velocity = s.get_contact_collider_velocity_at_pos(floor_index).x lv.x += floor_h_velocity - + # Finally, apply gravity and set back the linear velocity lv += s.get_total_gravity()*step s.set_linear_velocity(lv) @@ -222,7 +221,7 @@ func _integrate_forces(s): func _ready(): enemy = ResourceLoader.load("res://enemy.tscn") - + # if !Globals.has_singleton("Facebook"): # return # var Facebook = Globals.get_singleton("Facebook") diff --git a/2d/split_screen_platformer/split_stage.gd b/2d/split_screen_platformer/split_stage.gd index adbe3214..0c37c50a 100644 --- a/2d/split_screen_platformer/split_stage.gd +++ b/2d/split_screen_platformer/split_stage.gd @@ -9,7 +9,7 @@ func _ready(): var parallax_copy = get_node("top/viewport/stage/parallax_bg").duplicate() parallax_copy.set_custom_viewport( get_node("bottom/viewport") ) get_node("top/viewport/stage").add_child(parallax_copy) - + #simple and alternatively, copy them to the other viewport, but they must be erased when level is unloaded #get_node("bottom/viewport").add_child( get_node("top/viewport/stage/parallax_bg").duplicate() ) pass diff --git a/2d/tetris/grid.gd b/2d/tetris/grid.gd index 75fabb42..b9fe0035 100644 --- a/2d/tetris/grid.gd +++ b/2d/tetris/grid.gd @@ -1,4 +1,3 @@ - extends Control # Simple Tetris-like demo, (c) 2012 Juan Linietsky @@ -56,13 +55,13 @@ func piece_cell_xform(p, er = 0): func _draw(): var sb = get_stylebox("bg", "Tree") # Use line edit bg draw_style_box(sb, Rect2(Vector2(), get_size()).grow(3)) - + var bs = block.get_size() for y in range(height): for x in range(width): if (Vector2(x, y) in cells): draw_texture_rect(block, Rect2(Vector2(x, y)*bs, bs), false, block_colors[cells[Vector2(x, y)]]) - + if (piece_active): for c in block_shapes[piece_shape]: draw_texture_rect(block, Rect2(piece_cell_xform(c)*bs, bs), false, block_colors[piece_shape]) @@ -81,7 +80,7 @@ func piece_check_fit(ofs, er = 0): return false if (pos in cells): return false - + return true @@ -92,11 +91,11 @@ func new_piece(): piece_rot = 0 if (piece_shape == 0): piece_pos.y += 1 - + if (not piece_check_fit(Vector2())): # Game over game_over() - + update() @@ -113,10 +112,10 @@ func test_collapse_rows(): collapse = false if (accum_down): cells.erase(Vector2(x, y + accum_down)) - + if (collapse): accum_down += 1 - + score += accum_down*100 score_label.set_text(str(score)) @@ -190,5 +189,5 @@ func setup(w, h): func _ready(): setup(10, 20) score_label = get_node("../score") - + set_process_input(true) diff --git a/2d/texscreen/bubbles.gd b/2d/texscreen/bubbles.gd index c0c7d892..039e5c68 100644 --- a/2d/texscreen/bubbles.gd +++ b/2d/texscreen/bubbles.gd @@ -1,4 +1,3 @@ - extends Control # Member variables diff --git a/2d/texscreen/lens.gd b/2d/texscreen/lens.gd index d1007553..a2eb1a53 100644 --- a/2d/texscreen/lens.gd +++ b/2d/texscreen/lens.gd @@ -1,4 +1,3 @@ - extends BackBufferCopy # Member variables @@ -10,17 +9,17 @@ var dir func _process(delta): var pos = get_pos() + dir*delta*MOTION_SPEED - + if (pos.x < 0): dir.x = abs(dir.x) elif (pos.x > vsize.x): dir.x = -abs(dir.x) - + if (pos.y < 0): dir.y = abs(dir.y) elif (pos.y > vsize.y): dir.y = -abs(dir.y) - + set_pos(pos) diff --git a/3d/fixed_materials/s.xml b/3d/fixed_materials/s.xml index f974234e..44d60349 100644 --- a/3d/fixed_materials/s.xml +++ b/3d/fixed_materials/s.xml @@ -69,4 +69,4 @@ - \ No newline at end of file + diff --git a/3d/kinematic_char/cubio.gd b/3d/kinematic_char/cubio.gd index b850b5ad..65ef4116 100644 --- a/3d/kinematic_char/cubio.gd +++ b/3d/kinematic_char/cubio.gd @@ -1,4 +1,3 @@ - extends KinematicBody # Member variables @@ -14,7 +13,7 @@ const MAX_SLOPE_ANGLE = 30 func _fixed_process(delta): 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")): dir += -cam_xform.basis[2] if (Input.is_action_pressed("move_backwards")): @@ -23,43 +22,43 @@ func _fixed_process(delta): dir += -cam_xform.basis[0] if (Input.is_action_pressed("move_right")): dir += cam_xform.basis[0] - + dir.y = 0 dir = dir.normalized() - + vel.y += delta*g - + var hvel = vel hvel.y = 0 - + var target = dir*MAX_SPEED var accel if (dir.dot(hvel) > 0): accel = ACCEL else: accel = DEACCEL - + hvel = hvel.linear_interpolate(target, accel*delta) - + vel.x = hvel.x vel.z = hvel.z - + var motion = move(vel*delta) - + var on_floor = false var original_vel = vel var floor_velocity = Vector3() 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, # char is on floor floor_velocity = get_collider_velocity() on_floor = true - + motion = n.slide(motion) vel = n.slide(vel) if (original_vel.dot(vel) > 0): @@ -68,13 +67,13 @@ func _fixed_process(delta): if (motion.length() < 0.001): break attempts -= 1 - + if (on_floor and floor_velocity != Vector3()): move(floor_velocity*delta) - + if (on_floor and Input.is_action_pressed("jump")): vel.y = JUMP_SPEED - + var crid = get_node("../elevator1").get_rid() diff --git a/3d/kinematic_char/follow_camera.gd b/3d/kinematic_char/follow_camera.gd index 37a14020..92c9d960 100644 --- a/3d/kinematic_char/follow_camera.gd +++ b/3d/kinematic_char/follow_camera.gd @@ -1,4 +1,3 @@ - extends Camera # Member variables @@ -16,27 +15,27 @@ func _fixed_process(dt): var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin var up = Vector3(0, 1, 0) - + var delta = pos - target - + # Regular delta follow - + # 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 if (delta.y > max_height): delta.y = max_height if (delta.y < min_height): delta.y = min_height - + pos = target + delta - + look_at_from_pos(pos, target, up) - + # Turn a little up or down var t = get_transform() t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis diff --git a/3d/mousepick_test/mousepick.gd b/3d/mousepick_test/mousepick.gd index 674ec7ff..dc500d6f 100644 --- a/3d/mousepick_test/mousepick.gd +++ b/3d/mousepick_test/mousepick.gd @@ -1,4 +1,3 @@ - extends RigidBody # Member variables @@ -12,7 +11,7 @@ func _input_event(camera, event, pos, normal, shape): get_node("mesh").set_material_override(gray_mat) else: get_node("mesh").set_material_override(null) - + selected = not selected diff --git a/3d/navmesh/navmesh.gd b/3d/navmesh/navmesh.gd index 30b8cfb3..7351c432 100644 --- a/3d/navmesh/navmesh.gd +++ b/3d/navmesh/navmesh.gd @@ -1,4 +1,3 @@ - extends Navigation # Member variables @@ -29,16 +28,16 @@ func _process(delta): else: path[path.size() - 1] = pfrom.linear_interpolate(pto, to_walk/d) to_walk = 0 - + var atpos = path[path.size() - 1] var atdir = to_watch atdir.y = 0 - + var t = Transform() t.origin = atpos t=t.looking_at(atpos + atdir, Vector3(0, 1, 0)) get_node("robot_base").set_transform(t) - + if (path.size() < 2): path = [] set_process(false) @@ -71,12 +70,12 @@ func _input(event): var from = get_node("cambase/Camera").project_ray_origin(event.pos) var to = from + get_node("cambase/Camera").project_ray_normal(event.pos)*100 var p = get_closest_point_to_segment(from, to) - + begin = get_closest_point(get_node("robot_base").get_translation()) end = p _update_path() - + if (event.type == InputEvent.MOUSE_MOTION): if (event.button_mask&BUTTON_MASK_MIDDLE): camrot += event.relative_x*0.005 diff --git a/3d/platformer/bullet.gd b/3d/platformer/bullet.gd index 29219403..c458cf0c 100644 --- a/3d/platformer/bullet.gd +++ b/3d/platformer/bullet.gd @@ -1,4 +1,3 @@ - extends RigidBody # Member variables diff --git a/3d/platformer/coin.gd b/3d/platformer/coin.gd index de58ac62..84ac813e 100644 --- a/3d/platformer/coin.gd +++ b/3d/platformer/coin.gd @@ -1,4 +1,3 @@ - extends Area # Member variables @@ -14,4 +13,3 @@ func _on_coin_body_enter(body): func _on_anim_finished(): if get_node("anim").get_current_animation() == "take": queue_free() - \ No newline at end of file diff --git a/3d/platformer/enemy.gd b/3d/platformer/enemy.gd index 55c79e48..569d620c 100644 --- a/3d/platformer/enemy.gd +++ b/3d/platformer/enemy.gd @@ -1,4 +1,3 @@ - extends RigidBody # Member variables @@ -22,15 +21,15 @@ func _integrate_forces(state): lv += g*delta # Apply gravity var up = -g.normalized() - + if (dying): state.set_linear_velocity(lv) return - + for i in range(state.get_contact_count()): var cc = state.get_contact_collider_object(i) var dp = state.get_contact_local_normal(i) - + if (cc): if (cc extends preload("res://bullet.gd") and not cc.disabled): set_mode(MODE_RIGID) @@ -43,15 +42,15 @@ func _integrate_forces(state): cc.disabled = true get_node("sound").play("hit") return - + var col_floor = get_node("Armature/ray_floor").is_colliding() var col_wall = get_node("Armature/ray_wall").is_colliding() - + var advance = not col_wall and col_floor - + var dir = get_node("Armature").get_transform().basis[2].normalized() var deaccel_dir = dir - + if (advance): if (dir.dot(lv) < max_speed): lv += dir*accel*delta @@ -59,17 +58,17 @@ func _integrate_forces(state): else: if (prev_advance): rot_dir = 1 # randf()*2.0 - 1.0 - + dir = Matrix3(up, rot_dir*rot_speed*delta).xform(dir) get_node("Armature").set_transform(Transform().looking_at(-dir, up)) - + var dspeed = deaccel_dir.dot(lv) dspeed -= deaccel*delta if (dspeed < 0): dspeed = 0 - + lv = lv - deaccel_dir*deaccel_dir.dot(lv) + deaccel_dir*dspeed - + state.set_linear_velocity(lv) prev_advance = advance diff --git a/3d/platformer/follow_camera.gd b/3d/platformer/follow_camera.gd index d0d531b9..2731f930 100644 --- a/3d/platformer/follow_camera.gd +++ b/3d/platformer/follow_camera.gd @@ -1,4 +1,3 @@ - extends Camera # Member variables @@ -15,33 +14,33 @@ func _fixed_process(dt): var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin var up = Vector3(0, 1, 0) - + var delta = pos - target - + # Regular delta follow - + # 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 if (delta.y > max_height): delta.y = max_height if (delta.y < min_height): delta.y = min_height - + # 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) - + if (!col.empty()): # If main ray was occluded, get camera closer, this is the worst case scenario - delta = col.position - target + 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) @@ -51,15 +50,15 @@ func _fixed_process(dt): else: # 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 pos = target + delta - + look_at_from_pos(pos, target, up) - + # Turn a little up or down var t = get_transform() t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis diff --git a/3d/platformer/player.gd b/3d/platformer/player.gd index 74714605..b5c34efd 100644 --- a/3d/platformer/player.gd +++ b/3d/platformer/player.gd @@ -1,4 +1,3 @@ - extends RigidBody # Member variables @@ -36,15 +35,15 @@ var shoot_blend = 0 func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): var n = p_target # Normal var t = n.cross(current_gn).normalized() - + var x = n.dot(p_facing) var y = t.dot(p_facing) - + var ang = atan2(y,x) - + if (abs(ang) < 0.001): # Too small return p_facing - + var s = sign(ang) ang = ang*s var turn = ang*p_adjust_rate*p_step @@ -54,7 +53,7 @@ func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): else: a = turn ang = (ang - a)*s - + return (n*cos(ang) + t*sin(ang))*p_facing.length() @@ -66,33 +65,33 @@ func _integrate_forces(state): # if (d < 0): # d = 0 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 hdir = hv.normalized() # Horizontal direction var hspeed = hv.length() # Horizontal speed - + var floor_velocity var onfloor = false - + if (state.get_contact_count() == 0): floor_velocity = last_floor_velocity else: for i in range(state.get_contact_count()): if (state.get_contact_local_shape(i) != 1): continue - + onfloor = true floor_velocity = state.get_contact_collider_velocity_at_pos(i) break - + 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")): dir += -cam_xform.basis[2] if (Input.is_action_pressed("move_backwards")): @@ -101,15 +100,15 @@ func _integrate_forces(state): dir += -cam_xform.basis[0] if (Input.is_action_pressed("move_right")): dir += cam_xform.basis[0] - + var jump_attempt = Input.is_action_pressed("jump") var shoot_attempt = Input.is_action_pressed("shoot") - + 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_threshold - + if (dir.length() > 0.1 and !sharp_turn): if (hspeed > 0.001): #linear_dir = linear_h_velocity/linear_vel @@ -120,24 +119,24 @@ func _integrate_forces(state): facing_dir = hdir else: hdir = target_dir - + if (hspeed < max_speed): hspeed += accel*delta else: hspeed -= deaccel*delta if (hspeed < 0): hspeed = 0 - + hv = hdir*hspeed - + 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) var m3 = Matrix3(-facing_mesh, up, -facing_mesh.cross(up).normalized()).scaled(CHAR_SCALE) - + get_node("Armature").set_transform(Transform(m3, mesh_xform.origin)) - + if (not jumping and jump_attempt): vv = 7.0 jumping = true @@ -147,7 +146,7 @@ func _integrate_forces(state): anim = ANIM_AIR_UP else: anim = ANIM_AIR_DOWN - + var hs if (dir.length() > 0.1): hv += target_dir*(accel*0.2)*delta @@ -158,14 +157,14 @@ func _integrate_forces(state): hspeed = hspeed - (deaccel*0.2)*delta if (hspeed < 0): hspeed = 0 - + hv = hdir*hspeed - + if (jumping and vv < 0): jumping = false - + lv = hv + up*vv - + if (onfloor): movement_dir = lv #lv += floor_velocity @@ -175,19 +174,19 @@ func _integrate_forces(state): #if (keep_jump_inertia): # lv += last_floor_velocity pass - + last_floor_velocity = Vector3() movement_dir = lv - + on_floor = onfloor - + state.set_linear_velocity(lv) - + if (shoot_blend > 0): shoot_blend -= delta*SHOOT_SCALE if (shoot_blend < 0): shoot_blend = 0 - + if (shoot_attempt and not prev_shoot): shoot_blend = SHOOT_TIME var bullet = preload("res://bullet.scn").instance() @@ -196,12 +195,12 @@ func _integrate_forces(state): 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 get_node("sfx").play("shoot") - + prev_shoot = shoot_attempt - + if (onfloor): get_node("AnimationTreePlayer").blend2_node_set_amount("walk", hspeed/max_speed) - + get_node("AnimationTreePlayer").transition_node_set_current("state", anim) get_node("AnimationTreePlayer").blend2_node_set_amount("gun", min(shoot_blend, 1.0)) # state.set_angular_velocity(Vector3()) diff --git a/3d/shader_materials/s.xml b/3d/shader_materials/s.xml index f974234e..44d60349 100644 --- a/3d/shader_materials/s.xml +++ b/3d/shader_materials/s.xml @@ -69,4 +69,4 @@ - \ No newline at end of file + diff --git a/3d/truck_town/car_select.gd b/3d/truck_town/car_select.gd index 4efcf634..a94824fb 100644 --- a/3d/truck_town/car_select.gd +++ b/3d/truck_town/car_select.gd @@ -1,4 +1,3 @@ - extends Control # Member variables diff --git a/3d/truck_town/follow_camera.gd b/3d/truck_town/follow_camera.gd index 7c6a0a2b..e6da9c17 100644 --- a/3d/truck_town/follow_camera.gd +++ b/3d/truck_town/follow_camera.gd @@ -1,4 +1,3 @@ - extends Camera # Member variables @@ -16,27 +15,27 @@ func _fixed_process(dt): var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin var up = Vector3(0, 1, 0) - + var delta = pos - target - + # Regular delta follow - + # 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 if ( delta.y > max_height): delta.y = max_height if ( delta.y < min_height): delta.y = min_height - + pos = target + delta - + look_at_from_pos(pos, target, up) - + # Turn a little up or down var t = get_transform() t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis diff --git a/3d/truck_town/vehicle.gd b/3d/truck_town/vehicle.gd index c4224577..0cb361a3 100644 --- a/3d/truck_town/vehicle.gd +++ b/3d/truck_town/vehicle.gd @@ -1,4 +1,3 @@ - extends VehicleBody # Member variables @@ -18,17 +17,17 @@ func _fixed_process(delta): steer_target = STEER_LIMIT else: steer_target = 0 - + if (Input.is_action_pressed("ui_up")): set_engine_force(engine_force) else: set_engine_force(0) - + if (Input.is_action_pressed("ui_down")): set_brake(1) else: set_brake(0.0) - + if (steer_target < steer_angle): steer_angle -= STEER_SPEED*delta if (steer_target > steer_angle): @@ -37,7 +36,7 @@ func _fixed_process(delta): steer_angle += STEER_SPEED*delta if (steer_target < steer_angle): steer_angle = steer_target - + set_steering(steer_angle) diff --git a/README.md b/README.md index 9f7d31f1..82ea37b6 100644 --- a/README.md +++ b/README.md @@ -8,23 +8,10 @@ be used with [Godot Engine](https://godotengine.org), the open source - The [`master`](https://github.com/godotengine/godot-demo-projects) branch is compatible with Godot's `master` development branch (next 4.x release). - The [`3.x`](https://github.com/godotengine/godot-demo-projects/tree/3.x) branch is compatible with Godot's `3.x` development branch (next 3.x release). -- The other branches are compatible with the matching stable versions of Godot: - - [`4.0`](https://github.com/godotengine/godot-demo-projects/tree/4.0) - branch for Godot 4.0.x. - - [`3.5`](https://github.com/godotengine/godot-demo-projects/tree/3.5) - branch for Godot 3.5.x. - - [`3.4`](https://github.com/godotengine/godot-demo-projects/tree/3.4) - branch for Godot 3.4.x. - - [`3.3`](https://github.com/godotengine/godot-demo-projects/tree/3.3) - branch for Godot 3.3.x. - - [`3.2`](https://github.com/godotengine/godot-demo-projects/tree/3.2) - branch for Godot 3.2.x. - - [`3.1`](https://github.com/godotengine/godot-demo-projects/tree/3.1) - branch for Godot 3.1.x. - - [`3.0`](https://github.com/godotengine/godot-demo-projects/tree/3.0) - branch for Godot 3.0.x. - - [***`2.1`***](https://github.com/godotengine/godot-demo-projects/tree/2.1) - branch for Godot 2.1.x. +- The other branches are compatible with the matching stable versions of Godot. + - [Click here](https://github.com/godotengine/godot-demo-projects/branches) to see all branches. + - For example, the [`2.1`](https://github.com/godotengine/godot-demo-projects/tree/2.1) + branch is for demos compatible with Godot 2.1.x. ## Importing all demos diff --git a/file_format.sh b/file_format.sh new file mode 100755 index 00000000..fab029eb --- /dev/null +++ b/file_format.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# This script ensures proper POSIX text file formatting and a few other things. + +set -uo pipefail +IFS=$'\n\t' + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude some types of files. + if [[ "$f" == *"csproj" ]]; then + continue + elif [[ "$f" == *"hdr" ]]; then + continue + fi + # Ensure that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensure that files have LF line endings and do not contain a BOM. + dos2unix "$f" 2> /dev/null + # Remove trailing space characters and ensures that files end + # with newline characters. -l option handles newlines conveniently. + perl -i -ple 's/\s*$//g' "$f" + # Remove the character sequence "== true" if it has a leading space. + perl -i -pe 's/\x20== true//g' "$f" + # We don't want to change lines around braces in godot/tscn files. + if [[ "$f" == *"godot" ]]; then + continue + elif [[ "$f" == *"tscn" ]]; then + continue + fi + # Disallow empty lines after the opening brace. + sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f" + # Disallow some empty lines before the closing brace. + sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f" +done + +git diff > patch.patch +FILESIZE="$(stat -c%s patch.patch)" +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/gui/drag_and_drop/drag_drop_script.gd b/gui/drag_and_drop/drag_drop_script.gd index 719c42fe..dd1caa11 100644 --- a/gui/drag_and_drop/drag_drop_script.gd +++ b/gui/drag_and_drop/drag_drop_script.gd @@ -1,4 +1,3 @@ - extends ColorPickerButton diff --git a/gui/rich_text_bbcode/OFL.txt b/gui/rich_text_bbcode/OFL.txt index 7fc1aac5..45f21a87 100644 --- a/gui/rich_text_bbcode/OFL.txt +++ b/gui/rich_text_bbcode/OFL.txt @@ -17,7 +17,7 @@ with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, +fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The diff --git a/gui/rich_text_bbcode/rich_text_bbcode.gd b/gui/rich_text_bbcode/rich_text_bbcode.gd index 79a08c13..abb436d7 100644 --- a/gui/rich_text_bbcode/rich_text_bbcode.gd +++ b/gui/rich_text_bbcode/rich_text_bbcode.gd @@ -1,4 +1,3 @@ - extends Panel diff --git a/gui/translation/controls.gd b/gui/translation/controls.gd index ae2e2636..36e577d1 100644 --- a/gui/translation/controls.gd +++ b/gui/translation/controls.gd @@ -1,4 +1,3 @@ - extends Panel diff --git a/gui/translation/main.gd b/gui/translation/main.gd index c3e788f8..e35f1d9a 100644 --- a/gui/translation/main.gd +++ b/gui/translation/main.gd @@ -1,4 +1,3 @@ - extends Panel diff --git a/gui/translation/text.csv b/gui/translation/text.csv index 0f4c148b..85a861d2 100644 --- a/gui/translation/text.csv +++ b/gui/translation/text.csv @@ -1,3 +1,3 @@ ,en,es,ja KEY_HELLO,Hello!,Hola!,こんにちは -KEY_PUSH,Push Me!,Aprétame!,私をプッシュ \ No newline at end of file +KEY_PUSH,Push Me!,Aprétame!,私をプッシュ diff --git a/misc/android_iap/iap.gd b/misc/android_iap/iap.gd index 36de3299..7ac43060 100644 --- a/misc/android_iap/iap.gd +++ b/misc/android_iap/iap.gd @@ -1,4 +1,3 @@ - extends Node signal purchase_success(item_name) diff --git a/misc/android_iap/iap_demo.gd b/misc/android_iap/iap_demo.gd index 3c5d07df..b7eac431 100644 --- a/misc/android_iap/iap_demo.gd +++ b/misc/android_iap/iap_demo.gd @@ -1,4 +1,3 @@ - extends Control onready var alert = get_node("alert") @@ -13,7 +12,7 @@ func _ready(): iap.connect("consume_success", self, "on_consume_success") iap.connect("consume_fail", self, "on_consume_fail") iap.connect("sku_details_complete", self, "on_sku_details_complete") - + get_node("purchase").connect("pressed", self, "button_purchase") get_node("consume").connect("pressed", self, "button_consume") get_node("request").connect("pressed", self, "button_request") diff --git a/misc/autoload/global.gd b/misc/autoload/global.gd index 735995e8..870747c3 100644 --- a/misc/autoload/global.gd +++ b/misc/autoload/global.gd @@ -12,25 +12,25 @@ func goto_scene(path): # Deleting the current scene at this point might be # a bad idea, because it may be inside of a callback or function of it. # The worst case will be a crash or unexpected behavior. - + # The way around this is deferring the load to a later time, when # it is ensured that no code from the current scene is running: - + call_deferred("_deferred_goto_scene",path) func _deferred_goto_scene(path): # Immediately free the current scene, there is no risk here. get_tree().get_current_scene().free() - + # Load new scene var packed_scene = ResourceLoader.load(path) - + # Instance the new scene var instanced_scene = packed_scene.instance() - + # Add it to the scene tree, as direct child of root get_tree().get_root().add_child(instanced_scene) - + # Set it as the current scene, only after it has been added to the tree get_tree().set_current_scene(instanced_scene) diff --git a/misc/pause/spinpause.gd b/misc/pause/spinpause.gd index ea5617c0..a854d48c 100644 --- a/misc/pause/spinpause.gd +++ b/misc/pause/spinpause.gd @@ -1,4 +1,3 @@ - extends Spatial diff --git a/misc/regex/regex.gd b/misc/regex/regex.gd index 98e5ca88..1a578add 100644 --- a/misc/regex/regex.gd +++ b/misc/regex/regex.gd @@ -1,4 +1,3 @@ - extends VBoxContainer # Member variables diff --git a/misc/scene_changer/scene_a.gd b/misc/scene_changer/scene_a.gd index 0e80395e..06bf8168 100644 --- a/misc/scene_changer/scene_a.gd +++ b/misc/scene_changer/scene_a.gd @@ -1,4 +1,3 @@ - extends Panel # Member variables here, example: diff --git a/misc/scene_changer/scene_b.gd b/misc/scene_changer/scene_b.gd index 9ed13cf2..cf3486a5 100644 --- a/misc/scene_changer/scene_b.gd +++ b/misc/scene_changer/scene_b.gd @@ -1,4 +1,3 @@ - extends Panel # Member variables here, example: diff --git a/misc/threads/thread.gd b/misc/threads/thread.gd index 1ef67e40..71ca9f58 100644 --- a/misc/threads/thread.gd +++ b/misc/threads/thread.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables diff --git a/misc/tween/main.gd b/misc/tween/main.gd index bcacc614..df7d7078 100644 --- a/misc/tween/main.gd +++ b/misc/tween/main.gd @@ -16,26 +16,26 @@ func _ready(): for index in range(trans.size()): var name = trans[index] get_node("trans/" + name).connect("pressed", self, "on_trans_changed", [name, index]) - + for index in range(eases.size()): var name = eases[index] get_node("eases/" + name).connect("pressed", self, "on_eases_changed", [name, index]) - + for index in range(modes.size()): var name = modes[index] get_node("modes/" + name).connect("pressed", self, "on_modes_changed", [name]) - + get_node("colors/color_from/picker").set_color(Color(1, 0, 0, 1)) get_node("colors/color_from/picker").connect("color_changed", self, "on_color_changed") - + get_node("colors/color_to/picker").set_color(Color(0, 1, 1, 1)) get_node("colors/color_to/picker").connect("color_changed", self, "on_color_changed") - + get_node("trans/linear").set_pressed(true) get_node("eases/in").set_pressed(true) get_node("modes/move").set_pressed(true) get_node("modes/repeat").set_pressed(true) - + reset_tween() @@ -43,10 +43,10 @@ func on_trans_changed(name, index): for index in range(trans.size()): var pressed = trans[index] == name var btn = get_node("trans/" + trans[index]) - + btn.set_pressed(pressed) btn.set_ignore_mouse(pressed) - + state.trans = index reset_tween() @@ -55,10 +55,10 @@ func on_eases_changed(name, index): for index in range(eases.size()): var pressed = eases[index] == name var btn = get_node("eases/" + eases[index]) - + btn.set_pressed(pressed) btn.set_ignore_mouse(pressed) - + state.eases = index reset_tween() @@ -85,7 +85,7 @@ func reset_tween(): var pos = tween.tell() tween.reset_all() tween.remove_all() - + var sprite = get_node("tween/area/sprite") var follow = get_node("tween/area/follow") var follow_2 = get_node("tween/area/follow_2") @@ -94,44 +94,44 @@ func reset_tween(): if get_node("modes/move").is_pressed(): tween.interpolate_method(sprite, "set_pos", Vector2(0, 0), Vector2(size.width, size.height), 2, state.trans, state.eases) tween.interpolate_property(sprite, "transform/pos", Vector2(size.width, size.height), Vector2(0, 0), 2, state.trans, state.eases, 2) - + if get_node("modes/color").is_pressed(): tween.interpolate_method(sprite, "set_modulate", get_node("colors/color_from/picker").get_color(), get_node("colors/color_to/picker").get_color(), 2, state.trans, state.eases) tween.interpolate_property(sprite, "modulate", get_node("colors/color_to/picker").get_color(), get_node("colors/color_from/picker").get_color(), 2, state.trans, state.eases, 2) else: sprite.set_modulate(Color(1,1,1,1)) - + if get_node("modes/scale").is_pressed(): tween.interpolate_method(sprite, "set_scale", Vector2(0.5, 0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases) tween.interpolate_property(sprite, "transform/scale", Vector2(1.5, 1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2) else: sprite.set_scale(Vector2(1,1)) - + if get_node("modes/rotate").is_pressed(): tween.interpolate_method(sprite, "set_rotd", 0, 360, 2, state.trans, state.eases) tween.interpolate_property(sprite, "transform/rot", 360, 0, 2, state.trans, state.eases, 2) - + if get_node("modes/callback").is_pressed(): tween.interpolate_callback(self, 0.5, "on_callback", "0.5 second's after") tween.interpolate_callback(self, 0.2, "on_callback", "1.2 second's after") - + if get_node("modes/follow").is_pressed(): follow.show() follow_2.show() - + tween.follow_method(follow, "set_pos", Vector2(0, size.height), sprite, "get_pos", 2, state.trans, state.eases) tween.targeting_method(follow, "set_pos", sprite, "get_pos", Vector2(0, size.height), 2, state.trans, state.eases, 2) - + tween.targeting_property(follow_2, "transform/pos", sprite, "transform/pos", Vector2(size.width, 0), 2, state.trans, state.eases) tween.follow_property(follow_2, "transform/pos", Vector2(size.width, 0), sprite, "transform/pos", 2, state.trans, state.eases, 2) else: follow.hide() follow_2.hide() - + tween.set_repeat(get_node("modes/repeat").is_pressed()) tween.start() tween.seek(pos) - + if get_node("modes/pause").is_pressed(): tween.stop_all() get_node("timeline").set_ignore_mouse(false) @@ -143,10 +143,10 @@ func reset_tween(): func _on_tween_step(object, key, elapsed, value): var timeline = get_node("timeline") - + var tween = get_node("tween") var runtime = tween.get_runtime() - + var ratio = 100*(elapsed/runtime) timeline.set_value(ratio) @@ -154,7 +154,7 @@ func _on_tween_step(object, key, elapsed, value): func _on_timeline_value_changed(value): if !get_node("modes/pause").is_pressed(): return - + var tween = get_node("tween") var runtime = tween.get_runtime() tween.seek(runtime*value/100) diff --git a/misc/udp_chat/chat.gd b/misc/udp_chat/chat.gd index b60afa9d..a76a1eaf 100644 --- a/misc/udp_chat/chat.gd +++ b/misc/udp_chat/chat.gd @@ -1,4 +1,3 @@ - extends Panel # Really simple UDP chat client, not intended as a comprehensive chat implementation. @@ -12,7 +11,7 @@ var udp = PacketPeerUDP.new() func _process(delta): if (not udp.is_listening()): return - + while(udp.get_available_packet_count() > 0): var packet = udp.get_var() if (typeof(packet) == TYPE_STRING): @@ -62,5 +61,5 @@ func _on_entry_button_pressed(): if (msg == ""): return send_message(get_node("user_name").get_text() + "> " + msg) - + get_node("entry_line").set_text("") diff --git a/misc/window_management/control.gd b/misc/window_management/control.gd index 81b2d3b0..149c55bc 100644 --- a/misc/window_management/control.gd +++ b/misc/window_management/control.gd @@ -7,45 +7,45 @@ onready var observer = get_node("../Observer") func _fixed_process(delta): var modetext = "Mode:\n" - + if(OS.is_window_fullscreen()): modetext += "Fullscreen\n" else: modetext += "Windowed\n" - + if(!OS.is_window_resizable()): modetext += "FixedSize\n" - + if(OS.is_window_minimized()): modetext += "Minimized\n" - + if(OS.is_window_maximized()): modetext += "Maximized\n" - + if(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED): modetext += "MouseGrab\n" get_node("Label_MouseModeCaptured_KeyInfo").show() else: get_node("Label_MouseModeCaptured_KeyInfo").hide() - + get_node("Label_Mode").set_text(modetext) - + get_node("Label_Position").set_text(str("Position:\n", OS.get_window_position())) - + get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size())) - + get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos)) - + get_node("Label_Screen_Count").set_text(str("Screen_Count:\n", OS.get_screen_count())) - + get_node("Label_Screen_Current").set_text(str("Screen:\n", OS.get_current_screen())) - + get_node("Label_Screen0_Resolution").set_text(str("Screen0 Resolution:\n", OS.get_screen_size())) - + get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n", OS.get_screen_position())) get_node("Label_Screen0_DPI").set_text(str("Screen0 DPI:\n", OS.get_screen_dpi())) - + if(OS.get_screen_count() > 1): get_node("Button_Screen0").show() get_node("Button_Screen1").show() @@ -61,7 +61,7 @@ func _fixed_process(delta): get_node("Label_Screen1_Resolution").hide() get_node("Label_Screen1_Position").hide() get_node("Label_Screen1_DPI").hide() - + get_node("Button_Fullscreen").set_pressed(OS.is_window_fullscreen()) get_node("Button_FixedSize").set_pressed(!OS.is_window_resizable()) get_node("Button_Minimized").set_pressed(OS.is_window_minimized()) @@ -75,55 +75,55 @@ func check_wm_api(): var s = "" if(!OS.has_method("get_screen_count")): s += " - get_screen_count()\n" - + if(!OS.has_method("get_current_screen")): s += " - get_current_screen()\n" - + if(!OS.has_method("set_current_screen")): s += " - set_current_screen()\n" - + if(!OS.has_method("get_screen_position")): s += " - get_screen_position()\n" - + if(!OS.has_method("get_screen_size")): s += " - get_screen_size()\n" - + if(!OS.has_method("get_window_position")): s += " - get_window_position()\n" - + if(!OS.has_method("set_window_position")): s += " - set_window_position()\n" - + if(!OS.has_method("get_window_size")): s += " - get_window_size()\n" - + if(!OS.has_method("set_window_size")): s += " - set_window_size()\n" - + if(!OS.has_method("set_window_fullscreen")): s += " - set_window_fullscreen()\n" - + if(!OS.has_method("is_window_fullscreen")): s += " - is_window_fullscreen()\n" - + if(!OS.has_method("set_window_resizable")): s += " - set_window_resizable()\n" - + if(!OS.has_method("is_window_resizable")): s += " - is_window_resizable()\n" - + if(!OS.has_method("set_window_minimized")): s += " - set_window_minimized()\n" - + if(!OS.has_method("is_window_minimized")): s += " - is_window_minimized()\n" - + if(!OS.has_method("set_window_maximized")): s += " - set_window_maximized()\n" - + if(!OS.has_method("is_window_maximized")): s += " - is_window_maximized()\n" - + if(s.length() == 0): return true else: @@ -142,16 +142,16 @@ func _ready(): func _input(event): if (event.type == InputEvent.MOUSE_MOTION): mousepos = event.pos - + if (event.type == InputEvent.KEY): if Input.is_action_pressed("mouse_mode_visible"): observer.state = observer.STATE_MENU _on_Button_MouseModeVisible_pressed() - + if Input.is_action_pressed("mouse_mode_hidden"): observer.state = observer.STATE_MENU _on_Button_MouseModeHidden_pressed() - + if Input.is_action_pressed("mouse_mode_captured"): _on_Button_MouseModeCaptured_pressed() diff --git a/misc/window_management/observer/observer.gd b/misc/window_management/observer/observer.gd index 69f40300..c9d2dfa4 100644 --- a/misc/window_management/observer/observer.gd +++ b/misc/window_management/observer/observer.gd @@ -1,4 +1,3 @@ - extends Spatial # Member variables diff --git a/plugins/custom_dock/dock_plugin.gd b/plugins/custom_dock/dock_plugin.gd index ce8a3bcd..c826234d 100644 --- a/plugins/custom_dock/dock_plugin.gd +++ b/plugins/custom_dock/dock_plugin.gd @@ -10,14 +10,9 @@ func _enter_tree(): add_control_to_dock( DOCK_SLOT_LEFT_UL, dock ) -func _exit_tree(): +func _exit_tree(): # Remove from docks (must be called so layout is updated and saved) remove_control_from_docks(dock) # Remove the node dock.free() - - - - - \ No newline at end of file diff --git a/plugins/custom_import_plugin/import_plugin.gd b/plugins/custom_import_plugin/import_plugin.gd index 99f0289e..1dcbd570 100644 --- a/plugins/custom_import_plugin/import_plugin.gd +++ b/plugins/custom_import_plugin/import_plugin.gd @@ -1,5 +1,4 @@ tool - extends EditorImportPlugin diff --git a/plugins/custom_import_plugin/material_dialog.gd b/plugins/custom_import_plugin/material_dialog.gd index 10227432..33b02fa3 100644 --- a/plugins/custom_import_plugin/material_dialog.gd +++ b/plugins/custom_import_plugin/material_dialog.gd @@ -11,22 +11,22 @@ func configure(p_import_plugin,path,metadata): # metadata from previous import exists, fill in fields assert( metadata.get_source_count() > 0 ) # Always expand the source paths - var src_path = import_plugin.expand_source_path( metadata.get_source_path(0) ) + var src_path = import_plugin.expand_source_path( metadata.get_source_path(0) ) get_node("src_file").set_text(src_path) get_node("dst_file").set_text(path) # Fill in from metadata options get_node("use_red_anyway").set_pressed( metadata.get_option("use_red_anyway") ) - + func _ready(): - + src_fs = FileDialog.new() src_fs.set_mode(FileDialog.MODE_OPEN_FILE) src_fs.set_access(FileDialog.ACCESS_FILESYSTEM) #access all filesystem, not only res:// src_fs.add_filter("*.mtxt") src_fs.connect("file_selected",self,"_on_src_selected") - - add_child(src_fs) + + add_child(src_fs) dst_fs = EditorFileDialog.new() dst_fs.set_mode(EditorFileDialog.MODE_SAVE_FILE) @@ -47,15 +47,15 @@ func _on_dst_browse_pressed(): func _on_src_selected(path): get_node("src_file").set_text(path) - + func _on_dst_selected(path): - get_node("dst_file").set_text(path) + get_node("dst_file").set_text(path) func _on_MaterialImport_confirmed(): # Create an import metadata var imd = ResourceImportMetadata.new() # Add the source files, always validate the source path - imd.add_source( import_plugin.validate_source_path( get_node("src_file").get_text() )) + imd.add_source( import_plugin.validate_source_path( get_node("src_file").get_text() )) # Add the options imd.set_option( "use_red_anyway", get_node("use_red_anyway").is_pressed() ) # Perform regular import @@ -64,4 +64,4 @@ func _on_MaterialImport_confirmed(): if (err!=OK): get_node("error").set_text("Error Importing!") get_node("error").popup_centered_minsize() - + diff --git a/plugins/custom_import_plugin/material_import.gd b/plugins/custom_import_plugin/material_import.gd index f9859251..398a9a76 100644 --- a/plugins/custom_import_plugin/material_import.gd +++ b/plugins/custom_import_plugin/material_import.gd @@ -3,20 +3,15 @@ extends EditorPlugin var import_plugin + func _enter_tree(): - import_plugin = preload("res://addons/custom_import_plugin/import_plugin.gd").new() # pass the GUI base control, so the dialog has a parent node import_plugin.config( get_base_control() ) - add_import_plugin( import_plugin) + add_import_plugin( import_plugin) + func _exit_tree(): - - remove_import_plugin( import_plugin ) - - - - - \ No newline at end of file + remove_import_plugin( import_plugin ) diff --git a/plugins/custom_node/heart_plugin.gd b/plugins/custom_node/heart_plugin.gd index 01a6177c..abe7dc79 100644 --- a/plugins/custom_node/heart_plugin.gd +++ b/plugins/custom_node/heart_plugin.gd @@ -15,4 +15,3 @@ func _exit_tree(): - \ No newline at end of file diff --git a/plugins/readme.txt b/plugins/readme.txt index 963850dc..dc29e98f 100644 --- a/plugins/readme.txt +++ b/plugins/readme.txt @@ -10,4 +10,4 @@ addons/custom_node To distribute and install from UI, make a zip that contains the folder, example: -zip -r custom_node.zip custom_node/* \ No newline at end of file +zip -r custom_node.zip custom_node/* diff --git a/viewport/2d_in_3d/pong.gd b/viewport/2d_in_3d/pong.gd index ac345745..522fd644 100644 --- a/viewport/2d_in_3d/pong.gd +++ b/viewport/2d_in_3d/pong.gd @@ -1,4 +1,3 @@ - extends Node2D # Member variables @@ -16,47 +15,47 @@ func _process(delta): var ball_pos = get_node("ball").get_pos() var left_rect = Rect2(get_node("left").get_pos() - pad_size*0.5, pad_size) var right_rect = Rect2(get_node("right").get_pos() - pad_size*0.5, pad_size) - + # Integrate new ball postion ball_pos += direction*ball_speed*delta - + # Flip when touching roof or floor if ((ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > screen_size.y and direction.y > 0)): direction.y = -direction.y - + # Flip, change direction and increase speed when touching pads if ((left_rect.has_point(ball_pos) and direction.x < 0) or (right_rect.has_point(ball_pos) and direction.x > 0)): direction.x = -direction.x ball_speed *= 1.1 direction.y = randf()*2.0 - 1 direction = direction.normalized() - + # Check gameover if (ball_pos.x < 0 or ball_pos.x > screen_size.x): ball_pos = screen_size*0.5 ball_speed = INITIAL_BALL_SPEED direction = Vector2(-1, 0) - + get_node("ball").set_pos(ball_pos) - + # Move left pad var left_pos = get_node("left").get_pos() - + if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")): left_pos.y += -PAD_SPEED*delta if (left_pos.y < screen_size.y and Input.is_action_pressed("left_move_down")): left_pos.y += PAD_SPEED*delta - + get_node("left").set_pos(left_pos) - + # Move right pad var right_pos = get_node("right").get_pos() - + if (right_pos.y > 0 and Input.is_action_pressed("right_move_up")): right_pos.y += -PAD_SPEED*delta if (right_pos.y < screen_size.y and Input.is_action_pressed("right_move_down")): right_pos.y += PAD_SPEED*delta - + get_node("right").set_pos(right_pos) diff --git a/viewport/2d_in_3d/pong3d.gd b/viewport/2d_in_3d/pong3d.gd index 79a7a368..071f3f17 100644 --- a/viewport/2d_in_3d/pong3d.gd +++ b/viewport/2d_in_3d/pong3d.gd @@ -1,4 +1,3 @@ - extends Spatial diff --git a/viewport/gui_in_3d/gui_3d.gd b/viewport/gui_in_3d/gui_3d.gd index b93c1752..e97e8a84 100644 --- a/viewport/gui_in_3d/gui_3d.gd +++ b/viewport/gui_in_3d/gui_3d.gd @@ -1,4 +1,3 @@ - extends Spatial # Member variables diff --git a/viewport/screen_capture/screen_capture.gd b/viewport/screen_capture/screen_capture.gd index 9867d954..b11ad358 100644 --- a/viewport/screen_capture/screen_capture.gd +++ b/viewport/screen_capture/screen_capture.gd @@ -1,4 +1,3 @@ - extends Control