Skip to content

Commit 2399874

Browse files
authored
Merge branch 'master' into navigation_astar_hexagonal
2 parents 4fbff04 + 16d8ba0 commit 2399874

File tree

809 files changed

+9720
-8100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

809 files changed

+9720
-8100
lines changed

2d/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
These demos are all 2D, but otherwise do not have a common theme.
44

55
Languages: Most have GDScript, some have
6-
[GDSL](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/shading_language.html)
6+
[Godot shader language](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/shading_language.html)
77

8-
Renderers: 4 of them are GLES 3, but most are GLES 2
8+
Renderers: Glow for 2D and Physics Platformer use Forward+, 2D Particles uses Mobile, and the rest use Compatibility

2d/bullet_shower/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ in the documentation for more information.
99

1010
Language: GDScript
1111

12-
Renderer: Vulkan Mobile
12+
Renderer: Compatibility
1313

14-
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/887
14+
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2711
1515

1616
## Screenshots
1717

2d/bullet_shower/bullets.gd

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ const BULLET_COUNT = 500
88
const SPEED_MIN = 20
99
const SPEED_MAX = 80
1010

11-
const bullet_image = preload("res://bullet.png")
11+
const bullet_image := preload("res://bullet.png")
1212

1313
var bullets := []
14-
var shape
14+
var shape := RID()
1515

1616

1717
class Bullet:
18-
var position = Vector2()
19-
var speed = 1.0
18+
var position := Vector2()
19+
var speed := 1.0
2020
# The body is stored as a RID, which is an "opaque" way to access resources.
2121
# With large amounts of objects (thousands or more), it can be significantly
2222
# faster to use RIDs compared to a high-level approach.
23-
var body = RID()
23+
var body := RID()
2424

2525

26-
func _ready():
26+
func _ready() -> void:
2727
shape = PhysicsServer2D.circle_shape_create()
2828
# Set the collision shape's radius for each bullet in pixels.
2929
PhysicsServer2D.shape_set_data(shape, 8)
3030

3131
for _i in BULLET_COUNT:
32-
var bullet = Bullet.new()
32+
var bullet := Bullet.new()
3333
# Give each bullet its own random speed.
3434
bullet.speed = randf_range(SPEED_MIN, SPEED_MAX)
3535
bullet.body = PhysicsServer2D.body_create()
@@ -45,22 +45,22 @@ func _ready():
4545
randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
4646
randf_range(0, get_viewport_rect().size.y)
4747
)
48-
var transform2d = Transform2D()
48+
var transform2d := Transform2D()
4949
transform2d.origin = bullet.position
5050
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
5151

5252
bullets.push_back(bullet)
5353

5454

55-
func _process(_delta):
55+
func _process(_delta: float) -> void:
5656
# Order the CanvasItem to update every frame.
5757
queue_redraw()
5858

5959

60-
func _physics_process(delta):
61-
var transform2d = Transform2D()
62-
var offset = get_viewport_rect().size.x + 16
63-
for bullet in bullets:
60+
func _physics_process(delta: float) -> void:
61+
var transform2d := Transform2D()
62+
var offset := get_viewport_rect().size.x + 16
63+
for bullet: Bullet in bullets:
6464
bullet.position.x -= bullet.speed * delta
6565

6666
if bullet.position.x < -16:
@@ -73,15 +73,15 @@ func _physics_process(delta):
7373

7474
# Instead of drawing each bullet individually in a script attached to each bullet,
7575
# we are drawing *all* the bullets at once here.
76-
func _draw():
77-
var offset = -bullet_image.get_size() * 0.5
78-
for bullet in bullets:
76+
func _draw() -> void:
77+
var offset := -bullet_image.get_size() * 0.5
78+
for bullet: Bullet in bullets:
7979
draw_texture(bullet_image, bullet.position + offset)
8080

8181

8282
# Perform cleanup operations (required to exit without error messages in the console).
83-
func _exit_tree():
84-
for bullet in bullets:
83+
func _exit_tree() -> void:
84+
for bullet: Bullet in bullets:
8585
PhysicsServer2D.free_rid(bullet.body)
8686

8787
PhysicsServer2D.free_rid(shape)

2d/bullet_shower/player.gd

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ extends Node2D
44
# efficient than using instancing and nodes, but requires more programming and
55
# is less visual. Bullets are managed together in the `bullets.gd` script.
66

7-
# The number of bullets currently touched by the player.
8-
var touching = 0
7+
## The number of bullets currently touched by the player.
8+
var touching := 0
99

10-
@onready var sprite = $AnimatedSprite2D
10+
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
1111

