Format files using updated file_format.sh

This commit is contained in:
Aaron Franke
2020-10-01 14:23:54 -04:00
parent fe9fd7d7e4
commit 918a289ee2
79 changed files with 512 additions and 512 deletions

View File

@@ -15,12 +15,12 @@ func _process(delta):
# so each player sees the motion as smooth and not jerky.
if not stopped:
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()

View File

@@ -26,7 +26,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()
@@ -46,7 +46,7 @@ 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)
@@ -62,11 +62,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)
@@ -88,7 +88,7 @@ func _on_host_pressed():
# Is another server running?
_set_status("Can't host, address in use.",false)
return
get_tree().set_network_peer(peer)
host_button.set_disabled(true)
join_button.set_disabled(true)
@@ -100,10 +100,10 @@ func _on_join_pressed():
if not ip.is_valid_ip_address():
_set_status("IP address is invalid", false)
return
peer = NetworkedMultiplayerENet.new()
peer.set_compression_mode(NetworkedMultiplayerENet.COMPRESS_RANGE_CODER)
peer.create_client(ip, DEFAULT_PORT)
get_tree().set_network_peer(peer)
_set_status("Connecting...", true)

View File

@@ -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)

View File

@@ -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")