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/dodge_the_creeps/Player.gd b/2d/dodge_the_creeps/Player.gd index 5ac4f1f7..4cb5cd24 100644 --- a/2d/dodge_the_creeps/Player.gd +++ b/2d/dodge_the_creeps/Player.gd @@ -14,7 +14,7 @@ func _process(delta): var velocity = Vector2() velocity.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left") velocity.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up") - + if velocity.length() > 0: velocity = velocity.normalized() * speed $AnimatedSprite.play() diff --git a/2d/dodge_the_creeps/project.godot b/2d/dodge_the_creeps/project.godot index bfc532ff..8806d06e 100644 --- a/2d/dodge_the_creeps/project.godot +++ b/2d/dodge_the_creeps/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/finite_state_machine/debug/Explanations.tscn b/2d/finite_state_machine/debug/Explanations.tscn index 9fc00960..14c03dbb 100644 --- a/2d/finite_state_machine/debug/Explanations.tscn +++ b/2d/finite_state_machine/debug/Explanations.tscn @@ -16,7 +16,7 @@ size_flags_vertical = 4 custom_fonts/bold_font = ExtResource( 1 ) custom_fonts/normal_font = ExtResource( 2 ) bbcode_enabled = true -bbcode_text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton. +bbcode_text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton. States are common in games. You can use the pattern to: @@ -25,7 +25,7 @@ States are common in games. You can use the pattern to: 3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do. You can read more about States in the excellent [url=http://gameprogrammingpatterns.com/state.html]Game Programming Patterns ebook[/url]." -text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton. +text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton. States are common in games. You can use the pattern to: diff --git a/2d/finite_state_machine/project.godot b/2d/finite_state_machine/project.godot index 776715f9..3ac9eed6 100644 --- a/2d/finite_state_machine/project.godot +++ b/2d/finite_state_machine/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/finite_state_machine/state_machine/state_machine.gd b/2d/finite_state_machine/state_machine/state_machine.gd index 00dd9fc0..01abeb3b 100644 --- a/2d/finite_state_machine/state_machine/state_machine.gd +++ b/2d/finite_state_machine/state_machine/state_machine.gd @@ -60,14 +60,14 @@ func _change_state(state_name): if not _active: return current_state.exit() - + if state_name == "previous": states_stack.pop_front() else: states_stack[0] = states_map[state_name] - + current_state = states_stack[0] emit_signal("state_changed", current_state) - + if state_name != "previous": current_state.enter() diff --git a/2d/gd_paint/PaintControl.gd b/2d/gd_paint/PaintControl.gd index 2372112f..1e97d011 100644 --- a/2d/gd_paint/PaintControl.gd +++ b/2d/gd_paint/PaintControl.gd @@ -51,20 +51,20 @@ func _ready(): func _process(_delta): var mouse_pos = get_viewport().get_mouse_position() - + # Check if the mouse is currently inside the canvas/drawing-area. is_mouse_in_drawing_area = false if mouse_pos.x > TL_node.global_position.x: if mouse_pos.y > TL_node.global_position.y: is_mouse_in_drawing_area = true - + if Input.is_mouse_button_pressed(BUTTON_LEFT): # If we do not have a position for when the mouse was first clicked, then this must # be the first time is_mouse_button_pressed has been called since the mouse button was # released, so we need to store the position. if mouse_click_start_pos == null: mouse_click_start_pos = mouse_pos - + # If the mouse is inside the canvas and the mouse is 1px away from the position of the mouse last _process call. if check_if_mouse_is_inside_canvas(): if mouse_pos.distance_to(last_mouse_pos) >= 1: @@ -77,11 +77,11 @@ func _process(_delta): undo_element_list_num = brush_data_list.size() # Add the brush object to draw_elements_array. add_brush(mouse_pos, brush_mode) - + else: # We've finished our stroke, so we can set a new undo (if a new storke is made). undo_set = false - + # If the mouse is inside the canvas. if check_if_mouse_is_inside_canvas(): # If we're using either the circle shape mode, or the rectangle shape mode, then @@ -94,7 +94,7 @@ func _process(_delta): # Since we've released the left mouse, we need to get a new mouse_click_start_pos next time #is_mouse_button_pressed is true. mouse_click_start_pos = null - + # Store mouse_pos as last_mouse_pos now that we're done with _process. last_mouse_pos = mouse_pos @@ -108,7 +108,7 @@ func check_if_mouse_is_inside_canvas(): if mouse_click_start_pos.x > TL_node.global_position.x: if mouse_click_start_pos.y > TL_node.global_position.y: # Make sure the current mouse position is inside the canvas. - if is_mouse_in_drawing_area == true: + if is_mouse_in_drawing_area: return true return false @@ -117,17 +117,17 @@ func undo_stroke(): # Only undo a stroke if we have one. if undo_element_list_num == UNDO_NONE: return - + # If we are undoing a shape, then we can just remove the latest brush. if undo_element_list_num == UNDO_MODE_SHAPE: if brush_data_list.size() > 0: brush_data_list.remove(brush_data_list.size() - 1) - + # Now that we've undone a shape, we cannot undo again until another stoke is added. undo_element_list_num = UNDO_NONE # NOTE: if we only had shape brushes, then we could remove the above line and could let the user # undo until we have a empty element list. - + # Otherwise we're removing a either a pencil stroke or a eraser stroke. else: # Figure out how many elements/brushes we've added in the last stroke. @@ -136,7 +136,7 @@ func undo_stroke(): #warning-ignore:unused_variable for elment_num in range(0, elements_to_remove): brush_data_list.pop_back() - + # Now that we've undone a stoke, we cannot undo again until another stoke is added. undo_element_list_num = UNDO_NONE @@ -147,7 +147,7 @@ func undo_stroke(): func add_brush(mouse_pos, type): # Make new brush dictionary that will hold all of the data we need for the brush. var new_brush = {} - + # Populate the dictionary with values based on the global brush variables. # We will override these as needed if the brush is a rectange or circle. new_brush.brush_type = type @@ -155,13 +155,13 @@ func add_brush(mouse_pos, type): new_brush.brush_shape = brush_shape new_brush.brush_size = brush_size new_brush.brush_color = brush_color - + # If the new bursh is a rectangle shape, we need to calculate the top left corner of the rectangle and the # bottom right corner of the rectangle. if type == BrushModes.RECTANGLE_SHAPE: var TL_pos = Vector2() var BR_pos = Vector2() - + # Figure out the left and right positions of the corners and assign them to the proper variable. if mouse_pos.x < mouse_click_start_pos.x: TL_pos.x = mouse_pos.x @@ -169,7 +169,7 @@ func add_brush(mouse_pos, type): else: TL_pos.x = mouse_click_start_pos.x BR_pos.x = mouse_pos.x - + # Figure out the top and bottom positions of the corners and assign them to the proper variable. if mouse_pos.y < mouse_click_start_pos.y: TL_pos.y = mouse_pos.y @@ -177,11 +177,11 @@ func add_brush(mouse_pos, type): else: TL_pos.y = mouse_click_start_pos.y BR_pos.y = mouse_pos.y - + # Assign the positions to the brush. new_brush.brush_pos = TL_pos new_brush.brush_shape_rect_pos_BR = BR_pos - + # If the brush isa circle shape, then we need to calculate the radius of the circle. if type == BrushModes.CIRCLE_SHAPE: # Get the center point inbetween the mouse position and the position of the mouse when we clicked. @@ -190,7 +190,7 @@ func add_brush(mouse_pos, type): # the center to the top/bottom positon of the mouse. new_brush.brush_pos = center_pos new_brush.brush_shape_circle_radius = center_pos.distance_to(Vector2(center_pos.x, mouse_pos.y)) - + # Add the brush and update/draw all of the brushes. brush_data_list.append(new_brush) update() @@ -214,7 +214,7 @@ func _draw(): BrushModes.ERASER: # NOTE: this is a really cheap way of erasing that isn't really erasing! # However, this gives similar results in a fairy simple way! - + # Erasing works exactly the same was as pencil does for both the rectangle shape and the circle shape, # but instead of using brush.brush_color, we instead use bg_color instead. if brush.brush_shape == BrushShapes.RECTANGLE: @@ -237,13 +237,13 @@ func save_picture(path): # Wait a couple frames so the save dialog isn't in the way. yield (get_tree(), "idle_frame") yield (get_tree(), "idle_frame") - + # Get the viewport image. var img = get_viewport().get_texture().get_data() # Crop the image so we only have canvas area. var cropped_image = img.get_rect(Rect2(TL_node.global_position, IMAGE_SIZE)) # Flip the image on the Y-axis (it's flipped upside down by default). cropped_image.flip_y() - + # Save the image with the passed in path we got from the save dialog. cropped_image.save_png(path) diff --git a/2d/gd_paint/ToolsPanel.gd b/2d/gd_paint/ToolsPanel.gd index 894427b1..715c7255 100644 --- a/2d/gd_paint/ToolsPanel.gd +++ b/2d/gd_paint/ToolsPanel.gd @@ -50,7 +50,7 @@ func button_pressed(button_name): # If a brush mode button is pressed. var tool_name = null var shape_name = null - + if button_name == "mode_pencil": paint_control.brush_mode = paint_control.BrushModes.PENCIL brush_settings.modulate = Color(1, 1, 1, 1) @@ -84,7 +84,7 @@ func button_pressed(button_name): save_dialog.popup_centered() elif button_name == "undo_stroke": paint_control.undo_stroke() - + # Update the labels (in case the brush mode or brush shape has changed). if tool_name != null: label_tools.text = "Selected tool: " + tool_name diff --git a/2d/gd_paint/project.godot b/2d/gd_paint/project.godot index 17547124..c493bf68 100644 --- a/2d/gd_paint/project.godot +++ b/2d/gd_paint/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/grid_based_movement/grid/grid.gd b/2d/grid_based_movement/grid/grid.gd index 1d8c18e3..8bb6282d 100644 --- a/2d/grid_based_movement/grid/grid.gd +++ b/2d/grid_based_movement/grid/grid.gd @@ -16,7 +16,7 @@ func get_cell_pawn(coordinates): func request_move(pawn, direction): var cell_start = world_to_map(pawn.position) var cell_target = cell_start + direction - + var cell_target_type = get_cellv(cell_target) match cell_target_type: CellType.EMPTY: diff --git a/2d/grid_based_movement/pawns/actor.gd b/2d/grid_based_movement/pawns/actor.gd index 4a46f0b4..74b9d0ca 100644 --- a/2d/grid_based_movement/pawns/actor.gd +++ b/2d/grid_based_movement/pawns/actor.gd @@ -44,7 +44,7 @@ func move_to(target_position): # Stop the function execution until the animation finished yield($AnimationPlayer, "animation_finished") - + set_process(true) diff --git a/2d/grid_based_movement/project.godot b/2d/grid_based_movement/project.godot index ff85a1b5..fa9303c3 100644 --- a/2d/grid_based_movement/project.godot +++ b/2d/grid_based_movement/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/hdr/project.godot b/2d/hdr/project.godot index 982862bf..dded3f12 100644 --- a/2d/hdr/project.godot +++ b/2d/hdr/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/hexagonal_map/project.godot b/2d/hexagonal_map/project.godot index fc22d7e0..ea319be7 100644 --- a/2d/hexagonal_map/project.godot +++ b/2d/hexagonal_map/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/isometric/project.godot b/2d/isometric/project.godot index c20e1b1e..b5631d33 100644 --- a/2d/isometric/project.godot +++ b/2d/isometric/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/kinematic_character/player.gd b/2d/kinematic_character/player.gd index e1923167..a2186944 100644 --- a/2d/kinematic_character/player.gd +++ b/2d/kinematic_character/player.gd @@ -26,7 +26,7 @@ func _physics_process(delta): if (velocity.x <= WALK_MIN_SPEED and velocity.x > -WALK_MAX_SPEED) or (velocity.x >= -WALK_MIN_SPEED and velocity.x < WALK_MAX_SPEED): force.x += WALK_FORCE * walk - + if abs(walk) < 0.5: var vsign = sign(velocity.x) var vlen = abs(velocity.x) diff --git a/2d/kinematic_character/project.godot b/2d/kinematic_character/project.godot index e88da30d..59407a27 100644 --- a/2d/kinematic_character/project.godot +++ b/2d/kinematic_character/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/light2d_as_mask/project.godot b/2d/light2d_as_mask/project.godot index 57f97360..ab577222 100644 --- a/2d/light2d_as_mask/project.godot +++ b/2d/light2d_as_mask/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/lights_and_shadows/project.godot b/2d/lights_and_shadows/project.godot index bb144da3..0c834092 100644 --- a/2d/lights_and_shadows/project.godot +++ b/2d/lights_and_shadows/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/navigation/project.godot b/2d/navigation/project.godot index 2651056b..73988db6 100644 --- a/2d/navigation/project.godot +++ b/2d/navigation/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/navigation_astar/project.godot b/2d/navigation_astar/project.godot index dd0e1ca2..4eba2b3a 100644 --- a/2d/navigation_astar/project.godot +++ b/2d/navigation_astar/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/particles/project.godot b/2d/particles/project.godot index 4fb25a80..175f2cac 100644 --- a/2d/particles/project.godot +++ b/2d/particles/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/physics_platformer/enemy/enemy.gd b/2d/physics_platformer/enemy/enemy.gd index 6e1dbe7e..1372c75e 100644 --- a/2d/physics_platformer/enemy/enemy.gd +++ b/2d/physics_platformer/enemy/enemy.gd @@ -26,24 +26,24 @@ 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 is Bullet and not cc.disabled: # enqueue call call_deferred("_bullet_collider", cc, s, dp) 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 ($Sprite as Sprite).scale.x = -direction @@ -53,13 +53,13 @@ func _integrate_forces(s): elif direction > 0 and not rc_right.is_colliding() and rc_left.is_colliding(): direction = -direction ($Sprite as Sprite).scale.x = -direction - + lv.x = direction * WALK_SPEED - + if anim != new_anim: anim = new_anim ($AnimationPlayer as AnimationPlayer).play(anim) - + s.set_linear_velocity(lv) @@ -72,7 +72,7 @@ func _pre_explode(): $Shape1.queue_free() $Shape2.queue_free() $Shape3.queue_free() - + # Stay there mode = MODE_STATIC ($SoundExplode as AudioStreamPlayer2D).play() @@ -81,7 +81,7 @@ func _pre_explode(): func _bullet_collider(cc, s, dp): mode = MODE_RIGID state = State.DYING - + s.set_angular_velocity(sign(dp.x) * 33.0) set_friction(1) cc.disable() diff --git a/2d/physics_platformer/platform/moving_platform.gd b/2d/physics_platformer/platform/moving_platform.gd index 37a039b4..caa59ac6 100644 --- a/2d/physics_platformer/platform/moving_platform.gd +++ b/2d/physics_platformer/platform/moving_platform.gd @@ -9,9 +9,9 @@ var accum = 0.0 func _physics_process(delta): accum += delta * (1.0 / cycle) * TAU accum = fmod(accum, TAU) - + var d = sin(accum) var xf = Transform2D() - - xf[2]= motion * d + + xf[2]= motion * d ($Platform as RigidBody2D).transform = xf diff --git a/2d/physics_platformer/player/bullet.gd b/2d/physics_platformer/player/bullet.gd index e9572548..07e286bd 100644 --- a/2d/physics_platformer/player/bullet.gd +++ b/2d/physics_platformer/player/bullet.gd @@ -10,6 +10,6 @@ func _ready(): func disable(): if disabled: return - + ($AnimationPlayer as AnimationPlayer).play("shutdown") disabled = true diff --git a/2d/physics_platformer/player/player.gd b/2d/physics_platformer/player/player.gd index 631e315f..d8a6fc8d 100644 --- a/2d/physics_platformer/player/player.gd +++ b/2d/physics_platformer/player/player.gd @@ -50,47 +50,47 @@ var Enemy = preload("res://enemy/Enemy.tscn") 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: call_deferred("_spawn_enemy_above") - + # 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 implementing characters of all kinds, # compensates for physics imprecision, as well as human reaction delay. if shoot and not shooting: call_deferred("_shot_bullet") 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. @@ -100,10 +100,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: @@ -118,14 +118,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 ($SoundJump as AudioStreamPlayer2D).play() - + # Check siding. if lv.x < 0 and move_left: new_siding_left = true @@ -154,11 +154,11 @@ func _integrate_forces(s): else: var xv = abs(lv.x) xv -= AIR_DEACCEL * step - + 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" @@ -169,28 +169,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: ($Sprite as Sprite).scale.x = -1 else: ($Sprite as Sprite).scale.x = 1 - + siding_left = new_siding_left - + # Change animation. if new_anim != anim: anim = new_anim ($AnimationPlayer as AnimationPlayer).play(anim) - + shooting = shoot - + # Apply floor velocity. if found_floor: floor_h_velocity = s.get_contact_collider_velocity_at_position(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) @@ -205,15 +205,15 @@ func _shot_bullet(): else: ss = 1.0 var pos = position + ($BulletShoot as Position2D).position * Vector2(ss, 1.0) - + bi.position = pos get_parent().add_child(bi) - + bi.linear_velocity = Vector2(800.0 * ss, -80) - + ($Sprite/Smoke as Particles2D).restart() ($SoundShoot as AudioStreamPlayer2D).play() - + add_collision_exception_with(bi) # Make bullet and this not collide. diff --git a/2d/platformer/enemy/enemy.gd b/2d/platformer/enemy/enemy.gd index 05d2916d..ab0727cb 100644 --- a/2d/platformer/enemy/enemy.gd +++ b/2d/platformer/enemy/enemy.gd @@ -8,7 +8,7 @@ const FLOOR_NORMAL = Vector2(0, -1) const STATE_WALKING = 0 const STATE_KILLED = 1 -const WALK_SPEED = 70 +const WALK_SPEED = 70 var linear_velocity = Vector2() var direction = -1 diff --git a/2d/pong/project.godot b/2d/pong/project.godot index db7ac6d9..1c327478 100644 --- a/2d/pong/project.godot +++ b/2d/pong/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/role_playing_game/dialogue/dialogue_data/npc.json b/2d/role_playing_game/dialogue/dialogue_data/npc.json index 8e0bf27d..7efba441 100755 --- a/2d/role_playing_game/dialogue/dialogue_data/npc.json +++ b/2d/role_playing_game/dialogue/dialogue_data/npc.json @@ -1,5 +1,5 @@ { - "dialog_1" : {"name": "Unknown", "text": "Hey, it's a good time to have a JRPG fight, right?"}, - "dialog_2" : {"name": "Unknown", "text": "Let me introduce myself, I'm the OPPONENT"}, - "dialog_3" : {"name": "Opponent", "text": "Enough talking. Let's fight!"}, + "dialog_1": { "name": "Unknown", "text": "Hey, it's a good time to have a JRPG fight, right?" }, + "dialog_2": { "name": "Unknown", "text": "Let me introduce myself, I'm the OPPONENT" }, + "dialog_3": { "name": "Opponent", "text": "Enough talking. Let's fight!" } } diff --git a/2d/role_playing_game/dialogue/dialogue_data/object.json b/2d/role_playing_game/dialogue/dialogue_data/object.json index fc325888..1f981fe5 100755 --- a/2d/role_playing_game/dialogue/dialogue_data/object.json +++ b/2d/role_playing_game/dialogue/dialogue_data/object.json @@ -1,3 +1,3 @@ { - "dialog_1" : {"name":"Player", "text":"Just some object..." } + "dialog_1": { "name": "Player", "text": "Just some object..." } } diff --git a/2d/role_playing_game/dialogue/dialogue_data/player_lose.json b/2d/role_playing_game/dialogue/dialogue_data/player_lose.json index 2027cc2a..9b9756a2 100755 --- a/2d/role_playing_game/dialogue/dialogue_data/player_lose.json +++ b/2d/role_playing_game/dialogue/dialogue_data/player_lose.json @@ -1,3 +1,3 @@ { - "dialog_1" : {"name": "Opponent", "text": "Aha! I won, maybe you can try again next time"} + "dialog_1": { "name": "Opponent", "text": "Aha! I won, maybe you can try again next time" } } diff --git a/2d/role_playing_game/dialogue/dialogue_data/player_won.json b/2d/role_playing_game/dialogue/dialogue_data/player_won.json index 9eef0292..eb886bd2 100755 --- a/2d/role_playing_game/dialogue/dialogue_data/player_won.json +++ b/2d/role_playing_game/dialogue/dialogue_data/player_won.json @@ -1,3 +1,3 @@ { - "dialog_1" : {"name": "Opponent", "text": "Congratulations, you won!"} + "dialog_1": { "name": "Opponent", "text": "Congratulations, you won!" } } diff --git a/2d/role_playing_game/grid_movement/grid/Grid.gd b/2d/role_playing_game/grid_movement/grid/Grid.gd index b710f72f..17110375 100644 --- a/2d/role_playing_game/grid_movement/grid/Grid.gd +++ b/2d/role_playing_game/grid_movement/grid/Grid.gd @@ -19,7 +19,7 @@ func get_cell_pawn(cell, type = CellType.ACTOR): func request_move(pawn, direction): var cell_start = world_to_map(pawn.position) var cell_target = cell_start + direction - + var cell_tile_id = get_cellv(cell_target) match cell_tile_id: -1: @@ -29,7 +29,7 @@ func request_move(pawn, direction): CellType.OBJECT, CellType.ACTOR: var target_pawn = get_cell_pawn(cell_target, cell_tile_id) print("Cell %s contains %s" % [cell_target, target_pawn.name]) - + if not target_pawn.has_node("DialoguePlayer"): return get_node(dialogue_ui).show_dialogue(pawn, target_pawn.get_node("DialoguePlayer")) diff --git a/2d/role_playing_game/grid_movement/pawns/RandomActor.gd b/2d/role_playing_game/grid_movement/pawns/RandomActor.gd index 3313b3c4..a0320d4a 100644 --- a/2d/role_playing_game/grid_movement/pawns/RandomActor.gd +++ b/2d/role_playing_game/grid_movement/pawns/RandomActor.gd @@ -7,7 +7,7 @@ func get_input_direction(): return Vector2() var random_x = DIRECTIONS[randi() % DIRECTIONS.size()] var random_y = DIRECTIONS[randi() % DIRECTIONS.size()] - + var random_axis = randi() % 2 if random_axis > 0: random_x = 0 diff --git a/2d/role_playing_game/grid_movement/pawns/Walker.gd b/2d/role_playing_game/grid_movement/pawns/Walker.gd index bd21596b..8942bd52 100644 --- a/2d/role_playing_game/grid_movement/pawns/Walker.gd +++ b/2d/role_playing_game/grid_movement/pawns/Walker.gd @@ -42,9 +42,9 @@ func move_to(target_position): $Tween.interpolate_property($Pivot, "position", move_direction * 32, Vector2(), $AnimationPlayer.current_animation_length, Tween.TRANS_LINEAR, Tween.EASE_IN) $Pivot/Sprite.position = position - target_position position = target_position - + yield($AnimationPlayer, "animation_finished") - + set_process(true) diff --git a/2d/role_playing_game/project.godot b/2d/role_playing_game/project.godot index e848f4db..0c5dc5ce 100644 --- a/2d/role_playing_game/project.godot +++ b/2d/role_playing_game/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/role_playing_game/screens/combat/actors/Opponent.tscn b/2d/role_playing_game/screens/combat/actors/Opponent.tscn index 7b273db2..42fd4536 100644 --- a/2d/role_playing_game/screens/combat/actors/Opponent.tscn +++ b/2d/role_playing_game/screens/combat/actors/Opponent.tscn @@ -10,7 +10,7 @@ func set_active(value): .set_active(value) if not active: return - + $Timer.start() yield($Timer, \"timeout\") var target diff --git a/2d/role_playing_game/turn_combat/combatants/Combatant.gd b/2d/role_playing_game/turn_combat/combatants/Combatant.gd index 2def0eb1..b17f600c 100644 --- a/2d/role_playing_game/turn_combat/combatants/Combatant.gd +++ b/2d/role_playing_game/turn_combat/combatants/Combatant.gd @@ -10,7 +10,7 @@ func set_active(value): active = value set_process(value) set_process_input(value) - + if not active: return if $Health.armor >= $Health.base_armor + defense: diff --git a/2d/role_playing_game/turn_combat/combatants/Opponent.gd b/2d/role_playing_game/turn_combat/combatants/Opponent.gd index 5512d456..d7cfb08e 100644 --- a/2d/role_playing_game/turn_combat/combatants/Opponent.gd +++ b/2d/role_playing_game/turn_combat/combatants/Opponent.gd @@ -4,7 +4,7 @@ func set_active(value): .set_active(value) if not active: return - + $Timer.start() yield($Timer, "timeout") var target diff --git a/2d/screen_space_shaders/project.godot b/2d/screen_space_shaders/project.godot index 522de544..6e8af1d6 100644 --- a/2d/screen_space_shaders/project.godot +++ b/2d/screen_space_shaders/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/screen_space_shaders/shaders/BCS.shader b/2d/screen_space_shaders/shaders/BCS.shader index 9cf101f8..7fba0ce2 100644 --- a/2d/screen_space_shaders/shaders/BCS.shader +++ b/2d/screen_space_shaders/shaders/BCS.shader @@ -6,10 +6,10 @@ uniform float saturation = 1.8; void fragment() { vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb; - + c.rgb = mix(vec3(0.0), c.rgb, brightness); c.rgb = mix(vec3(0.5), c.rgb, contrast); c.rgb = mix(vec3(dot(vec3(1.0), c.rgb) * 0.33333), c.rgb, saturation); - + COLOR.rgb = c; } diff --git a/2d/screen_space_shaders/shaders/mirage.shader b/2d/screen_space_shaders/shaders/mirage.shader index 2b947a7a..b08e24d8 100644 --- a/2d/screen_space_shaders/shaders/mirage.shader +++ b/2d/screen_space_shaders/shaders/mirage.shader @@ -8,6 +8,6 @@ void fragment() { uv.x += sin(uv.y * frequency + TIME) * depth; uv.x = clamp(uv.x, 0.0, 1.0); vec3 c = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb; - + COLOR.rgb = c; } diff --git a/2d/screen_space_shaders/shaders/old_film.shader b/2d/screen_space_shaders/shaders/old_film.shader index b9565ad6..48983749 100644 --- a/2d/screen_space_shaders/shaders/old_film.shader +++ b/2d/screen_space_shaders/shaders/old_film.shader @@ -15,17 +15,17 @@ float make_grain(float time, vec2 uv) { void fragment() { vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb; - + //float v = max(c.r, max(c.g, c.b)); float v = dot(c, vec3(0.33333, 0.33333, 0.33333)); v = sqrt(v); //v *= v; - + float f = 1.0 / fps; float g = make_grain(TIME - mod(TIME, f), UV); g = max(g, make_grain(TIME - mod(TIME, f) + f, UV) * 0.5); g = max(g, make_grain(TIME - mod(TIME, f) + f * 2.0, UV) * 0.25); - + COLOR.rgb = base.rgb * v - vec3(g) * grain_strength; COLOR.rgb *= texture(vignette, UV).r; float ft = TIME * 0.002; diff --git a/2d/screen_space_shaders/shaders/pixelize.shader b/2d/screen_space_shaders/shaders/pixelize.shader index f82890a2..1af9b959 100644 --- a/2d/screen_space_shaders/shaders/pixelize.shader +++ b/2d/screen_space_shaders/shaders/pixelize.shader @@ -6,6 +6,6 @@ uniform float size_y = 0.008; void fragment() { vec2 uv = SCREEN_UV; uv -= mod(uv, vec2(size_x, size_y)); - + COLOR.rgb = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb; } diff --git a/2d/sdf_font/project.godot b/2d/sdf_font/project.godot index 90e17deb..8e2b79fd 100644 --- a/2d/sdf_font/project.godot +++ b/2d/sdf_font/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/2d/sprite_shaders/project.godot b/2d/sprite_shaders/project.godot index 824989d8..b8a1bf59 100644 --- a/2d/sprite_shaders/project.godot +++ b/2d/sprite_shaders/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/ik/addons/sade/ik_fabrik.gd b/3d/ik/addons/sade/ik_fabrik.gd index f972c014..21394a1b 100644 --- a/3d/ik/addons/sade/ik_fabrik.gd +++ b/3d/ik/addons/sade/ik_fabrik.gd @@ -52,61 +52,61 @@ func _ready(): if has_node("target") == false: target = Spatial.new() add_child(target) - - if Engine.editor_hint == true: + + if Engine.editor_hint: if get_tree() != null: if get_tree().edited_scene_root != null: target.set_owner(get_tree().edited_scene_root) - + target.name = "target" else: target = get_node("target") - + # If we are in the editor, we want to make a sphere at this node - if Engine.editor_hint == true: + if Engine.editor_hint: _make_editor_sphere_at_node(target, Color(1, 0, 1, 1)) - + if middle_joint_target == null: if has_node("middle_joint_target") == false: middle_joint_target = Spatial.new() add_child(middle_joint_target) - - if Engine.editor_hint == true: + + if Engine.editor_hint: if get_tree() != null: if get_tree().edited_scene_root != null: middle_joint_target.set_owner(get_tree().edited_scene_root) - + middle_joint_target.name = "middle_joint_target" else: middle_joint_target = get_node("middle_joint_target") - + # If we are in the editor, we want to make a sphere at this node - if Engine.editor_hint == true: + if Engine.editor_hint: _make_editor_sphere_at_node(middle_joint_target, Color(1, 0.24, 1, 1)) - + # Make all of the bone nodes for each bone in the IK chain _make_bone_nodes() - + # Make sure we're using the right update mode _set_update_mode(update_mode) # Various upate methods func _process(_delta): - if reset_iterations_on_update == true: + if reset_iterations_on_update: chain_iterations = 0 update_skeleton() func _physics_process(_delta): - if reset_iterations_on_update == true: + if reset_iterations_on_update: chain_iterations = 0 update_skeleton() func _notification(what): if what == NOTIFICATION_TRANSFORM_CHANGED: - if reset_iterations_on_update == true: + if reset_iterations_on_update: chain_iterations = 0 update_skeleton() @@ -115,51 +115,51 @@ func _notification(what): func update_skeleton(): #### ERROR CHECKING conditions - if first_call == true: + if first_call: _set_skeleton_path(skeleton_path) first_call = false - + if skeleton == null: _set_skeleton_path(skeleton_path) - + return - + if bones_in_chain == null: - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: No Bones in IK chain defined!") return if bones_in_chain_lengths == null: - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: No Bone lengths in IK chain defined!") return - + if bones_in_chain.size() != bones_in_chain_lengths.size(): - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: bones_in_chain and bones_in_chain_lengths!") return - + ################################ - + # Set all of the bone IDs in bone_IDs, if they are not already made var i = 0 if bone_IDs.size() <= 0: for bone_name in bones_in_chain: bone_IDs[bone_name] = skeleton.find_bone(bone_name) - + # Set the bone node to the currect bone position bone_nodes[i].global_transform = get_bone_transform(i) # If this is not the last bone in the bone chain, make it look at the next bone in the bone chain if i < bone_IDs.size()-1: bone_nodes[i].look_at(get_bone_transform(i+1).origin + skeleton.global_transform.origin, Vector3.UP) - + i += 1 - + # Set the total length of the bone chain, if it is not already set if total_length == INF: total_length = 0 for bone_length in bones_in_chain_lengths: total_length += bone_length - + # Solve the bone chain solve_chain() @@ -167,14 +167,14 @@ func update_skeleton(): func solve_chain(): # If we have reached our max chain iteration, and we are limiting ourselves, then return. # Otherwise set chain_iterations to zero (so we constantly update) - if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations == true: + if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations: return else: chain_iterations = 0 - + # Update the origin with the current bone's origin chain_origin = get_bone_transform(0).origin - + # Get the direction of the final bone by using the next to last bone if there is more than 2 bones. # If there are only 2 bones, we use the target's forward Z vector instead (not ideal, but it works fairly well) var dir @@ -182,19 +182,19 @@ func solve_chain(): dir = bone_nodes[bone_nodes.size()-2].global_transform.basis.z.normalized() else: dir = -target.global_transform.basis.z.normalized() - + # Get the target position (accounting for the final bone and it's length) var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1]) - + # If we are using middle joint target (and have more than 2 bones), move our middle joint towards it! - if use_middle_joint_target == true: + if use_middle_joint_target: if bone_nodes.size() > 2: var middle_point_pos = middle_joint_target.global_transform bone_nodes[bone_nodes.size()/2].global_transform.origin = middle_point_pos.origin - + # Get the distance from the origin to the target var distance = (chain_origin - target_pos).length() - + # If the distance is farther than our total reach, the target cannot be reached. # Make the bone chain a straight line pointing towards the target if distance > total_length: @@ -203,37 +203,37 @@ func solve_chain(): var curr_origin = bone_nodes[i].global_transform.origin var r =(target_pos - curr_origin).length() var l = bones_in_chain_lengths[i] / r - + # Find new join position var new_pos = curr_origin.linear_interpolate(target_pos, l) - + # Apply it to the bone node bone_nodes[i].look_at(new_pos, Vector3.UP) bone_nodes[i].global_transform.origin = new_pos - + # Apply the rotation to the first node in the bone chain, making it look at the next bone in the bone chain bone_nodes[0].look_at(bone_nodes[1].global_transform.origin, Vector3.UP) - + # If the distance is NOT farther than our total reach, the target can be reached. else: # Get the difference between our end effector (the final bone in the chain) and the target var dif = (bone_nodes[bone_nodes.size()-1].global_transform.origin - target_pos).length() - + # Check to see if the distance from the end effector to the target is within our error margin (CHAIN_TOLERANCE). # If it not, move the chain towards the target (going forwards, backwards, and then applying rotation) while dif > CHAIN_TOLERANCE: chain_backward() chain_forward() chain_apply_rotation() - + # Update the difference between our end effector (the final bone in the chain) and the target dif = (bone_nodes[bone_nodes.size()-1].global_transform.origin - target_pos).length() - + # Add one to chain_iterations. If we have reached our max iterations, then break chain_iterations = chain_iterations + 1 if chain_iterations >= CHAIN_MAX_ITER: break - + # Reset the bone node transforms to the skeleton bone transforms #if constrained == false: # Resetting seems to break bone constraints... for i in range(0, bone_nodes.size()): @@ -250,17 +250,17 @@ func chain_backward(): dir = bone_nodes[bone_nodes.size() - 2].global_transform.basis.z.normalized() else: dir = -target.global_transform.basis.z.normalized() - + # Set the position of the end effector (the final bone in the chain) to the target position bone_nodes[bone_nodes.size()-1].global_transform.origin = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1]) - + # For all of the other bones, move them towards the target var i = bones_in_chain.size() - 1 while i >= 1: var prev_origin = bone_nodes[i].global_transform.origin i -= 1 var curr_origin = bone_nodes[i].global_transform.origin - + var r = prev_origin - curr_origin var l = bones_in_chain_lengths[i] / r.length() # Apply the new joint position @@ -271,12 +271,12 @@ func chain_backward(): func chain_forward(): # Set root at initial position bone_nodes[0].global_transform.origin = chain_origin - + # Go through every bone in the bone chain for i in range(bones_in_chain.size() - 1): var curr_origin = bone_nodes[i].global_transform.origin var next_origin = bone_nodes[i + 1].global_transform.origin - + var r = next_origin - curr_origin var l = bones_in_chain_lengths[i] / r.length() # Apply the new joint position, (potentially with constraints), to the bone node @@ -297,38 +297,38 @@ func chain_apply_rotation(): # Get the bone node for this bone, and the previous bone var b_target = bone_nodes[i].global_transform var b_target_two = bone_nodes[i-1].global_transform - + # Convert the bone nodes positions from world space to bone/skeleton space b_target.origin = skeleton.global_transform.xform_inv(b_target.origin) b_target_two.origin = skeleton.global_transform.xform_inv(b_target_two.origin) - + # Get the direction that the previous bone is pointing towards var dir = (target.global_transform.origin - b_target_two.origin).normalized() - + # Make this bone look in the same the direction as the last bone bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3.UP) else: var b_target = target.global_transform b_target.origin = skeleton.global_transform.xform_inv(b_target.origin) bone_trans = bone_trans.looking_at(b_target.origin, Vector3.UP) - + # If this is NOT the last bone in the bone chain, rotate the bone to look at the next # bone in the bone chain. else: # Get the bone node for this bone, and the next bone var b_target = bone_nodes[i].global_transform var b_target_two = bone_nodes[i+1].global_transform - + # Convert the bone nodes positions from world space to bone/skeleton space b_target.origin = skeleton.global_transform.xform_inv(b_target.origin) b_target_two.origin = skeleton.global_transform.xform_inv(b_target_two.origin) - + # Get the direction towards the next bone var dir = (b_target_two.origin - b_target.origin).normalized() - + # Make this bone look towards the direction of the next bone bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3.UP) - + # The the bone's (updated) transform set_bone_transform(i, bone_trans) @@ -336,12 +336,12 @@ func chain_apply_rotation(): func get_bone_transform(bone, convert_to_world_space = true): # Get the global transform of the bone var ret: Transform = skeleton.get_bone_global_pose(bone_IDs[bones_in_chain[bone]]) - + # If we need to convert the bone position from bone/skeleton space to world space, we # use the Xform of the skeleton (because bone/skeleton space is relative to the position of the skeleton node). - if convert_to_world_space == true: + if convert_to_world_space: ret.origin = skeleton.global_transform.xform(ret.origin) - + return ret @@ -381,11 +381,11 @@ func _make_editor_sphere_at_node(node, color): func _set_update_mode(new_value): update_mode = new_value - + set_process(false) set_physics_process(false) set_notify_transform(false) - + if update_mode == 0: set_process(true) elif update_mode == 1: @@ -393,43 +393,43 @@ func _set_update_mode(new_value): elif update_mode == 2: set_notify_transform(true) else: - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: Unknown update mode. NOT updating skeleton") return func _set_skeleton_path(new_value): # Because get_node doesn't work in the first call, we just want to assign instead - if first_call == true: + if first_call: skeleton_path = new_value return - + skeleton_path = new_value - + if skeleton_path == null: - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: No Nodepath selected for skeleton_path!") return - + var temp = get_node(skeleton_path) if temp != null: # If it has the method "get_bone_global_pose" it is likely a Skeleton - if temp.has_method("get_bone_global_pose") == true: + if temp.has_method("get_bone_global_pose"): skeleton = temp bone_IDs = {} - + # (Delete all of the old bone nodes and) Make all of the bone nodes for each bone in the IK chain _make_bone_nodes() - - if debug_messages == true: + + if debug_messages: printerr(name, " - IK_FABRIK: Attached to a new skeleton") # If not, then it's (likely) not a Skeleton node else: skeleton = null - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: skeleton_path does not point to a skeleton!") else: - if debug_messages == true: + if debug_messages: printerr(name, " - IK_FABRIK: No Nodepath selected for skeleton_path!") @@ -438,33 +438,33 @@ func _set_skeleton_path(new_value): func _make_bone_nodes(): # Remove all of the old bone nodes # TODO: (not a huge concern, as these can be removed in the editor) - + for bone in range(0, bones_in_chain.size()): - + var bone_name = bones_in_chain[bone] if has_node(bone_name) == false: var new_node = Spatial.new() bone_nodes[bone] = new_node add_child(bone_nodes[bone]) - - if Engine.editor_hint == true: + + if Engine.editor_hint: if get_tree() != null: if get_tree().edited_scene_root != null: bone_nodes[bone].set_owner(get_tree().edited_scene_root) - + bone_nodes[bone].name = bone_name - + else: bone_nodes[bone] = get_node(bone_name) - + # If we are in the editor, we want to make a sphere at this node - if Engine.editor_hint == true: + if Engine.editor_hint: _make_editor_sphere_at_node(bone_nodes[bone], Color(0.65, 0, 1, 1)) func _set_bone_chain_bones(new_value): bones_in_chain = new_value - + _make_bone_nodes() diff --git a/3d/ik/addons/sade/ik_look_at.gd b/3d/ik/addons/sade/ik_look_at.gd index 802f4b2e..8a1b64fd 100644 --- a/3d/ik/addons/sade/ik_look_at.gd +++ b/3d/ik/addons/sade/ik_look_at.gd @@ -20,7 +20,7 @@ func _ready(): set_process(false) set_physics_process(false) set_notify_transform(false) - + if update_mode == 0: set_process(true) elif update_mode == 1: @@ -28,10 +28,10 @@ func _ready(): elif update_mode == 2: set_notify_transform(true) else: - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: Unknown update mode. NOT updating skeleton") - - if Engine.editor_hint == true: + + if Engine.editor_hint: _setup_for_editor() @@ -51,33 +51,33 @@ func _notification(what): func update_skeleton(): # NOTE: Because get_node doesn't work in _ready, we need to skip # a call before doing anything. - if first_call == true: + if first_call: first_call = false if skeleton_to_use == null: _set_skeleton_path(skeleton_path) - - + + # If we do not have a skeleton and/or we're not supposed to update, then return. if skeleton_to_use == null: return if update_mode >= 3: return - + # Get the bone var bone = skeleton_to_use.find_bone(bone_name) - + # If no bone is found (-1), then return (and optionally print an error) if bone == -1: - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: No bone in skeleton found with name [", bone_name, "]!") return - + # get the bone's rest position var rest = skeleton_to_use.get_bone_global_pose(bone) - + # Convert our position relative to the skeleton's transform var target_pos = skeleton_to_use.global_transform.xform_inv(global_transform.origin) - + # Call helper's look_at function with the chosen up axis. if look_at_axis == 0: rest = rest.looking_at(target_pos, Vector3(1, 0, 0)) @@ -87,34 +87,34 @@ func update_skeleton(): rest = rest.looking_at(target_pos, Vector3(0, 0, 1)) else: rest = rest.looking_at(target_pos, Vector3(0, 1, 0)) - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: Unknown look_at_axis value!") - + # Get our rotation euler, and the bone's rotation euler var rest_euler = rest.basis.get_euler() var self_euler = global_transform.basis.orthonormalized().get_euler() - + # If we using negative rotation, we flip our rotation euler - if use_negative_our_rot == true: + if use_negative_our_rot: self_euler = -self_euler - + # Apply our rotation euler, if wanted/required - if use_our_rotation_x == true: + if use_our_rotation_x: rest_euler.x = self_euler.x - if use_our_rotation_y == true: + if use_our_rotation_y: rest_euler.y = self_euler.y - if use_our_rotation_z == true: + if use_our_rotation_z: rest_euler.z = self_euler.z - + # Rotate the bone by the (potentially) changed euler angle(s) rest.basis = Basis(rest_euler) - + # If we have additional rotation, then rotate it by the local rotation vectors if additional_rotation != Vector3.ZERO: rest.basis = rest.basis.rotated(rest.basis.x, deg2rad(additional_rotation.x)) rest.basis = rest.basis.rotated(rest.basis.y, deg2rad(additional_rotation.y)) rest.basis = rest.basis.rotated(rest.basis.z, deg2rad(additional_rotation.z)) - + # Finally, apply the bone rotation to the skeleton skeleton_to_use.set_bone_global_pose(bone, rest) @@ -146,58 +146,58 @@ func _setup_for_editor(): func _set_update(new_value): update_mode = new_value - + # Set all of our processes to false set_process(false) set_physics_process(false) set_notify_transform(false) - + # Based on the value of upate, change how we handle updating the skeleton if update_mode == 0: set_process(true) - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: updating skeleton using _process...") elif update_mode == 1: set_physics_process(true) - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: updating skeleton using _physics_process...") elif update_mode == 2: set_notify_transform(true) - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: updating skeleton using _notification...") else: - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: NOT updating skeleton due to unknown update method...") func _set_skeleton_path(new_value): # Because get_node doesn't work in the first call, we just want to assign instead # This is to get around a issue with NodePaths exposed to the editor - if first_call == true: + if first_call: skeleton_path = new_value return - + # Assign skeleton_path to whatever value is passed skeleton_path = new_value - + if skeleton_path == null: - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!") return - + # Get the node at that location, if there is one var temp = get_node(skeleton_path) if temp != null: # If the node has the method "find_bone" then we can assume it is (likely) a skeleton - if temp.has_method("find_bone") == true: + if temp.has_method("find_bone"): skeleton_to_use = temp - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: attached to (new) skeleton") # If not, then it's (likely) not a skeleton else: skeleton_to_use = null - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: skeleton_path does not point to a skeleton!") else: - if debug_messages == true: + if debug_messages: print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!") diff --git a/3d/ik/addons/sade/plugin_main.gd b/3d/ik/addons/sade/plugin_main.gd index ff415fe3..1c89eac3 100644 --- a/3d/ik/addons/sade/plugin_main.gd +++ b/3d/ik/addons/sade/plugin_main.gd @@ -3,7 +3,7 @@ extends EditorPlugin func _enter_tree(): # Plugin Initialization here! - + # ------ IK STUFF ------ add_custom_type("IK_LookAt", "Spatial", preload("ik_look_at.gd"), preload("ik_look_at.png")) add_custom_type("IK_FABRIK", "Spatial", preload("ik_fabrik.gd"), preload("ik_fabrik.png")) @@ -12,7 +12,7 @@ func _enter_tree(): func _exit_tree(): # Plugin Clean-up here! - + # ------ IK STUFF ------ remove_custom_type("IK_LookAt") remove_custom_type("IK_FABRIK") diff --git a/3d/ik/fps/example_player.gd b/3d/ik/fps/example_player.gd index 233e3c17..95e5343a 100644 --- a/3d/ik/fps/example_player.gd +++ b/3d/ik/fps/example_player.gd @@ -55,16 +55,16 @@ var simple_bullet = preload("res://fps/simple_bullet.tscn") func _ready(): - + camera = get_node("CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Camera") camera_holder = get_node("CameraHolder") path_follow_node = get_node("CameraHolder/Lean_Path/PathFollow") - + anim_player = get_node("CameraHolder/AnimationPlayer") anim_player.connect("animation_finished", self, "animation_finished") - + pistol_end = get_node("CameraHolder/Weapon/Pistol/Pistol_end") - + set_physics_process(true) Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) set_process_input(true) @@ -76,12 +76,12 @@ func _physics_process(delta): func process_input(delta): - + # Reset dir, so our previous movement does not effect us dir = Vector3() # Get the camera's global transform so we can use its directional vectors var cam_xform = camera.get_global_transform() - + # ---------------------------------- # Walking if Input.is_key_pressed(KEY_UP) or Input.is_key_pressed(KEY_W): @@ -92,33 +92,33 @@ func process_input(delta): dir += -cam_xform.basis[0] if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D): dir += cam_xform.basis[0] - + if Input.is_action_just_pressed("ui_cancel"): if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) else: Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - + if Input.is_mouse_button_pressed(2): if right_mouse_down == false: right_mouse_down = true - - if anim_done == true: + + if anim_done: if current_anim != "Aiming": anim_player.play("Aiming") current_anim = "Aiming" else: anim_player.play("Idle") current_anim = "Idle" - + anim_done = false else: right_mouse_down = false - + if Input.is_mouse_button_pressed(1): if left_mouse_timer <= 0: left_mouse_timer = LEFT_MOUSE_FIRE_TIME - + # Create a bullet var new_bullet = simple_bullet.instance() get_tree().root.add_child(new_bullet) @@ -127,8 +127,8 @@ func process_input(delta): if left_mouse_timer > 0: left_mouse_timer -= delta # ---------------------------------- - - + + # ---------------------------------- # Sprinting if Input.is_key_pressed(KEY_SHIFT): @@ -136,7 +136,7 @@ func process_input(delta): else: is_sprinting = false # ---------------------------------- - + # ---------------------------------- # Jumping if Input.is_key_pressed(KEY_SPACE): @@ -147,8 +147,8 @@ func process_input(delta): else: jump_button_down = false # ---------------------------------- - - + + # ---------------------------------- # Leaninng if Input.is_key_pressed(KEY_Q): @@ -164,7 +164,7 @@ func process_input(delta): lean_value += 1 * delta if lean_value > 0.5: lean_value = 0.5 - + lean_value = clamp(lean_value, 0, 1) path_follow_node.unit_offset = lean_value if lean_value < 0.5: @@ -177,24 +177,24 @@ func process_input(delta): func process_movement(delta): - + var grav = norm_grav - + dir.y = 0 dir = dir.normalized() - + vel.y += delta*grav - + var hvel = vel hvel.y = 0 - + var target = dir if is_sprinting: target *= MAX_SPRINT_SPEED else: target *= MAX_SPEED - - + + var accel if dir.dot(hvel) > 0: if is_sprinting == false: @@ -203,32 +203,32 @@ func process_movement(delta): accel = SPRINT_ACCEL else: accel = DEACCEL - + hvel = hvel.linear_interpolate(target, accel*delta) - + vel.x = hvel.x vel.z = hvel.z - + vel = move_and_slide(vel,Vector3(0,1,0)) # Mouse based camera movement func _input(event): - + if event is InputEventMouseMotion && Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: - + rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1)) camera_holder.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY)) - + # We need to clamp the camera's rotation so we cannot rotate ourselves upside down var camera_rot = camera_holder.rotation_degrees if camera_rot.x < -40: camera_rot.x = -40 elif camera_rot.x > 60: camera_rot.x = 60 - + camera_holder.rotation_degrees = camera_rot - + else: pass diff --git a/3d/ik/project.godot b/3d/ik/project.godot index 176cf6fb..a88849d5 100644 --- a/3d/ik/project.godot +++ b/3d/ik/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/ik/target_from_mousepos.gd b/3d/ik/target_from_mousepos.gd index 396e3a93..ffc631d6 100644 --- a/3d/ik/target_from_mousepos.gd +++ b/3d/ik/target_from_mousepos.gd @@ -12,10 +12,10 @@ func _ready(): func _process(_delta): var mouse_to_world = project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED - + if flip_axis == false: mouse_to_world.z *= -1 else: mouse_to_world = -mouse_to_world - + targets.transform.origin = mouse_to_world diff --git a/3d/kinematic_character/project.godot b/3d/kinematic_character/project.godot index 92e127cd..3cd21387 100644 --- a/3d/kinematic_character/project.godot +++ b/3d/kinematic_character/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/material_testers/project.godot b/3d/material_testers/project.godot index df00ee52..c315d1d0 100644 --- a/3d/material_testers/project.godot +++ b/3d/material_testers/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/material_testers/tester.gd b/3d/material_testers/tester.gd index d2d6dbd0..a3047a62 100644 --- a/3d/material_testers/tester.gd +++ b/3d/material_testers/tester.gd @@ -40,7 +40,7 @@ func _unhandled_input(ev): zoom += ZOOM_SPEED zoom = clamp(zoom, 2, 8) camera.translation.z = zoom - + if ev is InputEventMouseMotion and ev.button_mask & MAIN_BUTTONS: # Compensate motion speed to be resolution-independent (based on the window height). var relative_motion = ev.relative * get_viewport().size.y / base_height diff --git a/3d/navmesh/navmesh.gd b/3d/navmesh/navmesh.gd index 18929339..610d7171 100644 --- a/3d/navmesh/navmesh.gd +++ b/3d/navmesh/navmesh.gd @@ -33,16 +33,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.UP) get_node("RobotBase").set_transform(t) - + if path.size() < 2: path = [] set_process(false) @@ -55,11 +55,11 @@ func _input(event): var from = get_node("CameraBase/Camera").project_ray_origin(event.position) var to = from + get_node("CameraBase/Camera").project_ray_normal(event.position) * 100 var p = get_closest_point_to_segment(from, to) - + begin = get_closest_point(get_node("RobotBase").get_translation()) end = p _update_path() - + if event is InputEventMouseMotion: if event.button_mask & (BUTTON_MASK_MIDDLE + BUTTON_MASK_RIGHT): camrot += event.relative.x * 0.005 @@ -72,7 +72,7 @@ func _update_path(): path = Array(p) # Vector3 array too complex to use, convert to regular array. path.invert() set_process(true) - + if draw_path: var im = get_node("Draw") im.set_material_override(m) diff --git a/3d/navmesh/project.godot b/3d/navmesh/project.godot index 6c8c0cf2..abf79f6a 100644 --- a/3d/navmesh/project.godot +++ b/3d/navmesh/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/platformer/enemy.gd b/3d/platformer/enemy.gd index afdbd3c2..441a86ab 100644 --- a/3d/platformer/enemy.gd +++ b/3d/platformer/enemy.gd @@ -24,15 +24,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 is preload("res://bullet.gd") and cc.enabled: set_mode(MODE_RIGID) @@ -43,15 +43,15 @@ func _integrate_forces(state): cc.enabled = false get_node("SoundHit").play() return - + var col_floor = get_node("Armature/RayFloor").is_colliding() var col_wall = get_node("Armature/RayWall").is_colliding() - + var advance = col_floor and not col_wall - + 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 +59,17 @@ func _integrate_forces(state): else: if prev_advance: rot_dir = 1 - + dir = Basis(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/player.gd b/3d/platformer/player.gd index 646d2308..00b52273 100644 --- a/3d/platformer/player.gd +++ b/3d/platformer/player.gd @@ -32,15 +32,15 @@ func _ready(): func _physics_process(delta): linear_velocity += gravity * delta - + var anim = ANIM_FLOOR - + var vv = linear_velocity.y # Vertical velocity. var hv = Vector3(linear_velocity.x, 0, linear_velocity.z) # Horizontal velocity. - + var hdir = hv.normalized() # Horizontal direction. var hspeed = hv.length() # Horizontal speed. - + # Player input var cam_basis = get_node("Target/Camera").get_global_transform().basis var dir = Vector3() # Where does the player intend to walk to. @@ -50,39 +50,39 @@ func _physics_process(delta): dir -= Input.get_action_strength("move_forward") * cam_basis[2] dir.y = 0 dir = dir.normalized() - + var jump_attempt = Input.is_action_pressed("jump") var shoot_attempt = Input.is_action_pressed("shoot") - + if is_on_floor(): var sharp_turn = hspeed > 0.1 and rad2deg(acos(dir.dot(hdir))) > sharp_turn_threshold - + if dir.length() > 0.1 and !sharp_turn: if hspeed > 0.001: hdir = adjust_facing(hdir, dir, delta, 1.0 / hspeed * TURN_SPEED, Vector3.UP) facing_dir = hdir else: hdir = 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 - Vector3.UP * facing_mesh.dot(Vector3.UP)).normalized() - + if hspeed > 0: facing_mesh = adjust_facing(facing_mesh, dir, delta, 1.0 / hspeed * TURN_SPEED, Vector3.UP) var m3 = Basis(-facing_mesh, Vector3.UP, -facing_mesh.cross(Vector3.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 @@ -92,7 +92,7 @@ func _physics_process(delta): anim = ANIM_AIR_UP else: anim = ANIM_AIR_DOWN - + if dir.length() > 0.1: hv += dir * (accel * 0.2 * delta) if hv.length() > max_speed: @@ -103,22 +103,22 @@ func _physics_process(delta): if hspeed < 0: hspeed = 0 hv = hdir * hspeed - + if jumping and vv < 0: jumping = false - + linear_velocity = hv + Vector3.UP * vv - + if is_on_floor(): movement_dir = linear_velocity - + linear_velocity = move_and_slide(linear_velocity, -gravity.normalized()) - + 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.tscn").instance() @@ -127,12 +127,12 @@ func _physics_process(delta): bullet.set_linear_velocity(get_node("Armature/Bullet").get_global_transform().basis[2].normalized() * 20) bullet.add_collision_exception_with(self) # Add it to bullet. get_node("SoundShoot").play() - + prev_shoot = shoot_attempt - + if is_on_floor(): 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)) @@ -140,15 +140,15 @@ func _physics_process(delta): 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 @@ -158,5 +158,5 @@ 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() diff --git a/3d/platformer/project.godot b/3d/platformer/project.godot index e37f37a4..bbb985be 100644 --- a/3d/platformer/project.godot +++ b/3d/platformer/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/truck_town/follow_camera.gd b/3d/truck_town/follow_camera.gd index 97224069..a8033695 100644 --- a/3d/truck_town/follow_camera.gd +++ b/3d/truck_town/follow_camera.gd @@ -17,7 +17,7 @@ func _ready(): break else: node = node.get_parent() - + # This detaches the camera transform from the parent spatial node. set_as_toplevel(true) @@ -25,25 +25,25 @@ func _ready(): func _physics_process(_delta): var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin - + var from_target = pos - target - + # Check ranges. if from_target.length() < min_distance: from_target = from_target.normalized() * min_distance elif from_target.length() > max_distance: from_target = from_target.normalized() * max_distance - + # Check upper and lower height. if from_target.y > max_height: from_target.y = max_height if from_target.y < min_height: from_target.y = min_height - + pos = target + from_target - + look_at_from_position(pos, target, Vector3.UP) - + # Turn a little up or down var t = get_transform() t.basis = Basis(t.basis[0], deg2rad(angle_v_adjust)) * t.basis diff --git a/3d/truck_town/project.godot b/3d/truck_town/project.godot index 20cc3b44..f7f6e3b1 100644 --- a/3d/truck_town/project.godot +++ b/3d/truck_town/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/3d/truck_town/vehicle.gd b/3d/truck_town/vehicle.gd index 48bd2e26..fa78a674 100644 --- a/3d/truck_town/vehicle.gd +++ b/3d/truck_town/vehicle.gd @@ -10,15 +10,15 @@ export var engine_force_value = 40 func _physics_process(delta): var fwd_mps = transform.basis.xform_inv(linear_velocity).x - + steer_target = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right") steer_target *= STEER_LIMIT - + if Input.is_action_pressed("accelerate"): engine_force = engine_force_value else: engine_force = 0 - + if Input.is_action_pressed("reverse"): if (fwd_mps >= -1): engine_force = -engine_force_value @@ -26,7 +26,7 @@ func _physics_process(delta): brake = 1 else: brake = 0.0 - + if steer_target < steer_angle: steer_angle -= STEER_SPEED * delta if steer_target > steer_angle: @@ -35,5 +35,5 @@ func _physics_process(delta): steer_angle += STEER_SPEED * delta if steer_target < steer_angle: steer_angle = steer_target - + steering = steer_angle diff --git a/README.md b/README.md index f43c7be5..4d791453 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/audio/device_changer/Changer.gd b/audio/device_changer/Changer.gd index df44db61..86f0838b 100644 --- a/audio/device_changer/Changer.gd +++ b/audio/device_changer/Changer.gd @@ -6,7 +6,7 @@ onready var itemList = get_node("ItemList") func _ready(): for item in AudioServer.get_device_list(): itemList.add_item(item) - + var device = AudioServer.get_device() for i in range(itemList.get_item_count()): if device == itemList.get_item_text(i): @@ -16,14 +16,14 @@ func _ready(): func _process(_delta): var speakerMode = "Stereo" - + if AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_31: speakerMode = "Surround 3.1" elif AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_51: speakerMode = "Surround 5.1" elif AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_71: speakerMode = "Surround 7.1" - + $DeviceInfo.text = "Current Device: " + AudioServer.get_device() + "\n" $DeviceInfo.text += "Speaker Mode: " + speakerMode diff --git a/audio/device_changer/project.godot b/audio/device_changer/project.godot index 138187cc..23cccb06 100644 --- a/audio/device_changer/project.godot +++ b/audio/device_changer/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/audio/generator/generator_demo.gd b/audio/generator/generator_demo.gd index 68bb29ba..f7239b75 100644 --- a/audio/generator/generator_demo.gd +++ b/audio/generator/generator_demo.gd @@ -8,7 +8,7 @@ var playback: AudioStreamPlayback = null # Actual playback stream, assigned in _ func _fill_buffer(): var increment = pulse_hz / sample_hz - + var to_fill = playback.get_frames_available() while (to_fill > 0): playback.push_frame(Vector2.ONE * sin(phase * TAU)) # Audio frames are stereo. diff --git a/audio/generator/project.godot b/audio/generator/project.godot index 977721d2..04ab0935 100644 --- a/audio/generator/project.godot +++ b/audio/generator/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/audio/mic_record/project.godot b/audio/mic_record/project.godot index a104f991..e5965de4 100644 --- a/audio/mic_record/project.godot +++ b/audio/mic_record/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/audio/spectrum/project.godot b/audio/spectrum/project.godot index 2d3c624e..1fd1f32f 100644 --- a/audio/spectrum/project.godot +++ b/audio/spectrum/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/audio/spectrum/show_spectrum.gd b/audio/spectrum/show_spectrum.gd index 7bc4b6c6..91d20567 100644 --- a/audio/spectrum/show_spectrum.gd +++ b/audio/spectrum/show_spectrum.gd @@ -14,7 +14,7 @@ func _draw(): #warning-ignore:integer_division var w = WIDTH / VU_COUNT var prev_hz = 0 - for i in range(1, VU_COUNT+1): + for i in range(1, VU_COUNT+1): var hz = i * FREQ_MAX / VU_COUNT; var magnitude: float = spectrum.get_magnitude_for_frequency_range(prev_hz, hz).length() var energy = clamp((MIN_DB + linear2db(magnitude)) / MIN_DB, 0, 1) diff --git a/file_format.sh b/file_format.sh new file mode 100644 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/project.godot b/gui/drag_and_drop/project.godot index a8c2b7ce..8b9056f2 100644 --- a/gui/drag_and_drop/project.godot +++ b/gui/drag_and_drop/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/gui/input_mapping/project.godot b/gui/input_mapping/project.godot index 80709800..734e6017 100644 --- a/gui/input_mapping/project.godot +++ b/gui/input_mapping/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/gui/rich_text_bbcode/SIL Open Font License.txt b/gui/rich_text_bbcode/SIL Open Font License.txt index 99deab69..7d4991ff 100644 --- a/gui/rich_text_bbcode/SIL Open Font License.txt +++ b/gui/rich_text_bbcode/SIL Open Font License.txt @@ -152,4 +152,4 @@ TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/gui/rich_text_bbcode/project.godot b/gui/rich_text_bbcode/project.godot index bbb331cf..310bbf77 100644 --- a/gui/rich_text_bbcode/project.godot +++ b/gui/rich_text_bbcode/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/gui/translation/LICENSE.DroidSans.txt b/gui/translation/LICENSE.DroidSans.txt index 636f1e29..d3a2eaa8 100644 --- a/gui/translation/LICENSE.DroidSans.txt +++ b/gui/translation/LICENSE.DroidSans.txt @@ -3,9 +3,9 @@ Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/gui/translation/project.godot b/gui/translation/project.godot index bedf813a..da70a014 100644 --- a/gui/translation/project.godot +++ b/gui/translation/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/gui/translation/text.csv b/gui/translation/text.csv index 655d7eb1..0e6ca1ed 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/loading/autoload/project.godot b/loading/autoload/project.godot index 382b161f..9bd5f3f3 100644 --- a/loading/autoload/project.godot +++ b/loading/autoload/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/loading/background_load/background_load.gd b/loading/background_load/background_load.gd index 7eef0239..a07c013d 100644 --- a/loading/background_load/background_load.gd +++ b/loading/background_load/background_load.gd @@ -12,9 +12,9 @@ func _thread_load(path): var total = ril.get_stage_count() # Call deferred to configure max load steps. progress.call_deferred("set_max", total) - + var res = null - + while true: #iterate until we have a resource # Update progress bar, use call deferred, which routes to main thread. progress.call_deferred("set_value", ril.get_stage()) @@ -31,20 +31,20 @@ func _thread_load(path): # Not OK, there was an error. print("There was an error loading") break - + # Send whathever we did (or did not) get. call_deferred("_thread_done", res) func _thread_done(resource): assert(resource) - + # Always wait for threads to finish, this is required on Windows. thread.wait_to_finish() - + # Hide the progress bar. progress.hide() - + # Instantiate new scene. var new_scene = resource.instance() # Free current scene. @@ -54,7 +54,7 @@ func _thread_done(resource): get_tree().root.add_child(new_scene) # Set as current scene. get_tree().current_scene = new_scene - + progress.visible = false func load_scene(path): diff --git a/loading/background_load/project.godot b/loading/background_load/project.godot index b3454ad1..0817521b 100644 --- a/loading/background_load/project.godot +++ b/loading/background_load/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/loading/scene_changer/project.godot b/loading/scene_changer/project.godot index 7554e8c7..e9d2a6f9 100644 --- a/loading/scene_changer/project.godot +++ b/loading/scene_changer/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/loading/threads/project.godot b/loading/threads/project.godot index cf31ebf3..c84e335a 100644 --- a/loading/threads/project.godot +++ b/loading/threads/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/android_iap/project.godot b/misc/android_iap/project.godot index 48ec31b4..b829cbdc 100644 --- a/misc/android_iap/project.godot +++ b/misc/android_iap/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [android] diff --git a/misc/instancing/project.godot b/misc/instancing/project.godot index 28adf010..655b54c4 100644 --- a/misc/instancing/project.godot +++ b/misc/instancing/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/joypads/project.godot b/misc/joypads/project.godot index 082f7cb1..27df254c 100644 --- a/misc/joypads/project.godot +++ b/misc/joypads/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/multitouch_cubes/project.godot b/misc/multitouch_cubes/project.godot index c9b8312d..5a0bc2aa 100644 --- a/misc/multitouch_cubes/project.godot +++ b/misc/multitouch_cubes/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/multitouch_view/project.godot b/misc/multitouch_view/project.godot index 71e99ab5..789fc438 100644 --- a/misc/multitouch_view/project.godot +++ b/misc/multitouch_view/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader index f71fe272..99575d14 100644 --- a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader +++ b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader @@ -6,7 +6,7 @@ uniform float max_value = 1; void fragment() { // Get the color. vec4 color = texture(TEXTURE, UV); - + // Compare the value. float gray = color.x; if (gray < min_value) { @@ -14,7 +14,7 @@ void fragment() { } else if (gray > max_value) { color = vec4(1, 1, 1, 1); } - + // Write back the color. COLOR = color; } diff --git a/misc/opensimplexnoise/project.godot b/misc/opensimplexnoise/project.godot index e158a1cb..bc400683 100644 --- a/misc/opensimplexnoise/project.godot +++ b/misc/opensimplexnoise/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/pause/project.godot b/misc/pause/project.godot index aab8c08d..639b3d08 100644 --- a/misc/pause/project.godot +++ b/misc/pause/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/regex/project.godot b/misc/regex/project.godot index a36068d3..a5157274 100644 --- a/misc/regex/project.godot +++ b/misc/regex/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/sensors/main.gd b/misc/sensors/main.gd index c3b19d0b..225c6942 100644 --- a/misc/sensors/main.gd +++ b/misc/sensors/main.gd @@ -1,11 +1,11 @@ extends Node -# Below are a number of helper functions that show how you can use the raw sensor data to determine the orientation +# Below are a number of helper functions that show how you can use the raw sensor data to determine the orientation # of your phone/device. The cheapest phones only have an accelerometer only the most expensive phones have all three. # Note that none of this logic filters data. Filters introduce lag but also provide stability. There are plenty # of examples on the internet on how to implement these. I wanted to keep this straight forward. -# We draw a few arrow objects to visualize the vectors and two cubes to show two implementation for orientating +# We draw a few arrow objects to visualize the vectors and two cubes to show two implementation for orientating # these cubes to our phones orientation. # This is a 3D example however reading the phones orientation is also invaluable for 2D @@ -13,52 +13,52 @@ extends Node # care about the rotation around this axis. func get_basis_for_arrow(p_vector): var rotate = Basis() - + # as our arrow points up, Y = our direction vector rotate.y = p_vector.normalized() - + # get an arbitrary vector we can use to calculate our other two vectors var v = Vector3(1.0, 0.0, 0.0) if abs(v.dot(rotate.y)) > 0.9: v = Vector3(0.0, 1.0, 0.0) - + # use our vector to get a vector perpendicular to our two vectors rotate.x = rotate.y.cross(v).normalized() - + # and the cross product again gives us our final vector perpendicular to our previous two vectors rotate.z = rotate.x.cross(rotate.y).normalized() - + return rotate # This function combines the magnetometer reading with the gravity vector to get a vector that points due north func calc_north(p_grav, p_mag): # Always use normalized vectors! p_grav = p_grav.normalized() - + # Calculate east (or is it west) by getting our cross product. # The cross product of two normalized vectors returns a vector that # is perpendicular to our two vectors var east = p_grav.cross(p_mag.normalized()).normalized() - + # Cross again to get our horizon aligned north return east.cross(p_grav).normalized() # This function creates an orientation matrix using the magnetometer and gravity vector as inputs. func orientate_by_mag_and_grav(p_mag, p_grav): var rotate = Basis() - + # as always, normalize! p_mag = p_mag.normalized() - + # gravity points down, so - gravity points up! rotate.y = -p_grav.normalized() - + # Cross products with our magnetic north gives an aligned east (or west, I always forget) rotate.x = rotate.y.cross(p_mag) - + # And cross product again and we get our aligned north completing our matrix rotate.z = rotate.x.cross(rotate.y) - + return rotate # This function takes our gyro input and update an orientation matrix accordingly @@ -66,28 +66,28 @@ func orientate_by_mag_and_grav(p_mag, p_grav): # rotational velocity. This is why we multiply our values with delta. func rotate_by_gyro(p_gyro, p_basis, p_delta): var rotate = Basis() - + rotate = rotate.rotated(p_basis.x, -p_gyro.x * p_delta) rotate = rotate.rotated(p_basis.y, -p_gyro.y * p_delta) rotate = rotate.rotated(p_basis.z, -p_gyro.z * p_delta) - + return rotate * p_basis -# This function corrects the drift in our matrix by our gravity vector +# This function corrects the drift in our matrix by our gravity vector func drift_correction(p_basis, p_grav): # as always, make sure our vector is normalized but also invert as our gravity points down var real_up = -p_grav.normalized() - + # start by calculating the dot product, this gives us the cosine angle between our two vectors var dot = p_basis.y.dot(real_up) - + # if our dot is 1.0 we're good if dot < 1.0: # the cross between our two vectors gives us a vector perpendicular to our two vectors var axis = p_basis.y.cross(real_up).normalized() var correction = Basis(axis, acos(dot)) p_basis = correction * p_basis - + return p_basis func _process(delta): @@ -96,12 +96,12 @@ func _process(delta): var grav = Input.get_gravity() var mag = Input.get_magnetometer() var gyro = Input.get_gyroscope() - + # Show our base values get_node("Control/Accelerometer").text = 'Accelerometer: ' + str(acc) + ', gravity: ' + str(grav) get_node("Control/Magnetometer").text = 'Magnetometer: ' + str(mag) get_node("Control/Gyroscope").text = 'Gyroscope: ' + str(gyro) - + # Check if we have all needed data if grav.length() < 0.1: if acc.length() < 0.1: @@ -110,31 +110,31 @@ func _process(delta): else: # The gravity vector is calculated by the OS by combining the other sensor inputs. # If we don't have a gravity vector, from now on, use accelerometer... - grav = acc - + grav = acc + if mag.length() < 0.1: mag = Vector3(1.0, 0.0, 0.0) - + # Update our arrow showing gravity get_node("Arrows/AccelerometerArrow").transform.basis = get_basis_for_arrow(grav) - + # Update our arrow showing our magnetometer # Note that in absense of other strong magnetic forces this will point to magnetic north, which is not horizontal thanks to the earth being, uhm, round get_node("Arrows/MagnetoArrow").transform.basis = get_basis_for_arrow(mag) - + # Calculate our north vector and show that var north = calc_north(grav,mag) get_node("Arrows/NorthArrow").transform.basis = get_basis_for_arrow(north) - + # Combine our magnetometer and gravity vector to position our box. This will be fairly accurate # but our magnetometer can be easily influenced by magnets. Cheaper phones often don't have gyros # so it is a good backup. var mag_and_grav = get_node("Boxes/MagAndGrav") mag_and_grav.transform.basis = orientate_by_mag_and_grav(mag, grav).orthonormalized() - + # Using our gyro and do a drift correction using our gravity vector gives the best result var gyro_and_grav = get_node("Boxes/GyroAndGrav") var new_basis = rotate_by_gyro(gyro, gyro_and_grav.transform.basis, delta).orthonormalized() gyro_and_grav.transform.basis = drift_correction(new_basis, grav) - - + + diff --git a/misc/sensors/project.godot b/misc/sensors/project.godot index a8876824..ebf15e4a 100644 --- a/misc/sensors/project.godot +++ b/misc/sensors/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/tween/project.godot b/misc/tween/project.godot index d7df53bc..074416b1 100644 --- a/misc/tween/project.godot +++ b/misc/tween/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/misc/window_management/observer/observer.gd b/misc/window_management/observer/observer.gd index c9862731..7f0e4ab7 100644 --- a/misc/window_management/observer/observer.gd +++ b/misc/window_management/observer/observer.gd @@ -11,23 +11,23 @@ onready var camera = $Camera func _process(delta): if state != STATE_GRAB: return - + var x_movement = Input.get_action_strength("move_right") - Input.get_action_strength("move_left") var z_movement = Input.get_action_strength("move_backwards") - Input.get_action_strength("move_forward") var dir = direction(Vector3(x_movement, 0, z_movement)) transform.origin += dir * 10 * delta - + var d = delta * 0.1 # Scale the input, easiest to do by scaling the delta. rotate(Vector3.UP, d * r_pos.x) # Yaw camera.transform = camera.transform.rotated(Vector3.RIGHT, d * r_pos.y) # Pitch - + r_pos = Vector2.ZERO # We've dealt with all the input, so set it to zero. func _input(event): if (event is InputEventMouseMotion): r_pos = -event.relative - + if (event.is_action("ui_cancel") and event.is_pressed() and !event.is_echo()): if (state == STATE_GRAB): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) diff --git a/misc/window_management/project.godot b/misc/window_management/project.godot index 74370281..04041eec 100644 --- a/misc/window_management/project.godot +++ b/misc/window_management/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/mono/dodge_the_creeps/project.godot b/mono/dodge_the_creeps/project.godot index 87c4516e..f49a878a 100644 --- a/mono/dodge_the_creeps/project.godot +++ b/mono/dodge_the_creeps/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/mono/pong/project.godot b/mono/pong/project.godot index 50401a10..9bfecfd2 100644 --- a/mono/pong/project.godot +++ b/mono/pong/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/multiplayer_bomber/project.godot b/networking/multiplayer_bomber/project.godot index 65317ce5..dbeebf97 100644 --- a/networking/multiplayer_bomber/project.godot +++ b/networking/multiplayer_bomber/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/multiplayer_pong/project.godot b/networking/multiplayer_pong/project.godot index 8022064f..45f4c631 100644 --- a/networking/multiplayer_pong/project.godot +++ b/networking/multiplayer_pong/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/multiplayer_pong/scripts/ball.gd b/networking/multiplayer_pong/scripts/ball.gd index 1011968f..2dcaf696 100644 --- a/networking/multiplayer_pong/scripts/ball.gd +++ b/networking/multiplayer_pong/scripts/ball.gd @@ -14,13 +14,13 @@ func _process(delta): # even if it's sightly out of sync between them, # so each player sees the motion as smooth and not jerky. if not stopped: - translate(_speed * delta * direction) - + translate(_speed * delta * direction) + # Check screen bounds to make ball bounce. var ball_pos = position if (ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > _screen_size.y and direction.y > 0): direction.y = -direction.y - + if is_network_master(): # Only master will decide when the ball is out in the left side (it's own side). # This makes the game playable even if latency is high and ball is going fast. @@ -43,7 +43,7 @@ sync func bounce(left, random): direction.x = abs(direction.x) else: direction.x = -abs(direction.x) - + _speed *= 1.1 direction.y = random * 2.0 - 1 direction = direction.normalized() diff --git a/networking/multiplayer_pong/scripts/lobby.gd b/networking/multiplayer_pong/scripts/lobby.gd index aebdd88c..3f1edd89 100644 --- a/networking/multiplayer_pong/scripts/lobby.gd +++ b/networking/multiplayer_pong/scripts/lobby.gd @@ -24,7 +24,7 @@ func _player_connected(_id): var pong = load("res://pong.tscn").instance() # Connect deferred so we can safely erase it from the callback. pong.connect("game_finished", self, "_end_game", [], CONNECT_DEFERRED) - + get_tree().get_root().add_child(pong) hide() @@ -44,9 +44,9 @@ func _connected_ok(): # Callback from SceneTree, only for clients (not server). func _connected_fail(): _set_status("Couldn't connect", false) - + get_tree().set_network_peer(null) # Remove peer. - + host_button.set_disabled(false) join_button.set_disabled(false) @@ -61,11 +61,11 @@ func _end_game(with_error = ""): # Erase immediately, otherwise network might show errors (this is why we connected deferred above). get_node("/root/Pong").free() show() - + get_tree().set_network_peer(null) # Remove peer. host_button.set_disabled(false) join_button.set_disabled(false) - + _set_status(with_error, false) @@ -87,7 +87,7 @@ func _on_host_pressed(): # Is another server running? _set_status("Can't host, address in use.",false) return - + get_tree().set_network_peer(host) host_button.set_disabled(true) join_button.set_disabled(true) @@ -99,10 +99,10 @@ func _on_join_pressed(): if not ip.is_valid_ip_address(): _set_status("IP address is invalid", false) return - + var host = NetworkedMultiplayerENet.new() host.set_compression_mode(NetworkedMultiplayerENet.COMPRESS_RANGE_CODER) host.create_client(ip, DEFAULT_PORT) get_tree().set_network_peer(host) - + _set_status("Connecting...", true) diff --git a/networking/multiplayer_pong/scripts/paddle.gd b/networking/multiplayer_pong/scripts/paddle.gd index b941fd29..1b8e8a10 100644 --- a/networking/multiplayer_pong/scripts/paddle.gd +++ b/networking/multiplayer_pong/scripts/paddle.gd @@ -13,21 +13,21 @@ func _process(delta): # Is the master of the paddle. if is_network_master(): motion = Input.get_action_strength("move_down") - Input.get_action_strength("move_up") - + if not you_hidden and motion != 0: _hide_you_label() - + motion *= MOTION_SPEED - + # Using unreliable to make sure position is updated as fast # as possible, even if one of the calls is dropped. rpc_unreliable("set_pos_and_motion", position, motion) else: if not you_hidden: _hide_you_label() - + translate(Vector2(0, motion * delta)) - + # Set screen limits. position.y = clamp(position.y, 16, _screen_size_y - 16) diff --git a/networking/multiplayer_pong/scripts/pong.gd b/networking/multiplayer_pong/scripts/pong.gd index f0805ca4..14283749 100644 --- a/networking/multiplayer_pong/scripts/pong.gd +++ b/networking/multiplayer_pong/scripts/pong.gd @@ -18,7 +18,7 @@ func _ready(): # while all nodes in clients inherit from puppet. # set_network_master is tree-recursive by default. if get_tree().is_network_server(): - # For the server, give control of player 2 to the other peer. + # For the server, give control of player 2 to the other peer. player2.set_network_master(get_tree().get_network_connected_peers()[0]) else: # For the client, give control of player 2 to itself. @@ -33,7 +33,7 @@ sync func update_score(add_to_left): else: score_right += 1 score_right_node.set_text(str(score_right)) - + var game_ended = false if score_left == SCORE_TO_WIN: winner_left.show() @@ -41,7 +41,7 @@ sync func update_score(add_to_left): elif score_right == SCORE_TO_WIN: winner_right.show() game_ended = true - + if game_ended: $ExitGame.show() $Ball.rpc("stop") diff --git a/networking/webrtc_minimal/Signaling.gd b/networking/webrtc_minimal/Signaling.gd index af1fb756..d4196966 100644 --- a/networking/webrtc_minimal/Signaling.gd +++ b/networking/webrtc_minimal/Signaling.gd @@ -25,4 +25,4 @@ func send_session(path, type, sdp): func send_candidate(path, mid, index, sdp): var other = _find_other(path) assert(other != "") - get_node(other).peer.add_ice_candidate(mid, index, sdp) \ No newline at end of file + get_node(other).peer.add_ice_candidate(mid, index, sdp) diff --git a/networking/webrtc_minimal/chat.gd b/networking/webrtc_minimal/chat.gd index 39678c3c..1eae9294 100644 --- a/networking/webrtc_minimal/chat.gd +++ b/networking/webrtc_minimal/chat.gd @@ -32,4 +32,4 @@ func _process(delta): print(get_path(), " received: ", channel.get_packet().get_string_from_utf8()) func send_message(message): - channel.put_packet(message.to_utf8()) \ No newline at end of file + channel.put_packet(message.to_utf8()) diff --git a/networking/webrtc_minimal/project.godot b/networking/webrtc_minimal/project.godot index 37cb0254..619d63bc 100644 --- a/networking/webrtc_minimal/project.godot +++ b/networking/webrtc_minimal/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/webrtc_signaling/client/multiplayer_client.gd b/networking/webrtc_signaling/client/multiplayer_client.gd index 4902fb69..1967c810 100644 --- a/networking/webrtc_signaling/client/multiplayer_client.gd +++ b/networking/webrtc_signaling/client/multiplayer_client.gd @@ -83,4 +83,4 @@ func answer_received(id : int, answer : String): func candidate_received(id : int, mid : String, index : int, sdp : String): if rtc_mp.has_peer(id): - rtc_mp.get_peer(id).connection.add_ice_candidate(mid, index, sdp) \ No newline at end of file + rtc_mp.get_peer(id).connection.add_ice_candidate(mid, index, sdp) diff --git a/networking/webrtc_signaling/client/ws_webrtc_client.gd b/networking/webrtc_signaling/client/ws_webrtc_client.gd index 8470c0f6..db6068f1 100644 --- a/networking/webrtc_signaling/client/ws_webrtc_client.gd +++ b/networking/webrtc_signaling/client/ws_webrtc_client.gd @@ -113,4 +113,4 @@ func _send_msg(type : String, id : int, data : String) -> int: func _process(delta): var status : int = client.get_connection_status() if status == WebSocketClient.CONNECTION_CONNECTING or status == WebSocketClient.CONNECTION_CONNECTED: - client.poll() \ No newline at end of file + client.poll() diff --git a/networking/webrtc_signaling/project.godot b/networking/webrtc_signaling/project.godot index 5db1f359..10943b8d 100644 --- a/networking/webrtc_signaling/project.godot +++ b/networking/webrtc_signaling/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/webrtc_signaling/server/ws_webrtc_server.gd b/networking/webrtc_signaling/server/ws_webrtc_server.gd index ed6586db..856fac24 100644 --- a/networking/webrtc_signaling/server/ws_webrtc_server.gd +++ b/networking/webrtc_signaling/server/ws_webrtc_server.gd @@ -192,4 +192,4 @@ func _parse_msg(id : int) -> bool: elif type.begins_with("C: "): # Client is making an answer server.get_peer(dest_id).put_packet(("C: %d\n%s" % [id, req[1]]).to_utf8()) - return true \ No newline at end of file + return true diff --git a/networking/webrtc_signaling/server_node/.eslintrc.json b/networking/webrtc_signaling/server_node/.eslintrc.json index a22aae1c..d6ea8d03 100644 --- a/networking/webrtc_signaling/server_node/.eslintrc.json +++ b/networking/webrtc_signaling/server_node/.eslintrc.json @@ -23,16 +23,10 @@ "arrow-spacing": "error", "block-scoped-var": "error", "block-spacing": "error", - "brace-style": [ - "error", - "1tbs" - ], + "brace-style": ["error", "1tbs"], "callback-return": "error", "camelcase": "error", - "capitalized-comments": [ - "error", - "always" - ], + "capitalized-comments": ["error", "always"], "class-methods-use-this": "error", "comma-dangle": "error", "comma-spacing": [ @@ -44,10 +38,7 @@ ], "comma-style": "error", "complexity": "error", - "computed-property-spacing": [ - "error", - "never" - ], + "computed-property-spacing": ["error", "never"], "consistent-return": "error", "consistent-this": "error", "curly": "off", @@ -59,10 +50,7 @@ "func-call-spacing": "error", "func-name-matching": "error", "func-names": "error", - "func-style": [ - "error", - "declaration" - ], + "func-style": ["error", "declaration"], "function-paren-newline": "error", "generator-star-spacing": "error", "global-require": "error", @@ -72,10 +60,7 @@ "id-length": "off", "id-match": "error", "implicit-arrow-linebreak": "error", - "indent": [ - "error", - "tab" - ], + "indent": ["error", "tab"], "indent-legacy": "off", "init-declarations": "error", "jsx-quotes": "error", @@ -88,16 +73,10 @@ } ], "line-comment-position": "off", - "linebreak-style": [ - "error", - "unix" - ], + "linebreak-style": ["error", "unix"], "lines-around-comment": "error", "lines-around-directive": "error", - "lines-between-class-members": [ - "error", - "never" - ], + "lines-between-class-members": ["error", "never"], "max-classes-per-file": "off", "max-depth": "error", "max-len": [ @@ -113,10 +92,7 @@ "max-params": "error", "max-statements": "off", "max-statements-per-line": "error", - "multiline-comment-style": [ - "error", - "separate-lines" - ], + "multiline-comment-style": ["error", "separate-lines"], "new-cap": "error", "new-parens": "error", "newline-after-var": "off", @@ -131,7 +107,7 @@ "no-caller": "error", "no-catch-shadow": "error", "no-confusing-arrow": "error", - "no-console": "off", + "no-console": "off", "no-continue": "error", "no-div-regex": "error", "no-duplicate-imports": "error", @@ -148,10 +124,7 @@ "no-implicit-globals": "error", "no-implied-eval": "error", "no-inline-comments": "off", - "no-inner-declarations": [ - "error", - "functions" - ], + "no-inner-declarations": ["error", "functions"], "no-invalid-this": "error", "no-iterator": "error", "no-label-var": "error", @@ -229,18 +202,12 @@ "no-with": "error", "nonblock-statement-body-position": "error", "object-curly-newline": "error", - "object-curly-spacing": [ - "error", - "always" - ], + "object-curly-spacing": ["error", "always"], "object-property-newline": "error", "object-shorthand": "error", "one-var": "off", "one-var-declaration-per-line": "error", - "operator-assignment": [ - "error", - "always" - ], + "operator-assignment": ["error", "always"], "operator-linebreak": "error", "padded-blocks": "off", "padding-line-between-statements": "error", @@ -257,10 +224,7 @@ "prefer-template": "off", "quote-props": "off", "quotes": "error", - "radix": [ - "error", - "as-needed" - ], + "radix": ["error", "as-needed"], "require-atomic-updates": "error", "require-await": "error", "require-jsdoc": "off", @@ -274,10 +238,7 @@ "before": false } ], - "semi-style": [ - "error", - "last" - ], + "semi-style": ["error", "last"], "sort-imports": "error", "sort-keys": "error", "sort-vars": "error", @@ -286,33 +247,18 @@ "space-in-parens": "error", "space-infix-ops": "error", "space-unary-ops": "error", - "spaced-comment": [ - "error", - "always" - ], - "strict": [ - "error", - "never" - ], + "spaced-comment": ["error", "always"], + "strict": ["error", "never"], "switch-colon-spacing": "error", "symbol-description": "error", - "template-curly-spacing": [ - "error", - "never" - ], + "template-curly-spacing": ["error", "never"], "template-tag-spacing": "error", - "unicode-bom": [ - "error", - "never" - ], + "unicode-bom": ["error", "never"], "valid-jsdoc": "error", "vars-on-top": "error", "wrap-iife": "error", "wrap-regex": "error", "yield-star-spacing": "error", - "yoda": [ - "error", - "never" - ] + "yoda": ["error", "never"] } } diff --git a/networking/webrtc_signaling/server_node/package.json b/networking/webrtc_signaling/server_node/package.json index 7b5b7dc4..315ec212 100644 --- a/networking/webrtc_signaling/server_node/package.json +++ b/networking/webrtc_signaling/server_node/package.json @@ -1,17 +1,17 @@ { - "name": "signaling_server", - "version": "1.0.0", - "description": "", - "main": "server.js", - "dependencies": { - "ws": "^7.0.0" - }, - "devDependencies": { - "eslint": "^5.16.0" - }, - "scripts": { - "test": "eslint server.js && echo \"Lint OK\" && exit 0" - }, - "author": "Fabio Alessandrelli", - "license": "MIT" + "name": "signaling_server", + "version": "1.0.0", + "description": "", + "main": "server.js", + "dependencies": { + "ws": "^7.0.0" + }, + "devDependencies": { + "eslint": "^5.16.0" + }, + "scripts": { + "test": "eslint server.js && echo \"Lint OK\" && exit 0" + }, + "author": "Fabio Alessandrelli", + "license": "MIT" } diff --git a/networking/websocket_chat/client/client.tscn b/networking/websocket_chat/client/client.tscn index f20edaad..8fa517ab 100644 --- a/networking/websocket_chat/client/client.tscn +++ b/networking/websocket_chat/client/client.tscn @@ -15,21 +15,18 @@ __meta__ = { anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="VBoxContainer" type="VBoxContainer" parent="Panel"] anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="Connect" type="HBoxContainer" parent="Panel/VBoxContainer"] margin_right = 1024.0 margin_bottom = 24.0 __meta__ = { - } [node name="Host" type="LineEdit" parent="Panel/VBoxContainer/Connect"] @@ -39,7 +36,6 @@ size_flags_horizontal = 3 text = "ws://localhost:8000/test/" placeholder_text = "ws://my.server/path/" __meta__ = { - } [node name="Connect" type="Button" parent="Panel/VBoxContainer/Connect"] @@ -49,7 +45,6 @@ margin_bottom = 24.0 toggle_mode = true text = "Connect" __meta__ = { - } [node name="Settings" type="HBoxContainer" parent="Panel/VBoxContainer"] @@ -57,14 +52,12 @@ margin_top = 28.0 margin_right = 1024.0 margin_bottom = 52.0 __meta__ = { - } [node name="Mode" type="OptionButton" parent="Panel/VBoxContainer/Settings"] margin_right = 41.0 margin_bottom = 24.0 __meta__ = { - } [node name="Multiplayer" type="CheckBox" parent="Panel/VBoxContainer/Settings"] @@ -74,7 +67,6 @@ margin_bottom = 24.0 pressed = true text = "Multiplayer API" __meta__ = { - } [node name="Destination" type="OptionButton" parent="Panel/VBoxContainer/Settings"] @@ -82,7 +74,6 @@ margin_left = 175.0 margin_right = 216.0 margin_bottom = 24.0 __meta__ = { - } [node name="Send" type="HBoxContainer" parent="Panel/VBoxContainer"] @@ -90,7 +81,6 @@ margin_top = 56.0 margin_right = 1024.0 margin_bottom = 80.0 __meta__ = { - } [node name="LineEdit" type="LineEdit" parent="Panel/VBoxContainer/Send"] @@ -99,7 +89,6 @@ margin_bottom = 24.0 size_flags_horizontal = 3 placeholder_text = "Enter some text to send..." __meta__ = { - } [node name="Send" type="Button" parent="Panel/VBoxContainer/Send"] @@ -108,7 +97,6 @@ margin_right = 1024.0 margin_bottom = 24.0 text = "Send" __meta__ = { - } [node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"] @@ -117,13 +105,11 @@ margin_right = 1024.0 margin_bottom = 600.0 size_flags_vertical = 3 __meta__ = { - } [node name="Client" type="Node" parent="."] script = ExtResource( 2 ) __meta__ = { - } [connection signal="toggled" from="Panel/VBoxContainer/Connect/Connect" to="." method="_on_Connect_toggled"] [connection signal="item_selected" from="Panel/VBoxContainer/Settings/Mode" to="." method="_on_Mode_item_selected"] diff --git a/networking/websocket_chat/combo/combo.tscn b/networking/websocket_chat/combo/combo.tscn index 8940a854..093fd0cb 100644 --- a/networking/websocket_chat/combo/combo.tscn +++ b/networking/websocket_chat/combo/combo.tscn @@ -8,7 +8,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 1 __meta__ = { - } [node name="Box" type="HBoxContainer" parent="."] @@ -16,7 +15,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 custom_constants/separation = 20 __meta__ = { - } [node name="ServerControl" parent="Box" instance=ExtResource( 1 )] @@ -32,7 +30,6 @@ margin_right = 1024.0 margin_bottom = 600.0 size_flags_horizontal = 3 __meta__ = { - } [node name="Client" parent="Box/VBoxContainer" instance=ExtResource( 2 )] diff --git a/networking/websocket_chat/project.godot b/networking/websocket_chat/project.godot index 5a9ca2cf..833f4f41 100644 --- a/networking/websocket_chat/project.godot +++ b/networking/websocket_chat/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/websocket_chat/server/server.tscn b/networking/websocket_chat/server/server.tscn index 6c14493d..d7455e02 100644 --- a/networking/websocket_chat/server/server.tscn +++ b/networking/websocket_chat/server/server.tscn @@ -8,34 +8,29 @@ anchor_right = 1.0 anchor_bottom = 1.0 script = ExtResource( 1 ) __meta__ = { - } [node name="Server" type="Node" parent="."] script = ExtResource( 2 ) __meta__ = { - } [node name="Panel" type="Panel" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="VBoxContainer" type="VBoxContainer" parent="Panel"] anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"] margin_right = 1024.0 margin_bottom = 24.0 __meta__ = { - } [node name="Port" type="SpinBox" parent="Panel/VBoxContainer/HBoxContainer"] @@ -45,7 +40,6 @@ min_value = 1.0 max_value = 65535.0 value = 8000.0 __meta__ = { - } [node name="Listen" type="Button" parent="Panel/VBoxContainer/HBoxContainer"] @@ -55,7 +49,6 @@ margin_bottom = 24.0 toggle_mode = true text = "Listen" __meta__ = { - } [node name="HBoxContainer2" type="HBoxContainer" parent="Panel/VBoxContainer"] @@ -63,14 +56,12 @@ margin_top = 28.0 margin_right = 1024.0 margin_bottom = 52.0 __meta__ = { - } [node name="WriteMode" type="OptionButton" parent="Panel/VBoxContainer/HBoxContainer2"] margin_right = 41.0 margin_bottom = 24.0 __meta__ = { - } [node name="MPAPI" type="CheckBox" parent="Panel/VBoxContainer/HBoxContainer2"] @@ -80,7 +71,6 @@ margin_bottom = 24.0 pressed = true text = "Multiplayer API" __meta__ = { - } [node name="Destination" type="OptionButton" parent="Panel/VBoxContainer/HBoxContainer2"] @@ -88,7 +78,6 @@ margin_left = 175.0 margin_right = 216.0 margin_bottom = 24.0 __meta__ = { - } [node name="HBoxContainer3" type="HBoxContainer" parent="Panel/VBoxContainer"] @@ -96,7 +85,6 @@ margin_top = 56.0 margin_right = 1024.0 margin_bottom = 80.0 __meta__ = { - } [node name="LineEdit" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer3"] @@ -104,7 +92,6 @@ margin_right = 977.0 margin_bottom = 24.0 size_flags_horizontal = 3 __meta__ = { - } [node name="Send" type="Button" parent="Panel/VBoxContainer/HBoxContainer3"] @@ -113,7 +100,6 @@ margin_right = 1024.0 margin_bottom = 24.0 text = "Send" __meta__ = { - } [node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"] @@ -122,7 +108,6 @@ margin_right = 1024.0 margin_bottom = 600.0 size_flags_vertical = 3 __meta__ = { - } [connection signal="toggled" from="Panel/VBoxContainer/HBoxContainer/Listen" to="." method="_on_Listen_toggled"] [connection signal="item_selected" from="Panel/VBoxContainer/HBoxContainer2/WriteMode" to="." method="_on_WriteMode_item_selected"] diff --git a/networking/websocket_minimal/Main.tscn b/networking/websocket_minimal/Main.tscn index 02c63789..4d73794b 100644 --- a/networking/websocket_minimal/Main.tscn +++ b/networking/websocket_minimal/Main.tscn @@ -5,17 +5,14 @@ [node name="Main" type="Node"] __meta__ = { - } [node name="Server" type="Node" parent="."] script = ExtResource( 1 ) __meta__ = { - } [node name="Client" type="Node" parent="."] script = ExtResource( 2 ) __meta__ = { - } diff --git a/networking/websocket_minimal/project.godot b/networking/websocket_minimal/project.godot index 8afcdf7f..72301285 100644 --- a/networking/websocket_minimal/project.godot +++ b/networking/websocket_minimal/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/websocket_multiplayer/default_env.tres b/networking/websocket_multiplayer/default_env.tres index b9063186..e323c23e 100644 --- a/networking/websocket_multiplayer/default_env.tres +++ b/networking/websocket_multiplayer/default_env.tres @@ -9,12 +9,10 @@ ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) ground_curve = 0.01 sun_energy = 16.0 __meta__ = { - } [resource] background_mode = 2 background_sky = SubResource( 1 ) __meta__ = { - } diff --git a/networking/websocket_multiplayer/project.godot b/networking/websocket_multiplayer/project.godot index e3900027..7b7245d0 100644 --- a/networking/websocket_multiplayer/project.godot +++ b/networking/websocket_multiplayer/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/networking/websocket_multiplayer/scene/game.tscn b/networking/websocket_multiplayer/scene/game.tscn index 7fddf3cc..3010cc5f 100644 --- a/networking/websocket_multiplayer/scene/game.tscn +++ b/networking/websocket_multiplayer/scene/game.tscn @@ -17,7 +17,6 @@ __meta__ = { anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="RichTextLabel" type="RichTextLabel" parent="HBoxContainer"] @@ -25,7 +24,6 @@ margin_right = 510.0 margin_bottom = 600.0 size_flags_horizontal = 3 __meta__ = { - } [node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] @@ -34,7 +32,6 @@ margin_right = 1024.0 margin_bottom = 600.0 size_flags_horizontal = 3 __meta__ = { - } [node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"] @@ -42,7 +39,6 @@ margin_right = 510.0 margin_bottom = 14.0 text = "Players:" __meta__ = { - } [node name="ItemList" type="ItemList" parent="HBoxContainer/VBoxContainer"] @@ -53,7 +49,6 @@ size_flags_horizontal = 3 size_flags_vertical = 3 same_column_width = true __meta__ = { - } [node name="Action" type="Button" parent="HBoxContainer/VBoxContainer"] @@ -63,6 +58,5 @@ margin_bottom = 600.0 disabled = true text = "Do Action!" __meta__ = { - } [connection signal="pressed" from="HBoxContainer/VBoxContainer/Action" to="." method="_on_Action_pressed"] diff --git a/networking/websocket_multiplayer/scene/main.tscn b/networking/websocket_multiplayer/scene/main.tscn index c307df58..f2fbbe0f 100644 --- a/networking/websocket_multiplayer/scene/main.tscn +++ b/networking/websocket_multiplayer/scene/main.tscn @@ -8,14 +8,12 @@ anchor_right = 1.0 anchor_bottom = 1.0 script = ExtResource( 1 ) __meta__ = { - } [node name="Panel" type="Panel" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 __meta__ = { - } [node name="VBoxContainer" type="VBoxContainer" parent="Panel"] @@ -26,14 +24,12 @@ margin_top = 20.0 margin_right = -20.0 margin_bottom = -20.0 __meta__ = { - } [node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"] margin_right = 984.0 margin_bottom = 24.0 __meta__ = { - } [node name="Label" type="Label" parent="Panel/VBoxContainer/HBoxContainer"] @@ -43,7 +39,6 @@ margin_bottom = 19.0 size_flags_horizontal = 3 text = "Name" __meta__ = { - } [node name="NameEdit" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer"] @@ -54,7 +49,6 @@ size_flags_horizontal = 3 size_flags_stretch_ratio = 2.0 text = "A Godot User" __meta__ = { - } [node name="HBoxContainer2" type="HBoxContainer" parent="Panel/VBoxContainer"] @@ -62,7 +56,6 @@ margin_top = 28.0 margin_right = 984.0 margin_bottom = 52.0 __meta__ = { - } [node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer/HBoxContainer2"] @@ -70,7 +63,6 @@ margin_right = 326.0 margin_bottom = 24.0 size_flags_horizontal = 3 __meta__ = { - } [node name="Host" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"] @@ -78,7 +70,6 @@ margin_right = 42.0 margin_bottom = 24.0 text = "Host" __meta__ = { - } [node name="Control" type="Control" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"] @@ -87,7 +78,6 @@ margin_right = 241.0 margin_bottom = 24.0 size_flags_horizontal = 3 __meta__ = { - } [node name="Connect" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"] @@ -96,7 +86,6 @@ margin_right = 326.0 margin_bottom = 24.0 text = "Connect to" __meta__ = { - } [node name="Disconnect" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"] @@ -106,7 +95,6 @@ margin_right = 152.0 margin_bottom = 24.0 text = "Disconnect" __meta__ = { - } [node name="Hostname" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer2"] @@ -118,7 +106,6 @@ size_flags_stretch_ratio = 2.0 text = "localhost" placeholder_text = "localhost" __meta__ = { - } [node name="Control" type="Control" parent="Panel/VBoxContainer"] @@ -127,7 +114,6 @@ margin_right = 984.0 margin_bottom = 76.0 rect_min_size = Vector2( 0, 20 ) __meta__ = { - } [node name="Game" parent="Panel/VBoxContainer" instance=ExtResource( 2 )] @@ -148,7 +134,6 @@ margin_right = 200.0 margin_bottom = 100.0 dialog_text = "Connection closed" __meta__ = { - } [connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Host" to="." method="_on_Host_pressed"] [connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Connect" to="." method="_on_Connect_pressed"] diff --git a/plugins/material_creator/material_creator.gd b/plugins/material_creator/material_creator.gd index 173b387b..0f6c99fa 100644 --- a/plugins/material_creator/material_creator.gd +++ b/plugins/material_creator/material_creator.gd @@ -29,7 +29,7 @@ func apply_pressed(): var selected_nodes = editor_selection.get_selected_nodes() if selected_nodes.size() == 0: printerr("Material Creator: Can't apply the material, because there are no nodes selected!") - + var material = _silly_resource_from_values().make_material() # Go through the selected nodes and see if they have the 'set_surface_material' # function (which only MeshInstance has by default). If they do, then set the material @@ -46,23 +46,23 @@ func save_file_selected(path): file.open(path, File.WRITE) file.store_string(silly_resource.make_json()) file.close() - + return true func load_file_selected(path): var file = File.new() var SpatialMaterial_Silly = null - + # Make a new silly resource (which in this case actually is a node) # and initialize it var silly_resource = silly_material_resource.new() silly_resource.init() - + # If the file exists, then open it if file.file_exists(path): file.open(path, File.READ) - + # Get the JSON string and convert it into a silly material. var json_dict_as_string = file.get_line() if json_dict_as_string != null: @@ -70,15 +70,15 @@ func load_file_selected(path): else: file.close() return false - + get_node("VBoxContainer/AlbedoColorPicker").color = silly_resource.albedo_color get_node("VBoxContainer/MetallicSlider").value = silly_resource.metallic_strength get_node("VBoxContainer/RoughnessSlider").value = silly_resource.roughness_strength - + # Close the file and return true (success!) file.close() return true - + #else: If the file does not exist, then return false (failure) return false @@ -91,10 +91,10 @@ func _silly_resource_from_values(): # Make a new silly resource (which in this case actually is a node) and initialize it var silly_resource = silly_material_resource.new() silly_resource.init() - + # Assign the values silly_resource.albedo_color = color silly_resource.metallic_strength = metallic silly_resource.roughness_strength = roughness - + return silly_resource diff --git a/plugins/material_creator/material_resource.gd b/plugins/material_creator/material_resource.gd index 26010514..6319d243 100644 --- a/plugins/material_creator/material_resource.gd +++ b/plugins/material_creator/material_resource.gd @@ -21,15 +21,15 @@ func init(): # into the JSON format func make_json(): var json_dict = {} - + json_dict["albedo_color"] = {} json_dict["albedo_color"]["r"] = albedo_color.r json_dict["albedo_color"]["g"] = albedo_color.g json_dict["albedo_color"]["b"] = albedo_color.b - + json_dict["metallic_strength"] = metallic_strength json_dict["roughness_strength"] = roughness_strength - + return to_json(json_dict) @@ -37,11 +37,11 @@ func make_json(): # fill in our data. func from_json(json_dict_as_string): var json_dict = parse_json(json_dict_as_string) - + albedo_color.r = json_dict["albedo_color"]["r"] albedo_color.g = json_dict["albedo_color"]["g"] albedo_color.b = json_dict["albedo_color"]["b"] - + metallic_strength = json_dict["metallic_strength"] roughness_strength = json_dict["roughness_strength"] @@ -49,9 +49,9 @@ func from_json(json_dict_as_string): # Make a SpatialMaterial using our variables. func make_material(): var mat = SpatialMaterial.new() - + mat.albedo_color = albedo_color mat.metallic = metallic_strength mat.roughness = roughness_strength - + return mat diff --git a/viewport/2d_in_3d/pong.gd b/viewport/2d_in_3d/pong.gd index 0f16b370..41a4a45a 100644 --- a/viewport/2d_in_3d/pong.gd +++ b/viewport/2d_in_3d/pong.gd @@ -19,44 +19,44 @@ func _process(delta): var ball_pos = get_node("ball").get_position() var left_rect = Rect2(get_node("left").get_position() - pad_size * 0.5, pad_size) var right_rect = Rect2(get_node("right").get_position() - 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_position(ball_pos) - + # Move left pad. var left_pos = get_node("left").get_position() - + 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_position(left_pos) - + # Move right pad. var right_pos = get_node("right").get_position() 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_position(right_pos) diff --git a/viewport/2d_in_3d/project.godot b/viewport/2d_in_3d/project.godot index f9d990fc..55767fb6 100644 --- a/viewport/2d_in_3d/project.godot +++ b/viewport/2d_in_3d/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/viewport/3d_in_2d/project.godot b/viewport/3d_in_2d/project.godot index 37c13f89..a823f234 100644 --- a/viewport/3d_in_2d/project.godot +++ b/viewport/3d_in_2d/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/viewport/dynamic_split_screen/CameraController.gd b/viewport/dynamic_split_screen/CameraController.gd index 3f9e0994..1cdc6799 100644 --- a/viewport/dynamic_split_screen/CameraController.gd +++ b/viewport/dynamic_split_screen/CameraController.gd @@ -2,20 +2,20 @@ extends Spatial # Handle the motion of both players' camera as well as communication with the # SplitScreen shader to achieve the dynamic split screen effet -# -# Cameras are place on the segment joining the two players, either in the middle +# +# Cameras are place on the segment joining the two players, either in the middle # if players are close enough or at a fixed distance if they are not. -# In the first case, both cameras being at the same location, only the view of -# the first one is used for the entire screen thus allowing the players to play +# In the first case, both cameras being at the same location, only the view of +# the first one is used for the entire screen thus allowing the players to play # on a unsplit screen. # In the second case, the screen is split in two with a line perpendicular to the # segement joining the two players. -# +# # The points of customization are: # max_separation: the distance between players at which the view starts to split # split_line_thickness: the thickness of the split line in pixels # split_line_color: color of the split line -# adaptive_split_line_thickness: if true, the split line thickness will vary +# adaptive_split_line_thickness: if true, the split line thickness will vary # depending on the distance between players. If false, the thickness will # be constant and equal to split_line_thickness @@ -34,9 +34,9 @@ onready var view: TextureRect = $'View' func _ready(): _on_size_changed() _update_splitscreen() - + get_viewport().connect("size_changed", self, "_on_size_changed") - + view.material.set_shader_param('viewport1', $Viewport1.get_texture()) view.material.set_shader_param('viewport2', $Viewport2.get_texture()) @@ -48,7 +48,7 @@ func _process(_delta): func _move_cameras(): var position_difference = _compute_position_difference_in_world() - + var distance = clamp(_compute_horizontal_length(position_difference), 0, max_separation) position_difference = position_difference.normalized() * distance @@ -64,7 +64,7 @@ func _update_splitscreen(): var screen_size = get_viewport().get_visible_rect().size var player1_position = camera1.unproject_position(player1.translation) / screen_size var player2_position = camera2.unproject_position(player2.translation) / screen_size - + var thickness if adaptive_split_line_thickness: var position_difference = _compute_position_difference_in_world() @@ -73,7 +73,7 @@ func _update_splitscreen(): thickness = clamp(thickness, 0, split_line_thickness) else: thickness = split_line_thickness - + view.material.set_shader_param('split_active', _get_split_state()) view.material.set_shader_param('player1_position', player1_position) view.material.set_shader_param('player2_position', player2_position) @@ -91,11 +91,11 @@ func _get_split_state(): func _on_size_changed(): var screen_size = get_viewport().get_visible_rect().size - + $Viewport1.size = screen_size $Viewport2.size = screen_size view.rect_size = screen_size - + view.material.set_shader_param('viewport_size', screen_size) diff --git a/viewport/dynamic_split_screen/PlayerMovement.gd b/viewport/dynamic_split_screen/PlayerMovement.gd index 80ac4951..021acdd1 100644 --- a/viewport/dynamic_split_screen/PlayerMovement.gd +++ b/viewport/dynamic_split_screen/PlayerMovement.gd @@ -12,5 +12,5 @@ func _physics_process(_delta): velocity.z += Input.get_action_strength("move_down_player" + str(player_id)) velocity.x = -Input.get_action_strength("move_left_player" + str(player_id)) velocity.x += Input.get_action_strength("move_right_player" + str(player_id)) - + move_and_slide(velocity.normalized() * walk_speed) diff --git a/viewport/dynamic_split_screen/README.md b/viewport/dynamic_split_screen/README.md index d6dc097c..dabed082 100644 --- a/viewport/dynamic_split_screen/README.md +++ b/viewport/dynamic_split_screen/README.md @@ -13,7 +13,7 @@ Two cameras are placed inside two separate viewports and their texture, as well The `SplitScreen` shader, with the help of the `CameraController` script, chooses wich texture to display on each pixel to achieve the effect. -The cameras are placed on the segment joining the two players, either in the middle if they're close enough or at a fixed distance otherwise. +The cameras are placed on the segment joining the two players, either in the middle if they're close enough or at a fixed distance otherwise. # How to use it Open and launch the project inside the Godot engine and then you can use WASD keys to move the first player and IJKL keys to move the second one. diff --git a/viewport/dynamic_split_screen/SplitScreen.shader b/viewport/dynamic_split_screen/SplitScreen.shader index d2c95462..0275167a 100644 --- a/viewport/dynamic_split_screen/SplitScreen.shader +++ b/viewport/dynamic_split_screen/SplitScreen.shader @@ -24,23 +24,23 @@ void fragment() { float width = viewport_size.x; float height = viewport_size.y; - + if (split_active) { vec2 dx = player2_position - player1_position; float split_slope; - + if (dx.y != 0.0) { split_slope = dx.x / dx.y; } else { split_slope = 100000.0; // High value (vertical split) if dx.y = 0 } - + vec2 split_origin = vec2(0.5, 0.5); vec2 split_line_start = vec2(0.0, height * ((split_origin.x - 0.0) * split_slope + split_origin.y)); vec2 split_line_end = vec2(width, height * ((split_origin.x - 1.0) * split_slope + split_origin.y)); float distance_to_split_line = distanceToLine(split_line_start, split_line_end, vec2(UV.x * width, UV.y * height)); - + // Draw split border if close enough if (distance_to_split_line < split_line_thickness) { COLOR = split_line_color; diff --git a/viewport/dynamic_split_screen/Walls.gd b/viewport/dynamic_split_screen/Walls.gd index d806a5b9..5b9161c6 100644 --- a/viewport/dynamic_split_screen/Walls.gd +++ b/viewport/dynamic_split_screen/Walls.gd @@ -9,5 +9,5 @@ func _ready(): for wall in walls: var material = SpatialMaterial.new() material.albedo_color = Color(randf(), randf(), randf()) - + wall.material_override = material diff --git a/viewport/dynamic_split_screen/project.godot b/viewport/dynamic_split_screen/project.godot index e92dbac0..ac990940 100644 --- a/viewport/dynamic_split_screen/project.godot +++ b/viewport/dynamic_split_screen/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/viewport/gui_in_3d/gui_3d.gd b/viewport/gui_in_3d/gui_3d.gd index 71b60385..d8f84236 100644 --- a/viewport/gui_in_3d/gui_3d.gd +++ b/viewport/gui_in_3d/gui_3d.gd @@ -17,7 +17,7 @@ onready var node_area = $Quad/Area func _ready(): node_area.connect("mouse_entered", self, "_mouse_entered_area") - + # If the material is NOT set to use billboard settings, then avoid running billboard specific code if node_quad.get_surface_material(0).params_billboard_mode == 0: set_process(false) @@ -39,7 +39,7 @@ func _input(event): if event is mouse_event: is_mouse_event = true break - + # If the event is a mouse/touch event and/or the mouse is either held or inside the area, then # we need to do some additional processing in the handle_mouse function before passing the event to the viewport. # If the event is not a mouse/touch event, then we can just pass the event directly to the viewport. @@ -53,14 +53,14 @@ func _input(event): func handle_mouse(event): # Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh. quad_mesh_size = node_quad.mesh.size - + # Detect mouse being held to mantain event while outside of bounds. Avoid orphan clicks if event is InputEventMouseButton or event is InputEventScreenTouch: is_mouse_held = event.pressed - + # Find mouse position in Area var mouse_pos3D = find_mouse(event.global_position) - + # Check if the mouse is outside of bounds, use last position to avoid errors # NOTE: mouse_exited signal was unrealiable in this situation is_mouse_inside = mouse_pos3D != null @@ -73,12 +73,12 @@ func handle_mouse(event): mouse_pos3D = last_mouse_pos3D if mouse_pos3D == null: mouse_pos3D = Vector3.ZERO - + # TODO: adapt to bilboard mode or avoid completely - + # convert the relative event position from 3D to 2D var mouse_pos2D = Vector2(mouse_pos3D.x, -mouse_pos3D.y) - + # Right now the event position's range is the following: (-quad_size/2) -> (quad_size/2) # We need to convert it into the following range: 0 -> quad_size mouse_pos2D.x += quad_mesh_size.x / 2 @@ -86,16 +86,16 @@ func handle_mouse(event): # Then we need to convert it into the following range: 0 -> 1 mouse_pos2D.x = mouse_pos2D.x / quad_mesh_size.x mouse_pos2D.y = mouse_pos2D.y / quad_mesh_size.y - + # Finally, we convert the position to the following range: 0 -> viewport.size mouse_pos2D.x = mouse_pos2D.x * node_viewport.size.x mouse_pos2D.y = mouse_pos2D.y * node_viewport.size.y # We need to do these conversions so the event's position is in the viewport's coordinate system. - + # Set the event's position and global position. event.position = mouse_pos2D event.global_position = mouse_pos2D - + # If the event is a mouse motion event... if event is InputEventMouseMotion: # If there is not a stored previous position, then we'll assume there is no relative motion. @@ -107,23 +107,23 @@ func handle_mouse(event): event.relative = mouse_pos2D - last_mouse_pos2D # Update last_mouse_pos2D with the position we just calculated. last_mouse_pos2D = mouse_pos2D - + # Finally, send the processed input event to the viewport. node_viewport.input(event) func find_mouse(global_position): var camera = get_viewport().get_camera() - + # From camera center to the mouse position in the Area var from = camera.project_ray_origin(global_position) var dist = find_further_distance_to(camera.transform.origin) var to = from + camera.project_ray_normal(global_position) * dist - - + + # Manually raycasts the are to find the mouse position var result = get_world().direct_space_state.intersect_ray(from, to, [], node_area.collision_layer,false,true) #for 3.1 changes - + if result.size() > 0: return result.position else: @@ -137,7 +137,7 @@ func find_further_distance_to(origin): edges.append(node_area.to_global(Vector3(quad_mesh_size.x / 2, -quad_mesh_size.y / 2, 0))) edges.append(node_area.to_global(Vector3(-quad_mesh_size.x / 2, quad_mesh_size.y / 2, 0))) edges.append(node_area.to_global(Vector3(-quad_mesh_size.x / 2, -quad_mesh_size.y / 2, 0))) - + # Get the furthest distance between the camera and collision to avoid raycasting too far or too short var far_dist = 0 var temp_dist @@ -145,13 +145,13 @@ func find_further_distance_to(origin): temp_dist = origin.distance_to(edge) if temp_dist > far_dist: far_dist = temp_dist - + return far_dist func rotate_area_to_billboard(): var billboard_mode = node_quad.get_surface_material(0).params_billboard_mode - + # Try to match the area with the material's billboard setting, if enabled if billboard_mode > 0: # Get the camera @@ -159,12 +159,12 @@ func rotate_area_to_billboard(): # Look in the same direction as the camera var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin look = node_area.translation + look - + # Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted. - if billboard_mode == 2: + if billboard_mode == 2: look = Vector3(look.x, 0, look.z) - + node_area.look_at(look, Vector3.UP) - + # Rotate in the Z axis to compensate camera tilt node_area.rotate_object_local(Vector3.BACK, camera.rotation.z) diff --git a/viewport/gui_in_3d/project.godot b/viewport/gui_in_3d/project.godot index d029e8fa..f4501ff8 100644 --- a/viewport/gui_in_3d/project.godot +++ b/viewport/gui_in_3d/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/viewport/screen_capture/project.godot b/viewport/screen_capture/project.godot index 03ec1239..65c28218 100644 --- a/viewport/screen_capture/project.godot +++ b/viewport/screen_capture/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/visual_script/circle_pop/project.godot b/visual_script/circle_pop/project.godot index 08210c09..bc9acfad 100644 --- a/visual_script/circle_pop/project.godot +++ b/visual_script/circle_pop/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/visual_script/multitouch_view/project.godot b/visual_script/multitouch_view/project.godot index b620f34a..d91a2e99 100644 --- a/visual_script/multitouch_view/project.godot +++ b/visual_script/multitouch_view/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] diff --git a/visual_script/pong/project.godot b/visual_script/pong/project.godot index 168eb50a..be71a740 100644 --- a/visual_script/pong/project.godot +++ b/visual_script/pong/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application]