1212

13-
func _ready():
13+
func _ready() -> void:
1414
# The player follows the mouse cursor automatically, so there's no point
1515
# in displaying the mouse cursor.
1616
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
1717

1818

19-
func _input(event):
19+
func _input(event: InputEvent) -> void:
2020
# Getting the movement of the mouse so the sprite can follow its position.
2121
if event is InputEventMouseMotion:
2222
position = event.position - Vector2(0, 16)
2323

2424

25-
func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape):
25+
func _on_body_shape_entered(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
2626
# Player got touched by a bullet so sprite changes to sad face.
2727
touching += 1
2828
if touching >= 1:
2929
sprite.frame = 1
3030

3131

32-
func _on_body_shape_exited(_body_id, _body, _body_shape, _local_shape):
32+
func _on_body_shape_exited(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
3333
touching -= 1
3434
# When non of the bullets are touching the player,
3535
# sprite changes to happy face.

2d/bullet_shower/project.godot

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ run/main_scene="res://shower.tscn"
1717
config/features=PackedStringArray("4.2")
1818
config/icon="res://icon.webp"
1919

20+
[debug]
21+
22+
gdscript/warnings/untyped_declaration=1
23+
2024
[display]
2125

2226
window/stretch/mode="canvas_items"
@@ -26,10 +30,7 @@ window/stretch/aspect="expand"
2630

2731
2d_physics/layer_1="Player"
2832

29-
[physics]
30-
31-
2d/cell_size=64
32-
3333
[rendering]
3434

35-
renderer/rendering_method="mobile"
35+
renderer/rendering_method="gl_compatibility"
36+
renderer/rendering_method.mobile="gl_compatibility"

2d/dodge_the_creeps/HUD.tscn

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
[gd_scene load_steps=4 format=3 uid="uid://ccqoreueuxdb7"]
1+
[gd_scene load_steps=5 format=3 uid="uid://ccqoreueuxdb7"]
22

33
[ext_resource type="Script" path="res://HUD.gd" id="1"]
4+
[ext_resource type="FontFile" uid="uid://cit6gwe5px1q8" path="res://fonts/Xolonium-Regular.ttf" id="2_2jm3i"]
45

56
[sub_resource type="InputEventAction" id="InputEventAction_fopy7"]
67
action = &"start_game"
@@ -16,6 +17,7 @@ anchors_preset = 10
1617
anchor_right = 1.0
1718
offset_bottom = 78.0
1819
grow_horizontal = 2
20+
theme_override_fonts/font = ExtResource("2_2jm3i")
1921
theme_override_font_sizes/font_size = 60
2022
text = "0"
2123
horizontal_alignment = 1
@@ -29,6 +31,7 @@ offset_top = -79.5
2931
offset_bottom = 79.5
3032
grow_horizontal = 2
3133
grow_vertical = 2
34+
theme_override_fonts/font = ExtResource("2_2jm3i")
3235
theme_override_font_sizes/font_size = 60
3336
text = "Dodge the
3437
Creeps"
@@ -46,6 +49,7 @@ offset_right = 90.0
4649
offset_bottom = -100.0
4750
grow_horizontal = 2
4851
grow_vertical = 0
52+
theme_override_fonts/font = ExtResource("2_2jm3i")
4953
theme_override_font_sizes/font_size = 60
5054
shortcut = SubResource("4")
5155
text = "Start"

2d/dodge_the_creeps/Player.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func start(pos):
4747
$CollisionShape2D.disabled = false
4848

4949

50-
func _on_Player_body_entered(_body):
50+
func _on_body_entered(_body):
5151
hide() # Player disappears after being hit.
5252
hit.emit()
5353
# Must be deferred as we can't change physics properties on a physics callback.

2d/dodge_the_creeps/Player.tscn

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ process_material = SubResource("7")
7272
texture = ExtResource("2")
7373
speed_scale = 2.0
7474

75-
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
75+
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

2d/dodge_the_creeps/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ consider following the tutorial in the documentation.
1010

1111
Language: GDScript
1212

13-
Renderer: Vulkan Mobile
13+
Renderer: Compatibility
1414

1515
Note: There is a C# version available [here](https://github.com/godotengine/godot-demo-projects/tree/master/mono/dodge_the_creeps).
1616

17-
Note: There is a GDNative C++ version available [here](https://github.com/godotengine/gdnative-demos/tree/master/cpp/dodge_the_creeps).
18-
19-
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/515
17+
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2712
2018

2119
## Screenshots
2220

2d/dodge_the_creeps/fonts/Xolonium-Regular.tres

-6
This file was deleted.

2d/dodge_the_creeps/project.godot

+7-10
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ run/main_scene="res://Main.tscn"
2222
config/features=PackedStringArray("4.2")
2323
config/icon="res://icon.webp"
2424

25-
[debug]
26-
27-
gdscript/warnings/redundant_await=false
28-
2925
[display]
3026

3127
window/size/viewport_width=480
@@ -37,44 +33,45 @@ window/stretch/mode="canvas_items"
3733
[input]
3834

3935
move_left={
40-
"deadzone": 0.5,
36+
"deadzone": 0.2,
4137
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
4238
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
4339
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
4440
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
4541
]
4642
}
4743
move_right={
48-
"deadzone": 0.5,
44+
"deadzone": 0.2,
4945
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null)
5046
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
5147
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
5248
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
5349
]
5450
}
5551
move_up={
56-
"deadzone": 0.5,
52+
"deadzone": 0.2,
5753
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
5854
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
5955
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
6056
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
6157
]
6258
}
6359
move_down={
64-
"deadzone": 0.5,
60+
"deadzone": 0.2,
6561
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
6662
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
6763
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
6864
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
6965
]
7066
}
7167
start_game={
72-
"deadzone": 0.5,
68+
"deadzone": 0.2,
7369
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
7470
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
7571
]
7672
}
7773

