Skip to content

Commit af45026

Browse files
committed
formatting
1 parent 8ca7087 commit af45026

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

net-pong/rust/src/ball.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use godot::prelude::*;
2-
use godot::classes::{Area2D, IArea2D};
31
use crate::pong::Pong;
2+
use godot::classes::{Area2D, IArea2D};
3+
use godot::prelude::*;
44

55
const DEFAULT_SPEED: f64 = 100.0;
66

@@ -16,7 +16,6 @@ pub struct Ball {
1616
#[godot_api]
1717
impl IArea2D for Ball {
1818
fn init(base: Base<Area2D>) -> Self {
19-
2019
Self {
2120
direction: Vector2::LEFT,
2221
stopped: false,

net-pong/rust/src/lobby.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use godot::classes::enet_connection::CompressionMode;
2-
use godot::classes::object::ConnectFlags;
3-
use godot::classes::{
4-
Button, ENetMultiplayerPeer, Label, LineEdit, LinkButton, Os, Panel, ProjectSettings, IPanel
5-
};
6-
use godot::global::Error;
1+
use godot::classes::enet_connection::CompressionMode;
2+
use godot::classes::object::ConnectFlags;
3+
use godot::classes::{
4+
Button, ENetMultiplayerPeer, IPanel, Label, LineEdit, LinkButton, Os, Panel, ProjectSettings,
5+
};
6+
use godot::global::Error;
77
use godot::prelude::*;
88

99
use crate::pong::Pong;
@@ -33,7 +33,6 @@ pub struct Lobby {
3333

3434
#[godot_api]
3535
impl IPanel for Lobby {
36-
3736
fn ready(&mut self) {
3837
/*
3938
# Connect all the callbacks related to networking.
@@ -51,16 +50,15 @@ impl IPanel for Lobby {
5150
.builder()
5251
.connect_other_gd(&gd_ref, |mut this: Gd<Self>, _id: i64| {
5352
godot_print!("Someone connected, start the game!");
54-
let pong: Gd<Pong> = load::<PackedScene>("res://pong.tscn")
55-
.instantiate_as::<Pong>();
53+
let pong: Gd<Pong> =
54+
load::<PackedScene>("res://pong.tscn").instantiate_as::<Pong>();
5655
// Connect deferred so we can safely erase it from the callback.
5756
pong.signals()
5857
.game_finished()
5958
.builder()
6059
.flags(ConnectFlags::DEFERRED)
6160
.connect_other_gd(&this, |mut this: Gd<Self>| {
62-
this.bind_mut()
63-
.end_game("Client disconnected.".to_string());
61+
this.bind_mut().end_game("Client disconnected.".to_string());
6462
});
6563

6664
this.bind_mut()
@@ -148,7 +146,7 @@ impl Lobby {
148146
self.base().get_node_as::<Node>("/root/Pong").free();
149147
self.base_mut().show();
150148
}
151-
149+
152150
let mut multiplayer = self.base().get_multiplayer().unwrap();
153151
multiplayer.set_multiplayer_peer(Gd::null_arg()); // Remove peer.
154152
self.host_button.set_disabled(false);
@@ -176,13 +174,13 @@ impl Lobby {
176174
self.host_button.set_disabled(true);
177175
self.join_button.set_disabled(true);
178176
self.set_status("Waiting for player...", true);
179-
let application_name = ProjectSettings::singleton()
180-
.get_setting("application/config/name")
181-
.to_string();
182-
self.base_mut()
183-
.get_window()
184-
.unwrap()
185-
.set_title(&format!("{application_name}: Server"));
177+
let application_name = ProjectSettings::singleton()
178+
.get_setting("application/config/name")
179+
.to_string();
180+
self.base_mut()
181+
.get_window()
182+
.unwrap()
183+
.set_title(&format!("{application_name}: Server"));
186184
// Only show hosting instructions when relevant.
187185
self.port_forward_label.set_visible(true);
188186
self.find_public_ip_button.set_visible(true);
@@ -205,13 +203,13 @@ impl Lobby {
205203
multiplayer.set_multiplayer_peer(&peer);
206204

207205
self.set_status("Connecting...", true);
208-
let application_name = ProjectSettings::singleton()
209-
.get_setting("application/config/name")
210-
.to_string();
211-
self.base_mut()
212-
.get_window()
213-
.unwrap()
214-
.set_title(&format!("{application_name}: Client"));
206+
let application_name = ProjectSettings::singleton()
207+
.get_setting("application/config/name")
208+
.to_string();
209+
self.base_mut()
210+
.get_window()
211+
.unwrap()
212+
.set_title(&format!("{application_name}: Client"));
215213
}
216214

217215
fn _on_find_public_ip_pressed(&mut self) {

net-pong/rust/src/paddle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use godot::classes::IArea2D;
2121

2222
#[godot_api]
2323
impl IArea2D for Paddle {
24-
2524
fn ready(&mut self) {
2625
// bounce signal is emitted when the ball enters the paddle area.
2726
self.signals()

net-pong/rust/src/pong.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use godot::classes::{INode2D, Node2D, Label, Button, Area2D};
2-
use godot::prelude::*;
31
use crate::ball::Ball;
2+
use godot::classes::{Area2D, Button, INode2D, Label, Node2D};
3+
use godot::prelude::*;
44

55
const SCORE_TO_WIN: i32 = 10;
66

0 commit comments

Comments
 (0)