Skip to content

Commit

Permalink
Typos and Code fixed in GdExt's Hello-World page (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: Refined <[email protected]>
  • Loading branch information
RefinedDev and Refined authored Jul 28, 2023
1 parent 24ada16 commit d36d60a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/gdext/intro/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The `[libraries]` section should be updated to match the paths of your dynamic R
```ini
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.1

[libraries]
linux.debug.x86_64 = "res://../rust/target/debug/lib{myCrate}.so"
Expand Down Expand Up @@ -161,7 +162,7 @@ use godot::engine::Sprite2DVirtual;
#[godot_api]
impl Sprite2DVirtual for Player {
fn init(sprite: Base<Sprite2D>) -> Self {
println!("Hello, world!");
godot_print!("Hello, world!"); // Prints to the Godot console

Self {
speed: 400.0,
Expand Down Expand Up @@ -198,7 +199,9 @@ impl Sprite2DVirtual for Player {
// In GDScript, this would be:
// rotation += angular_speed * delta

self.sprite.rotate(self.angular_speed * delta);
self.sprite.rotate((self.angular_speed * delta) as f32);
// The 'rotate' method requires a f32,
// therefore we convert 'self.angular_speed * delta' which is a f64 to a f32
}
}
```
Expand Down Expand Up @@ -235,13 +238,14 @@ impl Sprite2DVirtual for Player {
// var velocity = Vector2.UP.rotated(rotation) * speed
// position += velocity * delta

self.sprite.rotate(self.angular_speed * delta);
self.sprite.rotate((self.angular_speed * delta) as f32);

let velocity = Vector2::UP.rotated(rotation) * self.speed;
self.sprite.translate(self.velocity * delta);
let rotation = self.sprite.get_rotation();
let velocity = Vector2::UP.rotated(rotation) * self.speed as f32;
self.sprite.translate(velocity * delta as f32);

// or verbose:
// self.sprite.set_position(self.sprite.get_position() + self.velocity * delta);
// self.sprite.set_position(self.sprite.get_position() + velocity * delta as f32);
}
}
```
Expand Down

0 comments on commit d36d60a

Please sign in to comment.