Skip to content

Commit 006309b

Browse files
committed
Many tweaks thanks to IAmActuallyCthulhu
Also change apostrophes to double quotes and update C# projects
1 parent 866f826 commit 006309b

File tree

64 files changed

+216
-188
lines changed

Some content is hidden

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

64 files changed

+216
-188
lines changed

2d/dodge_the_creeps/HUD.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func show_game_over():
1313
yield($MessageTimer, "timeout")
1414
$MessageLabel.text = "Dodge the\nCreeps"
1515
$MessageLabel.show()
16-
yield(get_tree().create_timer(1), 'timeout')
16+
yield(get_tree().create_timer(1), "timeout")
1717
$StartButton.show()
1818

1919

2d/dodge_the_creeps/Main.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extends Node
22

3-
export (PackedScene) var Mob
3+
export(PackedScene) var Mob
44
var score
55

66
func _ready():
@@ -28,9 +28,9 @@ func _on_MobTimer_timeout():
2828
$MobPath/MobSpawnLocation.offset = randi()
2929
var mob = Mob.instance()
3030
add_child(mob)
31-
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
31+
var direction = $MobPath/MobSpawnLocation.rotation + TAU / 4
3232
mob.position = $MobPath/MobSpawnLocation.position
33-
direction += rand_range(-PI / 4, PI / 4)
33+
direction += rand_range(-TAU / 8, TAU / 8)
3434
mob.rotation = direction
3535
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction)
3636
# warning-ignore:return_value_discarded

2d/finite_state_machine/debug/states_stack_displayer.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ func _process(_delta):
77
var numbers = ""
88
var index = 0
99
for state in fsm_node.states_stack:
10-
states_names += state.get_name() + '\n'
11-
numbers += str(index) + '\n'
10+
states_names += state.get_name() + "\n"
11+
numbers += str(index) + "\n"
1212
index += 1
1313
$States.text = states_names
1414
$Numbers.text = numbers

2d/finite_state_machine/player/bullet/bullet.gd

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ extends KinematicBody2D
33
var direction = Vector2()
44
export(float) var speed = 1000.0
55

6+
onready var root = get_tree().root
7+
68
func _ready():
79
set_as_toplevel(true)
810

911

1012
func _physics_process(delta):
11-
if is_outside_view_bounds():
13+
if not root.get_visible_rect().has_point(position):
1214
queue_free()
1315

1416
var motion = direction * speed * delta
@@ -17,10 +19,5 @@ func _physics_process(delta):
1719
queue_free()
1820

1921

20-
func is_outside_view_bounds():
21-
return position.x > OS.get_screen_size().x or position.x < 0.0 \
22-
or position.y > OS.get_screen_size().y or position.y < 0.0
23-
24-
2522
func _draw():
2623
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)

2d/finite_state_machine/player/player_state_machine.gd

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
extends "res://state_machine/state_machine.gd"
22

3+
onready var idle = $Idle
4+
onready var move = $Move
5+
onready var jump = $Jump
6+
onready var stagger = $Stagger
7+
onready var attack = $Attack
8+
39
func _ready():
410
states_map = {
5-
"idle": $Idle,
6-
"move": $Move,
7-
"jump": $Jump,
8-
"stagger": $Stagger,
9-
"attack": $Attack,
11+
"idle": idle,
12+
"move": move,
13+
"jump": jump,
14+
"stagger": stagger,
15+
"attack": attack,
1016
}
1117

1218

@@ -16,16 +22,16 @@ func _change_state(state_name):
1622
return
1723
if state_name in ["stagger", "jump", "attack"]:
1824
states_stack.push_front(states_map[state_name])
19-
if state_name == "jump" and current_state == $Move:
20-
$Jump.initialize($Move.speed, $Move.velocity)
25+
if state_name == "jump" and current_state == move:
26+
jump.initialize(move.speed, move.velocity)
2127
._change_state(state_name)
2228

2329

2430
func _unhandled_input(event):
2531
# Here we only handle input that can interrupt states, attacking in this case,
2632
# otherwise we let the state node handle it.
2733
if event.is_action_pressed("attack"):
28-
if current_state in [$Attack, $Stagger]:
34+
if current_state in [attack, stagger]:
2935
return
3036
_change_state("attack")
3137
return

2d/finite_state_machine/player/states/motion/in_air/jump.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func initialize(speed, velocity):
2222
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
2323
enter_velocity = velocity
2424

25+
2526
func enter():
2627
var input_direction = get_input_direction()
2728
update_look_direction(input_direction)
@@ -31,6 +32,7 @@ func enter():
3132

3233
owner.get_node("AnimationPlayer").play("idle")
3334

35+
3436
func update(delta):
3537
var input_direction = get_input_direction()
3638
update_look_direction(input_direction)
@@ -40,6 +42,7 @@ func update(delta):
4042
if height <= 0.0:
4143
emit_signal("finished", "previous")
4244

45+
4346
func move_horizontally(delta, direction):
4447
if direction:
4548
horizontal_speed += air_acceleration * delta
@@ -53,6 +56,7 @@ func move_horizontally(delta, direction):
5356

5457
owner.move_and_slide(horizontal_velocity)
5558

59+
5660
func animate_jump_height(delta):
5761
vertical_speed -= gravity * delta
5862
height += vertical_speed * delta

2d/finite_state_machine/player/states/motion/motion.gd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ func handle_input(event):
77

88

99
func get_input_direction():
10-
var input_direction = Vector2()
11-
input_direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
12-
input_direction.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
10+
var input_direction = Vector2(
11+
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
12+
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
13+
)
1314
return input_direction
1415

1516

2d/finite_state_machine/state_machine/state_machine.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ func _ready():
2121
if not start_state:
2222
start_state = get_child(0).get_path()
2323
for child in get_children():
24-
child.connect("finished", self, "_change_state")
24+
var err = child.connect("finished", self, "_change_state")
25+
if err:
26+
printerr(err)
2527
initialize(start_state)
2628

2729

2d/gd_paint/PaintControl.gd renamed to 2d/gd_paint/paint_control.gd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,9 @@ func _draw():
232232
draw_circle(brush.brush_pos, brush.brush_shape_circle_radius, brush.brush_color)
233233

234234

235-
236235
func save_picture(path):
237-
# Wait a couple frames so the save dialog isn't in the way.
238-
yield (get_tree(), "idle_frame")
239-
yield (get_tree(), "idle_frame")
236+
# Wait until the frame has finished before getting the texture.
237+
yield(VisualServer, "frame_post_draw")
240238

241239
# Get the viewport image.
242240
var img = get_viewport().get_texture().get_data()

2d/gd_paint/Paint_root.tscn renamed to 2d/gd_paint/paint_root.tscn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[gd_scene load_steps=5 format=2]
22

3-
[ext_resource path="res://PaintControl.gd" type="Script" id=1]
4-
[ext_resource path="res://ToolsPanel.gd" type="Script" id=2]
5-
[ext_resource path="res://PaintTools.png" type="Texture" id=3]
3+
[ext_resource path="res://paint_control.gd" type="Script" id=1]
4+
[ext_resource path="res://tools_panel.gd" type="Script" id=2]
5+
[ext_resource path="res://paint_tools.png" type="Texture" id=3]
66

77
[sub_resource type="StyleBoxFlat" id=1]
88
bg_color = Color( 1, 1, 1, 1 )

0 commit comments

Comments
 (0)