Skip to content

Commit 301282f

Browse files
authored
Merge pull request #804 from godot-rust/qol/crates-readme
Add crates.io ReadMe + docs logo
2 parents dbbd59c + d3cc8b8 commit 301282f

File tree

6 files changed

+94
-4
lines changed

6 files changed

+94
-4
lines changed

ReadMe.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
![logo.png](assets/gdext-ferris.png)
1+
![logo.png](misc/assets/gdext-ferris.png)
22

33
# Rust bindings for Godot 4
44

55
_**[Website]** | **[Book][book]** | **[API Docs]** | [Discord] | [Mastodon] | [Twitter] | [Sponsor]_
66

7-
**gdext** is a library to bind the Rust language to Godot 4.
7+
**gdext** is a library to integrate the Rust language with Godot 4.
88

9-
[Godot] is an open-source game engine, whose version 4 has brought large-scale improvements.
9+
[Godot] is an open-source game engine, focusing on a productive and batteries-included 2D and 3D experience.
1010
Its _GDExtension_ API allows integrating third-party languages and libraries.
1111

1212
If you are looking for a Rust binding for Godot 3 (GDNative API), check out [`gdnative`].
@@ -32,7 +32,7 @@ However, there are still certain things to keep in mind.
3232
> improved ergonomics for existing ones. See also [API stability] in the book.
3333
3434
**Features:** While most Godot features are available, some less commonly used ones are missing. See [#24] for an up-to-date overview.
35-
At this point, there is **no** support for [Android] or [iOS], and [WASM] is experimental. Contributions are very welcome!
35+
At this point, there is little support for [Android] or [iOS], and [Wasm] is experimental. Contributions are very welcome!
3636

3737
**Bugs:** Most undefined behavior related to the FFI layer has been ironed out, but there may still be occasional safety issues. Apart from that,
3838
new additions to the library are typically not feature-complete from the start, but become more robust with feedback and testing over time.

godot/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ authors = ["Bromeon", "godot-rust contributors"]
1111
repository = "https://github.com/godot-rust/gdext"
1212
homepage = "https://godot-rust.github.io"
1313
documentation = "https://docs.rs/godot/0.1.2"
14+
readme = "crate-readme.md"
1415

1516
[features]
1617
custom-godot = ["api-custom"]

godot/crate-readme.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
![logo.png](https://github.com/godot-rust/assets/blob/master/gdext/banner.png?raw=true)
2+
3+
# Rust bindings for Godot 4
4+
5+
_**[Website]** | **[GitHub]** | **[Book]** | **[API Docs]** | [Discord] | [Mastodon] | [Twitter] | [Sponsor]_
6+
7+
The **godot** crate integrates the Rust language with Godot 4.
8+
9+
[Godot] is an open-source game engine, focusing on a productive and batteries-included 2D and 3D experience.
10+
Its _GDExtension_ API allows integrating third-party languages and libraries.
11+
12+
13+
## Philosophy
14+
15+
The Rust binding is an alternative to GDScript, with a focus on type safety, scalability and performance.
16+
17+
The primary goal of this library is to provide a [**pragmatic Rust API**][philosophy] for game developers.
18+
Recurring workflows should be simple and require minimal boilerplate. APIs are designed to be safe and idiomatic Rust wherever possible.
19+
Due to interacting with Godot as a C++ engine, we sometimes follow unconventional approaches to provide a good user experience.
20+
21+
22+
## Example
23+
24+
The following code snippet demonstrates writing a simple Godot class `Player` in Rust.
25+
26+
```rust
27+
use godot::prelude::*;
28+
use godot::classes::{ISprite2D, Sprite2D};
29+
30+
// Declare the Player class inheriting Sprite2D.
31+
#[derive(GodotClass)]
32+
#[class(base=Sprite2D)]
33+
struct Player {
34+
// Inheritance via composition: access to Sprite2D methods.
35+
base: Base<Sprite2D>,
36+
37+
// Other fields.
38+
velocity: Vector2,
39+
hitpoints: i32,
40+
}
41+
42+
// Implement Godot's virtual methods via predefined trait.
43+
#[godot_api]
44+
impl ISprite2D for Player {
45+
// Default constructor (base object is passed in).
46+
fn init(base: Base<Sprite2D>) -> Self {
47+
Player {
48+
base,
49+
velocity: Vector2::ZERO,
50+
hitpoints: 100,
51+
}
52+
}
53+
54+
// Override the `_ready` method.
55+
fn ready(&mut self) {
56+
godot_print!("Player ready!");
57+
}
58+
}
59+
60+
// Implement custom methods that can be called from GDScript.
61+
#[godot_api]
62+
impl Player {
63+
#[func]
64+
fn take_damage(&mut self, damage: i32) {
65+
self.hitpoints -= damage;
66+
godot_print!("Player hit! HP left: {}", self.hitpoints);
67+
}
68+
}
69+
```
70+
71+
## More
72+
73+
For more information, check out our [Website] or [GitHub] page!
74+
75+
76+
[API Docs]: https://godot-rust.github.io/docs/gdext
77+
[Book]: https://godot-rust.github.io/book
78+
[Discord]: https://discord.gg/aKUCJ8rJsc
79+
[GitHub]: https://github.com/godot-rust/gdext
80+
[Godot]: https://godotengine.org
81+
[Mastodon]: https://mastodon.gamedev.place/@GodotRust
82+
[philosophy]: https://godot-rust.github.io/book/contribute/philosophy.html
83+
[Sponsor]: https://github.com/sponsors/Bromeon
84+
[Twitter]: https://twitter.com/GodotRust
85+
[Website]: https://godot-rust.github.io

godot/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
//! The serialized representation underlies **no stability guarantees** and may change at any time, even without a SemVer-breaking change.
116116
//!
117117
118+
#![doc(
119+
html_logo_url = "https://raw.githubusercontent.com/godot-rust/assets/master/gdext/ferris.svg"
120+
)]
121+
118122
#[cfg(doc)]
119123
pub mod __docs;
120124

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)