7874
[rendering]
7975

80-
renderer/rendering_method="mobile"
76+
renderer/rendering_method="gl_compatibility"
77+
renderer/rendering_method.mobile="gl_compatibility"

2d/dynamic_tilemap_layers/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ to disable collisions per layer.
66

77
Language: GDScript
88

9-
Renderer: OpenGL
9+
Renderer: Compatibility
10+
11+
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2713
1012

1113
## Screenshots
1214

2d/dynamic_tilemap_layers/level/tile_map.gd

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
extends TileMap
22

3-
4-
var secret_layer: int # You can have multiple layers if you make this an array.
5-
var player_in_secret: bool
3+
# You can have multiple layers if you make this an array.
4+
var secret_layer := 0
5+
var player_in_secret := false
66
var layer_alpha := 1.0
77

8-
98
func _init() -> void:
10-
for i in get_layers_count(): # Find the secret layer by name.
9+
for i in get_layers_count():
10+
# Find the secret layer by name.
1111
if get_layer_name(i) == "Secret":
1212
secret_layer = i
1313

@@ -19,7 +19,8 @@ func _ready() -> void:
1919
func _process(delta: float) -> void:
2020
if player_in_secret:
2121
if layer_alpha > 0.3:
22-
layer_alpha = move_toward(layer_alpha, 0.3, delta) # Animate the layer transparency.
22+
# Animate the layer transparency.
23+
layer_alpha = move_toward(layer_alpha, 0.3, delta)
2324
set_layer_modulate(secret_layer, Color(1, 1, 1, layer_alpha))
2425
else:
2526
set_process(false)
@@ -32,17 +33,17 @@ func _process(delta: float) -> void:
3233

3334

3435
func _use_tile_data_runtime_update(layer: int, _coords: Vector2i) -> bool:
35-
if layer == secret_layer:
36-
return true
37-
return false
36+
return layer == secret_layer
3837

3938

4039
func _tile_data_runtime_update(_layer: int, _coords: Vector2i, tile_data: TileData) -> void:
41-
tile_data.set_collision_polygons_count(0, 0) # Remove collision for secret layer.
40+
# Remove collision for secret layer.
41+
tile_data.set_collision_polygons_count(0, 0)
4242

4343

4444
func _on_secret_detector_body_entered(body: Node2D) -> void:
45-
if not body is CharacterBody2D: # Detect player only.
45+
if not body is CharacterBody2D:
46+
# Detect the player only.
4647
return
4748

4849
player_in_secret = true

2d/dynamic_tilemap_layers/player/player.gd

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const WALK_MAX_SPEED = 200
55
const STOP_FORCE = 1300
66
const JUMP_SPEED = 200
77

8-
@onready var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
8+
@onready var gravity: float = ProjectSettings.get_setting("physics/2d/default_gravity")
99

10-
func _physics_process(delta):
10+
func _physics_process(delta: float) -> void:
1111
# Horizontal movement code. First, get the player's input.
12-
var walk = WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
12+
var walk := WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
1313
# Slow down the player if they're not trying to move.
1414
if abs(walk) < WALK_FORCE * 0.2:
1515
# The velocity, slowed down a bit, and then reassigned.

0 commit comments

Comments
 (0)