Skip to content

Commit

Permalink
Update projects to Godot 3.5 (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
zf-moth authored Jan 23, 2023
1 parent 4357b5b commit 9e68af3
Show file tree
Hide file tree
Showing 332 changed files with 988 additions and 858 deletions.
1 change: 1 addition & 0 deletions 2d/dodge_the_creeps/HUD.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends CanvasLayer

signal start_game


func show_message(text):
$MessageLabel.text = text
$MessageLabel.show()
Expand Down
2 changes: 2 additions & 0 deletions 2d/dodge_the_creeps/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends Node
export(PackedScene) var mob_scene
var score


func _ready():
randomize()

Expand Down Expand Up @@ -50,6 +51,7 @@ func _on_MobTimer_timeout():
# Spawn the mob by adding it to the Main scene.
add_child(mob)


func _on_ScoreTimer_timeout():
score += 1
$HUD.update_score(score)
Expand Down
3 changes: 0 additions & 3 deletions 2d/dodge_the_creeps/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ mob_scene = ExtResource( 2 )
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0.219608, 0.372549, 0.380392, 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Player" parent="." instance=ExtResource( 3 )]

Expand Down
1 change: 1 addition & 0 deletions 2d/dodge_the_creeps/Mob.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends RigidBody2D


func _ready():
$AnimatedSprite.playing = true
var mob_types = $AnimatedSprite.frames.get_animation_names()
Expand Down
1 change: 1 addition & 0 deletions 2d/dodge_the_creeps/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ signal hit
export var speed = 400 # How fast the player will move (pixels/sec).
var screen_size # Size of the game window.


func _ready():
screen_size = get_viewport_rect().size
hide()
Expand Down
4 changes: 3 additions & 1 deletion 2d/dodge_the_creeps/art/gameover.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
3 changes: 0 additions & 3 deletions 2d/finite_state_machine/debug/ControlsPanel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ anchor_left = 1.0
anchor_right = 1.0
margin_left = -220.0
margin_bottom = 170.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Keys" type="Label" parent="."]
anchor_right = 1.0
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/debug/states_stack_displayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Panel

onready var fsm_node = get_node("../../Player/StateMachine")


func _process(_delta):
var states_names = ""
var numbers = ""
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/bullet/bullet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(float) var speed = 1000.0

onready var root = get_tree().root


func _ready():
set_as_toplevel(true)

Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/bullet/bullet_spawner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Node2D

var bullet = preload("Bullet.tscn")


func _unhandled_input(event):
if event.is_action_pressed("fire"):
fire()
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/player_controller.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ signal direction_changed(new_direction)

var look_direction = Vector2.RIGHT setget set_look_direction


func take_damage(attacker, amount, effect = null):
if is_a_parent_of(attacker):
return
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/player_state_machine.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ onready var jump = $Jump
onready var stagger = $Stagger
onready var attack = $Attack


func _ready():
states_map = {
"idle": idle,
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/states/combat/attack.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends "res://state_machine/state.gd"


func enter():
owner.get_node("AnimationPlayer").play("idle")

Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/states/combat/stagger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends "res://state_machine/state.gd"
# The animation only affects the Body Sprite's modulate property so it
# could stack with other animations if we had two AnimationPlayer nodes.


func enter():
owner.get_node("AnimationPlayer").play("stagger")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Label

var start_position = Vector2()


func _ready():
start_position = rect_position

Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/states/die.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends "res://state_machine/state.gd"


# Initialize the state. E.g. change the animation.
func enter():
owner.set_dead(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var horizontal_velocity = Vector2()
var vertical_speed = 0.0
var height = 0.0


func initialize(speed, velocity):
horizontal_speed = speed
if speed > 0.0:
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/states/motion/motion.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends "res://state_machine/state.gd"
# Collection of important methods to handle direction and animation.


func handle_input(event):
if event.is_action_pressed("simulate_damage"):
emit_signal("finished", "stagger")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends "on_ground.gd"


func enter():
owner.get_node("AnimationPlayer").play("idle")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
extends "on_ground.gd"

export(float) var max_walk_speed = 450
export(float) var max_run_speed = 700

export(float) var max_walk_speed = 450.0
export(float) var max_run_speed = 700.0


func enter():
speed = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends "../motion.gd"
var speed = 0.0
var velocity = Vector2()


func handle_input(event):
if event.is_action_pressed("jump"):
emit_signal("finished", "jump")
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/weapon/sword.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var combo = [{

var hit_objects = []


func _ready():
# warning-ignore:return_value_discarded
$AnimationPlayer.connect("animation_finished", self, "_on_animation_finished")
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/player/weapon/weapon_pivot.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Position2D

var z_index_start = 0


func _ready():
#warning-ignore:return_value_discarded
owner.connect("direction_changed", self, "_on_Parent_direction_changed")
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/state_machine/state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extends Node
# warning-ignore:unused_signal
signal finished(next_state_name)


# Initialize the state. E.g. change the animation.
func enter():
pass
Expand Down
1 change: 1 addition & 0 deletions 2d/finite_state_machine/state_machine/state_machine.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var states_stack = []
var current_state = null
var _active = false setget set_active


func _ready():
if not start_state:
start_state = get_child(0).get_path()
Expand Down
1 change: 1 addition & 0 deletions 2d/gd_paint/paint_control.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var brush_shape = BrushShapes.CIRCLE;
# in the _draw function for more details).
var bg_color = Color.white


func _ready():
# Get the top left position node. We need this to find out whether or not the mouse is inside the canvas.
TL_node = get_node("TLPos")
Expand Down
3 changes: 1 addition & 2 deletions 2d/gd_paint/paint_root.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ text = "Clear picture"
[node name="SaveFileDialog" type="FileDialog" parent="."]
margin_right = 600.0
margin_bottom = 400.0
rect_min_size = Vector2( 300, 105 )
resizable = true
access = 2
filters = PoolStringArray( "*.png" )
current_dir = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint"
current_path = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint/"
1 change: 1 addition & 0 deletions 2d/gd_paint/tools_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ onready var _parent = get_parent()
onready var save_dialog = _parent.get_node(@"SaveFileDialog")
onready var paint_control = _parent.get_node(@"PaintControl")


func _ready():
# warning-ignore-all:return_value_discarded
# Assign all of the needed signals for the oppersation buttons.
Expand Down
1 change: 1 addition & 0 deletions 2d/hdr/beach_cave.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const CAVE_LIMIT = 1000

onready var cave = $Cave


func _unhandled_input(event):
if event is InputEventMouseMotion and event.button_mask > 0:
var rel_x = event.relative.x
Expand Down
1 change: 1 addition & 0 deletions 2d/hexagonal_map/troll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends KinematicBody2D
const MOTION_SPEED = 160 # Pixels/second.
const TAN30DEG = tan(deg2rad(30))


func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
Expand Down
1 change: 1 addition & 0 deletions 2d/instancing/ball_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Node2D

export(PackedScene) var ball_scene = preload("res://ball.tscn")


func _unhandled_input(event):
if event.is_echo():
return
Expand Down
1 change: 1 addition & 0 deletions 2d/isometric/troll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends KinematicBody2D

const MOTION_SPEED = 160 # Pixels/second.


func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
Expand Down
1 change: 1 addition & 0 deletions 2d/kinematic_character/level/princess.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends Node


func _on_body_entered(body):
if body.name == "Player":
$"../WinText".show()
1 change: 1 addition & 0 deletions 2d/kinematic_character/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var velocity = Vector2()

onready var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")


func _physics_process(delta):
# Horizontal movement code. First, get the player's input.
var walk = WALK_FORCE * (Input.get_action_strength("move_right") - Input.get_action_strength("move_left"))
Expand Down
2 changes: 1 addition & 1 deletion 2d/navigation/level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vertices = PoolVector2Array( 587.833, 271.924, 530.464, 284.878, 508.256, 281.17
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6 ), PoolIntArray( 7, 8, 9 ), PoolIntArray( 10, 11, 12, 13, 14 ), PoolIntArray( 15, 16, 17, 18, 19, 20 ), PoolIntArray( 21, 3, 2, 22, 23 ), PoolIntArray( 24, 25, 26, 27, 28 ), PoolIntArray( 25, 24, 29 ), PoolIntArray( 30, 25, 29, 31 ), PoolIntArray( 32, 33, 34, 35, 36 ), PoolIntArray( 37, 38, 39, 40 ), PoolIntArray( 41, 37, 40 ), PoolIntArray( 41, 40, 42, 43 ), PoolIntArray( 44, 45, 30, 31 ), PoolIntArray( 46, 12, 11, 7, 47 ), PoolIntArray( 47, 7, 9 ), PoolIntArray( 48, 10, 14, 49 ), PoolIntArray( 50, 6, 5, 51, 48 ), PoolIntArray( 52, 50, 48, 49 ), PoolIntArray( 53, 52, 49, 54, 55 ), PoolIntArray( 17, 56, 57, 58, 18 ), PoolIntArray( 59, 60, 61, 62, 63 ), PoolIntArray( 64, 65, 61, 66 ), PoolIntArray( 66, 61, 60, 67, 68 ), PoolIntArray( 68, 67, 69, 70 ), PoolIntArray( 68, 70, 35, 34 ), PoolIntArray( 71, 53, 55, 72 ), PoolIntArray( 71, 72, 73, 74 ), PoolIntArray( 4, 6, 75, 76 ), PoolIntArray( 63, 77, 74, 59 ), PoolIntArray( 78, 2, 1, 76, 75, 79, 80 ), PoolIntArray( 78, 80, 63, 62 ), PoolIntArray( 81, 59, 74, 73 ), PoolIntArray( 81, 73, 41, 82 ), PoolIntArray( 44, 31, 83, 84, 85 ), PoolIntArray( 18, 86, 47, 9, 19 ), PoolIntArray( 15, 20, 3, 21 ), PoolIntArray( 23, 22, 87, 88 ), PoolIntArray( 89, 28, 27, 90, 91 ), PoolIntArray( 89, 91, 92, 93 ), PoolIntArray( 36, 94, 95, 93, 92 ), PoolIntArray( 36, 92, 88 ), PoolIntArray( 36, 88, 87, 32 ), PoolIntArray( 36, 35, 85, 84 ), PoolIntArray( 42, 44, 85, 96 ), PoolIntArray( 42, 96, 43 ), PoolIntArray( 41, 43, 82 ) ]
outlines = [ PoolVector2Array( 221.41, 488.446, 147.386, 408.87, 145.584, 224.311, 202.904, 99.8167, 310.24, 62.8043, 310.24, 75.7586, 517.509, 55.4019, 537.866, 99.8167, 536.016, 175.692, 476.796, 207.152, 443.485, 192.348, 437.933, 170.14, 415.725, 177.543, 428.68, 246.015, 471.244, 251.567, 587.833, 179.393, 573.028, 140.53, 645.202, 159.036, 573.028, 94.2648, 582.281, 47.9994, 667.409, 75.7586, 710.106, 179.216, 700.721, 268.223, 682.214, 284.878, 695.169, 303.385, 706.272, 501.401, 669.26, 529.16, 602.638, 523.608, 571.177, 501.401, 536.407, 524.944, 371.311, 518.056, 300.441, 497.494, 317.643, 447.733, 182.548, 382.961, 193.651, 423.675, 245.469, 477.343 ), PoolVector2Array( 350.954, 447.733, 363.908, 351.501, 321.344, 338.546, 241.767, 327.443, 234.365, 244.165, 288.033, 231.211, 221.41, 171.991, 189.95, 231.211, 175.145, 332.995, 184.398, 349.65, 265.825, 407.019 ), PoolVector2Array( 267.676, 153.485, 310.24, 112.771, 308.39, 92.4142, 487.899, 85.0117, 502.704, 97.9661, 495.302, 164.588, 465.692, 179.393, 452.738, 166.439, 476.796, 149.783, 460.14, 123.875, 319.493, 190.497 ), PoolVector2Array( 397.219, 188.646, 345.402, 210.854, 360.207, 223.808, 297.286, 258.97, 299.136, 283.028, 352.804, 320.04, 424.978, 334.845, 421.277, 360.754, 384.265, 351.501, 376.862, 418.123, 480.497, 434.779, 508.256, 281.177, 421.277, 270.074 ), PoolVector2Array( 497.153, 255.269, 597.086, 192.348, 630.397, 212.704, 650.754, 251.567, 648.903, 321.891, 669.26, 297.833, 676.663, 493.998, 619.293, 510.654, 598.937, 492.148, 621.144, 486.596, 648.903, 394.065, 624.926, 359.595, 526.762, 342.248, 530.464, 284.878, 587.833, 271.924 ), PoolVector2Array( 325.228, 486.302, 332.441, 457.494, 366.441, 467.494, 373.441, 436.494, 476.441, 468.494, 496.638, 439.381, 524.608, 359.37, 620.443, 383.995, 605.437, 456.366, 538.077, 499.891, 395.879, 501.87 ) ]

[node name="Navigation2D" type="Navigation2D"]
[node name="Navigation2D" type="Node2D"]
script = ExtResource( 1 )

[node name="Navmesh" type="NavigationPolygonInstance" parent="."]
Expand Down
36 changes: 33 additions & 3 deletions 2d/navigation/navigation.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
extends Navigation2D
extends Node2D


export(float) var character_speed = 400.0
var path = []

var map

onready var character = $Character


func _ready():
# use call deferred to make sure the entire SceneTree Nodes are setup
# else yield on 'physics_frame' in a _ready() might get stuck
call_deferred("setup_navserver")


func _process(delta):
var walk_distance = character_speed * delta
move_along_path(walk_distance)
Expand All @@ -18,6 +28,26 @@ func _unhandled_input(event):
_update_navigation_path(character.position, get_local_mouse_position())


func setup_navserver():

# create a new navigation map
map = Navigation2DServer.map_create()
Navigation2DServer.map_set_active(map, true)

# create a new navigation region and add it to the map
var region = Navigation2DServer.region_create()
Navigation2DServer.region_set_transform(region, Transform())
Navigation2DServer.region_set_map(region, map)

# sets navigation mesh for the region
var navigation_poly = NavigationMesh.new()
navigation_poly = $Navmesh.navpoly
Navigation2DServer.region_set_navpoly(region, navigation_poly)

# wait for Navigation2DServer sync to adapt to made changes
yield(get_tree(), "physics_frame")


func move_along_path(distance):
var last_point = character.position
while path.size():
Expand All @@ -36,10 +66,10 @@ func move_along_path(distance):


func _update_navigation_path(start_position, end_position):
# get_simple_path is part of the Navigation2D class.
# map_get_path is part of the avigation2DServer class.
# It returns a PoolVector2Array of points that lead you
# from the start_position to the end_position.
path = get_simple_path(start_position, end_position, true)
path = Navigation2DServer.map_get_path(map,start_position, end_position, true)
# The first point is always the start_position.
# We don't need it in this example as it corresponds to the character's position.
path.remove(0)
Expand Down
1 change: 1 addition & 0 deletions 2d/navigation_astar/character.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _target_position = Vector2()

var _velocity = Vector2()


func _ready():
_change_state(States.IDLE)

Expand Down
1 change: 1 addition & 0 deletions 2d/navigation_astar/pathfind_astar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ onready var astar_node = AStar.new()
onready var obstacles = get_used_cells_by_id(0)
onready var _half_cell_size = cell_size / 2


func _ready():
var walkable_cells_list = astar_add_walkable_cells(obstacles)
astar_connect_walkable_cells(walkable_cells_list)
Expand Down
4 changes: 3 additions & 1 deletion 2d/physics_platformer/audio/sound_coin.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
4 changes: 3 additions & 1 deletion 2d/physics_platformer/audio/sound_explode.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
4 changes: 3 additions & 1 deletion 2d/physics_platformer/audio/sound_hit.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Loading

0 comments on commit 9e68af3

Please sign in to comment.