Skip to content

Commit 3a20114

Browse files
committed
refactor: reorganize module imports and clean up code formatting
This commit reorganizes module imports for better readability and removes unnecessary whitespace and comments. The changes improve code maintainability without altering functionality.
1 parent 5678638 commit 3a20114

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

squash-the-creeps/rust/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
mod mob;
2-
mod scorelabel;
31
mod main_scene;
2+
mod mob;
43
mod player;
4+
mod scorelabel;
55
use godot::prelude::*;
66

7-
87
struct Scripts;
98

109
#[gdextension]

squash-the-creeps/rust/src/main_scene.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ pub struct MainScene {
2929

3030
#[godot_api]
3131
impl INode for MainScene {
32-
3332
fn ready(&mut self) {
3433
// $UserInterface/Retry.hide()
3534
self.base()
3635
.get_node_as::<ColorRect>("UserInterface/Retry")
3736
.hide();
38-
3937
}
4038
fn unhandled_input(&mut self, event: Gd<InputEvent>) {
4139
// if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
@@ -53,7 +51,6 @@ impl INode for MainScene {
5351
}
5452
#[godot_api]
5553
impl MainScene {
56-
5754
#[func]
5855
fn on_mob_timer_timeout(&mut self) {
5956
// Create mob instance
@@ -69,20 +66,20 @@ impl MainScene {
6966

7067
// Communicate the spawn location and the player's location to the mob.
7168
// var player_position = $Player.position
72-
let player_position = self.base().get_node_as::<player::Player>("Player").get_position();
69+
let player_position = self
70+
.base()
71+
.get_node_as::<player::Player>("Player")
72+
.get_position();
7373

7474
// var mob = mob_scene.instantiate()
7575
let mut mob = self.mob_scene.instantiate_as::<mob::Mob>();
7676

7777
// mob.initialize(mob_spawn_location.position, player_position)
7878
mob.bind_mut()
7979
.initialize(mob_spawn_location.get_position(), player_position);
80-
80+
8181
// mob.squashed.connect($UserInterface/ScoreLabel._on_mob_squashed.bind())
82-
mob.connect(
83-
"squashed",
84-
&self.user_interface.callable("on_mob_squashed"),
85-
);
82+
mob.connect("squashed", &self.user_interface.callable("on_mob_squashed"));
8683

8784
// add_child(mob)
8885
self.base_mut().add_child(&mob);

squash-the-creeps/rust/src/mob.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub struct Mob {
1919

2020
#[godot_api]
2121
impl ICharacterBody3D for Mob {
22-
2322
fn physics_process(&mut self, _delta: f64) {
2423
// move_and_slide()
2524
self.base_mut().move_and_slide();
@@ -68,7 +67,7 @@ impl Mob {
6867
pub fn squash(&mut self) {
6968
// squashed.emit()
7069
self.signals().squashed().emit();
71-
70+
7271
// queue_free()
7372
self.base_mut().queue_free();
7473
}

squash-the-creeps/rust/src/player.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ pub struct Player {
2525
/// The downward acceleration when in the air, in meters per second.
2626
#[export]
2727
fall_acceleration: f32,
28-
28+
2929
/// The target velocity of the character (node property)
3030
#[export]
3131
target_velocity: Vector3,
3232
base: Base<CharacterBody3D>,
3333
}
3434
#[godot_api]
3535
impl ICharacterBody3D for Player {
36-
3736
fn physics_process(&mut self, _delta: f64) {
3837
/*Here, instead of _process(), we're going to make all
3938
calculations using the _physics_process() virtual function.
@@ -45,7 +44,7 @@ impl ICharacterBody3D for Player {
4544
let mut direction = Vector3::ZERO;
4645

4746
let input = Input::singleton();
48-
47+
4948
// if Input.is_action_pressed("move_right"):
5049
if input.is_action_pressed("move_right") {
5150
//direction.x += 1

0 commit comments

Comments
 (0)