├── .gitignore ├── 0.11 └── hello_bevy_ecs │ ├── .import │ ├── .gdignore │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.md5 │ └── icon.png-487276ed1e3a0c39cad0279d744ee560.stex │ ├── default_env.tres │ ├── icon.png │ ├── icon.png.import │ ├── project.godot │ ├── scene.gdns │ ├── scene.tscn │ └── scripts │ ├── .gitignore │ ├── Cargo.toml │ └── src │ ├── components │ ├── mod.rs │ └── position.rs │ ├── ecs.rs │ ├── entities │ ├── mod.rs │ ├── player.rs │ └── scene_entity.rs │ ├── lib.rs │ ├── scene.rs │ ├── scheduler │ ├── main_scheduler.rs │ └── mod.rs │ └── systems │ ├── mod.rs │ ├── player_update_system.rs │ └── position_update_system.rs ├── 0.8 ├── basics │ ├── .import │ │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.md5 │ │ └── icon.png-487276ed1e3a0c39cad0279d744ee560.stex │ ├── LICENSE │ ├── controlled.gdns │ ├── default_env.tres │ ├── icon.png │ ├── icon.png.import │ ├── project.godot │ ├── scene.tscn │ ├── scripts │ │ ├── Cargo.toml │ │ ├── controlled │ │ │ ├── .gitignore │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ └── uncontrolled │ │ │ ├── .gitignore │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── lib.rs │ └── uncontrolled.gdns ├── others │ └── template.afdesign └── platformer │ ├── .import │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.md5 │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.stex │ ├── player.png-2dd0af52de4b213777cd8c9df94c0978.md5 │ ├── player.png-2dd0af52de4b213777cd8c9df94c0978.stex │ ├── tiles.png-20e12ed313f9b52ca4483ea23302e684.md5 │ └── tiles.png-20e12ed313f9b52ca4483ea23302e684.stex │ ├── KinematicBody2D.gdns │ ├── default_env.tres │ ├── icon.png │ ├── icon.png.import │ ├── player.png │ ├── player.png.import │ ├── project.godot │ ├── scripts │ ├── Cargo.toml │ └── src │ │ ├── controls.rs │ │ ├── lib.rs │ │ └── player.rs │ ├── tiles.png │ ├── tiles.png.import │ └── tileset.tscn └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | .DS_Store 4 | 5 | /target/ 6 | target 7 | 8 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 9 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 10 | Cargo.lock 11 | 12 | # These are backup files generated by rustfmt 13 | **/*.rs.bk 14 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/.import/.gdignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5: -------------------------------------------------------------------------------- 1 | source_md5="47313fa4c47a9963fddd764e1ec6e4a8" 2 | dest_md5="26ea799ea0a3da9e753b3ebe822e0570" 3 | 4 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.11/hello_bevy_ecs/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.11/hello_bevy_ecs/icon.png -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | [application] 12 | 13 | config/name="hello_bevy_ecs" 14 | run/main_scene="res://scene.tscn" 15 | config/icon="res://icon.png" 16 | 17 | [gui] 18 | 19 | common/drop_mouse_on_gui_input_disabled=true 20 | 21 | [physics] 22 | 23 | common/enable_pause_aware_picking=true 24 | 25 | [rendering] 26 | 27 | quality/driver/driver_name="GLES2" 28 | vram_compression/import_etc=true 29 | vram_compression/import_etc2=false 30 | environment/default_environment="res://default_env.tres" 31 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scene.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [sub_resource type="GDNativeLibrary" id=1] 4 | entry/OSX.64 = "res://scripts/target/debug/libscripts.dylib" 5 | dependency/OSX.64 = [ ] 6 | 7 | [resource] 8 | resource_name = "HelloBevy" 9 | class_name = "HelloBevy" 10 | library = SubResource( 1 ) 11 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scene.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scene.gdns" type="Script" id=1] 4 | 5 | [node name="scene" type="Node2D"] 6 | script = ExtResource( 1 ) 7 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock 3 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "scripts" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | crate-type = ["cdylib"] 10 | 11 | [dependencies] 12 | gdnative = "0.11" 13 | bevy_ecs = "0.8.1" 14 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/components/mod.rs: -------------------------------------------------------------------------------- 1 | mod position; 2 | 3 | pub mod prelude { 4 | pub use super::position::*; 5 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/components/position.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | 3 | #[derive(Component, Debug, Clone)] 4 | pub struct Position { 5 | pub x: f32, 6 | pub y: f32, 7 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/ecs.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | 3 | use super::components::prelude::*; 4 | use super::entities::prelude::*; 5 | use super::scheduler::prelude::*; 6 | 7 | pub struct Ecs { 8 | world: World, 9 | main_scheduler: MainScheduler, 10 | } 11 | 12 | impl Default for Ecs { 13 | fn default() -> Self { 14 | Ecs { 15 | world: World::default(), 16 | main_scheduler: MainScheduler::default(), 17 | } 18 | } 19 | } 20 | 21 | impl Ecs { 22 | pub fn spawn_some_entities(&mut self) { 23 | self.world 24 | .spawn() 25 | .insert(SceneEntity { 26 | name: "First Entity".to_string(), 27 | }) 28 | .insert(Position { x: 40.0, y: 40.0 }); 29 | 30 | self.world 31 | .spawn() 32 | .insert(SceneEntity { 33 | name: "Second Entity".to_string(), 34 | }) 35 | .insert(Position { x: 80.0, y: 80.0 }); 36 | 37 | self.world 38 | .spawn() 39 | .insert(SceneEntity { 40 | name: "Third Entity".to_string(), 41 | }) 42 | .insert(Position { x: 0.0, y: 0.0 }); 43 | 44 | self.world 45 | .spawn() 46 | .insert(PlayerEntity {}) 47 | .insert(Position { x: 0.0, y: 0.0 }); 48 | } 49 | 50 | pub fn get_entities(&mut self) -> Vec { 51 | let mut query = self.world.query::<&SceneEntity>(); 52 | 53 | let mut result = Vec::new(); 54 | 55 | for entity in query.iter(&self.world) { 56 | result.push(entity.clone()); 57 | } 58 | 59 | return result; 60 | } 61 | 62 | pub fn update_world(&mut self) { 63 | self.main_scheduler.run(&mut self.world); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/entities/mod.rs: -------------------------------------------------------------------------------- 1 | mod scene_entity; 2 | mod player; 3 | 4 | pub mod prelude { 5 | pub use super::scene_entity::*; 6 | pub use super::player::*; 7 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/entities/player.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | 3 | #[derive(Component, Debug, Clone)] 4 | pub struct PlayerEntity { 5 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/entities/scene_entity.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | 3 | #[derive(Component, Debug, Clone)] 4 | pub struct SceneEntity { 5 | pub name: String, 6 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod scene; 2 | mod ecs; 3 | mod components; 4 | mod entities; 5 | mod systems; 6 | mod scheduler; 7 | 8 | use gdnative::prelude::*; 9 | 10 | use crate::scene::*; 11 | 12 | fn init(handle: InitHandle) { 13 | handle.add_class::(); 14 | } 15 | 16 | godot_init!(init); -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/scene.rs: -------------------------------------------------------------------------------- 1 | use gdnative::prelude::*; 2 | 3 | use crate::ecs::*; 4 | 5 | #[derive(NativeClass)] 6 | #[inherit(Node)] 7 | pub struct HelloBevy{ 8 | pub ecs: Ecs, 9 | } 10 | 11 | #[methods] 12 | impl HelloBevy { 13 | fn new(_owner: &Node) -> Self { 14 | HelloBevy { 15 | ecs: Ecs::default() 16 | } 17 | } 18 | 19 | #[method] 20 | fn _ready(&mut self) { 21 | self.ecs.spawn_some_entities(); 22 | let entities = self.ecs.get_entities(); 23 | godot_print!("Currently there are {} entities in the ecs", entities.len()) 24 | } 25 | 26 | #[method] 27 | fn _process(&mut self, _: f64) { 28 | self.ecs.update_world(); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/scheduler/main_scheduler.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | 3 | use crate::systems::prelude::*; 4 | 5 | pub struct MainScheduler { 6 | scheduler: Schedule, 7 | } 8 | 9 | impl Default for MainScheduler { 10 | fn default() -> Self { 11 | let mut scheduler = Schedule::default(); 12 | scheduler.add_stage( 13 | "update_stage", 14 | SystemStage::single_threaded(), 15 | ); 16 | 17 | scheduler.add_system_to_stage("update_stage", scene_entity_position_update_system); 18 | scheduler.add_system_to_stage("update_stage", player_entity_update_system); 19 | 20 | MainScheduler { 21 | scheduler, 22 | } 23 | } 24 | } 25 | 26 | impl MainScheduler { 27 | pub fn run(&mut self, world: &mut World) { 28 | self.scheduler.run(world); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/scheduler/mod.rs: -------------------------------------------------------------------------------- 1 | mod main_scheduler; 2 | 3 | pub mod prelude { 4 | pub use super::main_scheduler::*; 5 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/systems/mod.rs: -------------------------------------------------------------------------------- 1 | mod position_update_system; 2 | mod player_update_system; 3 | 4 | pub mod prelude { 5 | pub use super::position_update_system::*; 6 | pub use super::player_update_system::*; 7 | } -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/systems/player_update_system.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | use gdnative::prelude::*; 3 | 4 | use crate::components::prelude::*; 5 | use crate::entities::prelude::*; 6 | 7 | pub fn player_entity_update_system(query: Query<(&PlayerEntity, With)>) { 8 | godot_print!("player_entity_update_system start"); 9 | 10 | for (player, _position) in query.iter() { 11 | godot_print!("{:?}", player); 12 | } 13 | 14 | godot_print!("player_entity_update_system end"); 15 | } 16 | -------------------------------------------------------------------------------- /0.11/hello_bevy_ecs/scripts/src/systems/position_update_system.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::prelude::*; 2 | use gdnative::prelude::*; 3 | 4 | use crate::{components::prelude::Position, entities::prelude::SceneEntity}; 5 | 6 | pub fn scene_entity_position_update_system(query: Query<(&SceneEntity, With)>) { 7 | godot_print!("scene_entity_position_update_system start"); 8 | 9 | for entity in query.iter() { 10 | godot_print!("{:?}", entity.0.name); 11 | } 12 | 13 | godot_print!("scene_entity_position_update_system start"); 14 | } 15 | -------------------------------------------------------------------------------- /0.8/basics/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5: -------------------------------------------------------------------------------- 1 | source_md5="47313fa4c47a9963fddd764e1ec6e4a8" 2 | dest_md5="2ded9e7f9060e2b530aab678b135fc5b" 3 | 4 | -------------------------------------------------------------------------------- /0.8/basics/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/basics/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex -------------------------------------------------------------------------------- /0.8/basics/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Georg Strieder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /0.8/basics/controlled.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [sub_resource type="GDNativeLibrary" id=1] 4 | entry/OSX.64 = "res://scripts/target/debug/libcontrolled.dylib" 5 | dependency/OSX.64 = [ ] 6 | 7 | [resource] 8 | resource_name = "Controlled" 9 | class_name = "Controlled" 10 | library = SubResource( 1 ) 11 | -------------------------------------------------------------------------------- /0.8/basics/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /0.8/basics/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/basics/icon.png -------------------------------------------------------------------------------- /0.8/basics/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /0.8/basics/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | 14 | } 15 | 16 | [application] 17 | 18 | config/name="godot-rust" 19 | run/main_scene="res://scene.tscn" 20 | config/icon="res://icon.png" 21 | 22 | [rendering] 23 | 24 | environment/default_environment="res://default_env.tres" 25 | -------------------------------------------------------------------------------- /0.8/basics/scene.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=2] 2 | 3 | [ext_resource path="res://icon.png" type="Texture" id=1] 4 | [ext_resource path="res://uncontrolled.gdns" type="Script" id=2] 5 | [ext_resource path="res://controlled.gdns" type="Script" id=3] 6 | 7 | [node name="Node2D" type="Node2D"] 8 | 9 | [node name="uncontrolled" type="Sprite" parent="."] 10 | position = Vector2( 523, 372 ) 11 | texture = ExtResource( 1 ) 12 | script = ExtResource( 2 ) 13 | 14 | [node name="controlled" type="Sprite" parent="."] 15 | position = Vector2( 523, 223 ) 16 | texture = ExtResource( 1 ) 17 | script = ExtResource( 3 ) 18 | -------------------------------------------------------------------------------- /0.8/basics/scripts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "controlled", 4 | "uncontrolled", 5 | ] 6 | -------------------------------------------------------------------------------- /0.8/basics/scripts/controlled/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /0.8/basics/scripts/controlled/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "controlled" 3 | version = "0.1.0" 4 | authors = ["Schr3da <...@gmail.com>"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | gdnative = "0.8" 10 | 11 | [lib] 12 | crate-type = ["cdylib"] 13 | -------------------------------------------------------------------------------- /0.8/basics/scripts/controlled/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate gdnative; 3 | 4 | use gdnative::GlobalConstants; 5 | 6 | 7 | #[derive(gdnative::NativeClass)] 8 | #[inherit(gdnative::Sprite)] 9 | struct Controlled { 10 | up: bool, 11 | down: bool, 12 | left: bool, 13 | right: bool, 14 | } 15 | 16 | #[gdnative::methods] 17 | impl Controlled { 18 | fn _init(_owner: gdnative::Sprite) -> Self { 19 | Controlled { 20 | up: false, 21 | down: false, 22 | left: false, 23 | right: false, 24 | } 25 | } 26 | 27 | #[export] 28 | unsafe fn _ready(&mut self, _owner: gdnative::Sprite) { 29 | godot_warn!("_ready called"); 30 | } 31 | 32 | #[export] 33 | unsafe fn _input(&mut self, _owner: gdnative::Sprite, event: Option) { 34 | 35 | let e = match event { 36 | Some(e) => { e }, 37 | None => { return; } 38 | }; 39 | 40 | match e.cast::() { 41 | Some(v) => { 42 | let key_code = v.get_scancode(); 43 | let value = v.is_pressed(); 44 | 45 | if key_code == GlobalConstants::KEY_A { 46 | self.left = value; 47 | } 48 | 49 | if key_code == GlobalConstants::KEY_D { 50 | self.right = value; 51 | } 52 | 53 | if key_code == GlobalConstants::KEY_W { 54 | self.up = value; 55 | } 56 | 57 | if key_code == GlobalConstants::KEY_S { 58 | self.down = value; 59 | } 60 | }, 61 | _ => {}, 62 | }; 63 | } 64 | 65 | #[export] 66 | unsafe fn _process(&mut self, mut owner: gdnative::Sprite, _delta: f64) { 67 | let mut pos = owner.get_position(); 68 | 69 | if self.left { 70 | pos.x -= 1.0; 71 | } 72 | 73 | if self.right { 74 | pos.x += 1.0; 75 | } 76 | 77 | if self.up { 78 | pos.y -= 1.0; 79 | } 80 | 81 | if self.down { 82 | pos.y += 1.0; 83 | } 84 | 85 | owner.set_position(pos); 86 | } 87 | } 88 | 89 | fn init(handle: gdnative::init::InitHandle) { 90 | handle.add_class::(); 91 | } 92 | 93 | godot_gdnative_init!(); 94 | godot_nativescript_init!(init); 95 | godot_gdnative_terminate!(); 96 | -------------------------------------------------------------------------------- /0.8/basics/scripts/uncontrolled/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /0.8/basics/scripts/uncontrolled/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uncontrolled" 3 | version = "0.1.0" 4 | authors = ["Schr3da <...@gmail.com>"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | gdnative = "0.8" 10 | 11 | [lib] 12 | crate-type = ["cdylib"] 13 | -------------------------------------------------------------------------------- /0.8/basics/scripts/uncontrolled/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | #[macro_use] 3 | extern crate gdnative; 4 | 5 | use gdnative::init::property::{EnumHint, IntHint, StringHint}; 6 | 7 | #[derive(gdnative::NativeClass)] 8 | #[inherit(gdnative::Sprite)] 9 | struct Uncontrolled {} 10 | 11 | #[gdnative::methods] 12 | impl Uncontrolled { 13 | fn _init(_owner: gdnative::Sprite) -> Self { 14 | Uncontrolled {} 15 | } 16 | 17 | #[export] 18 | unsafe fn _ready(&mut self, mut owner: gdnative::Sprite) { 19 | godot_warn!("_ready called"); 20 | } 21 | 22 | #[export] 23 | unsafe fn _process(&mut self, mut owner: gdnative::Sprite, delta: f64) { 24 | let mut pos = owner.get_position(); 25 | 26 | if (pos.x > 100.0) { 27 | pos.x -= 1.0; 28 | } 29 | 30 | owner.set_position(pos); 31 | } 32 | } 33 | 34 | fn init(handle: gdnative::init::InitHandle) { 35 | handle.add_class::(); 36 | } 37 | 38 | godot_gdnative_init!(); 39 | godot_nativescript_init!(init); 40 | godot_gdnative_terminate!(); 41 | -------------------------------------------------------------------------------- /0.8/basics/uncontrolled.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [sub_resource type="GDNativeLibrary" id=1] 4 | entry/OSX.64 = "res://scripts/target/debug/libuncontrolled.dylib" 5 | dependency/OSX.64 = [ ] 6 | 7 | [resource] 8 | resource_name = "Uncontrolled" 9 | class_name = "Uncontrolled" 10 | library = SubResource( 1 ) 11 | -------------------------------------------------------------------------------- /0.8/others/template.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/others/template.afdesign -------------------------------------------------------------------------------- /0.8/platformer/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5: -------------------------------------------------------------------------------- 1 | source_md5="47313fa4c47a9963fddd764e1ec6e4a8" 2 | dest_md5="2ded9e7f9060e2b530aab678b135fc5b" 3 | 4 | -------------------------------------------------------------------------------- /0.8/platformer/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex -------------------------------------------------------------------------------- /0.8/platformer/.import/player.png-2dd0af52de4b213777cd8c9df94c0978.md5: -------------------------------------------------------------------------------- 1 | source_md5="48eb6b391a7e997a2fa7a56e6204223a" 2 | dest_md5="46eee189d1a828cce2d4ea957484fbbb" 3 | 4 | -------------------------------------------------------------------------------- /0.8/platformer/.import/player.png-2dd0af52de4b213777cd8c9df94c0978.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/.import/player.png-2dd0af52de4b213777cd8c9df94c0978.stex -------------------------------------------------------------------------------- /0.8/platformer/.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.md5: -------------------------------------------------------------------------------- 1 | source_md5="f05b334268a55a1c1c3b9b9d3837f49f" 2 | dest_md5="e429d1027d037fd4b095008be3b9bd07" 3 | 4 | -------------------------------------------------------------------------------- /0.8/platformer/.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex -------------------------------------------------------------------------------- /0.8/platformer/KinematicBody2D.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [sub_resource type="GDNativeLibrary" id=1] 4 | entry/OSX.64 = "res://scripts/target/debug/libscripts.dylib" 5 | dependency/OSX.64 = [ ] 6 | 7 | [resource] 8 | resource_name = "Player" 9 | class_name = "Player" 10 | library = SubResource( 1 ) 11 | -------------------------------------------------------------------------------- /0.8/platformer/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /0.8/platformer/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/icon.png -------------------------------------------------------------------------------- /0.8/platformer/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /0.8/platformer/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/player.png -------------------------------------------------------------------------------- /0.8/platformer/player.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/player.png-2dd0af52de4b213777cd8c9df94c0978.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://player.png" 13 | dest_files=[ "res://.import/player.png-2dd0af52de4b213777cd8c9df94c0978.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=false 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /0.8/platformer/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | 14 | } 15 | 16 | [application] 17 | 18 | config/name="simple-platformer" 19 | run/main_scene="res://tileset.tscn" 20 | config/icon="res://icon.png" 21 | 22 | [rendering] 23 | 24 | environment/default_environment="res://default_env.tres" 25 | -------------------------------------------------------------------------------- /0.8/platformer/scripts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "scripts" 3 | version = "0.1.0" 4 | authors = ["Schr3da "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | gdnative = "0.8" 11 | 12 | [lib] 13 | crate-type = ["cdylib"] 14 | -------------------------------------------------------------------------------- /0.8/platformer/scripts/src/controls.rs: -------------------------------------------------------------------------------- 1 | #[derive(PartialEq)] 2 | pub enum Direction { 3 | None, 4 | Left, 5 | Right, 6 | } 7 | 8 | pub struct KeyboardControls { 9 | pub direction: Direction, 10 | pub jump: bool, 11 | pub left: bool, 12 | pub right: bool, 13 | } 14 | 15 | impl KeyboardControls { 16 | 17 | pub fn new() -> Self { 18 | KeyboardControls { 19 | direction: Direction::None, 20 | jump: false, 21 | left: false, 22 | right: false, 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /0.8/platformer/scripts/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate gdnative; 3 | 4 | mod controls; 5 | mod player; 6 | -------------------------------------------------------------------------------- /0.8/platformer/scripts/src/player.rs: -------------------------------------------------------------------------------- 1 | use crate::controls::{KeyboardControls, Direction}; 2 | 3 | use gdnative::{GlobalConstants, Vector2, InputEvent, InputEventKey, KinematicBody2D}; 4 | 5 | const GRAVITY: f32 = 1000.0; 6 | const MOVEMENT_SPEED: f32 = 5.0; 7 | const JUMP_SPEED: f32 = 400.0; 8 | 9 | #[derive(gdnative::NativeClass)] 10 | #[inherit(gdnative::KinematicBody2D)] 11 | struct Player { 12 | is_jumping: bool, 13 | controls: KeyboardControls, 14 | velocity: Vector2, 15 | } 16 | 17 | #[gdnative::methods] 18 | impl Player { 19 | fn _init(_owner: KinematicBody2D) -> Self { 20 | Player { 21 | is_jumping: false, 22 | controls: KeyboardControls::new(), 23 | velocity: Vector2::new(0.0, 0.0), 24 | } 25 | } 26 | 27 | #[export] 28 | unsafe fn _ready(&mut self, mut owner: KinematicBody2D) { 29 | owner.set_physics_process(true); 30 | } 31 | 32 | #[export] 33 | unsafe fn _input(&mut self, _owner: KinematicBody2D, event: Option) { 34 | let e = match event { 35 | Some(e) => { e }, 36 | None => { return; } 37 | }; 38 | 39 | match e.cast::() { 40 | Some(v) => { 41 | let key_code = v.get_scancode(); 42 | let value = v.is_pressed(); 43 | 44 | if key_code == GlobalConstants::KEY_A { 45 | self.controls.direction = Direction::Left; 46 | self.controls.left = value; 47 | } 48 | 49 | if key_code == GlobalConstants::KEY_D { 50 | self.controls.direction = Direction::Right; 51 | self.controls.right = value; 52 | 53 | } 54 | 55 | if self.is_jumping == false && key_code == GlobalConstants::KEY_SPACE { 56 | self.is_jumping = true; 57 | self.controls.jump = value; 58 | } 59 | }, 60 | _ => {} 61 | }; 62 | } 63 | 64 | #[export] 65 | unsafe fn _physics_process(&mut self, mut owner: KinematicBody2D, delta: f64) { 66 | 67 | if self.controls.left { 68 | self.velocity.x -= MOVEMENT_SPEED; 69 | } 70 | 71 | if self.controls.right { 72 | self.velocity.x += MOVEMENT_SPEED; 73 | } 74 | 75 | if self.controls.left == self.controls.right { 76 | self.velocity.x = 0.0; 77 | } 78 | 79 | if self.controls.jump && owner.is_on_floor() { 80 | self.velocity.y = -JUMP_SPEED; 81 | } 82 | 83 | if self.is_jumping && owner.is_on_floor() { 84 | self.is_jumping = false; 85 | } 86 | 87 | self.velocity.y += GRAVITY * delta as f32; 88 | self.velocity = owner.move_and_slide(self.velocity, Vector2::new(0.0, -1.0), true, 4, 0.785398, true) 89 | } 90 | } 91 | 92 | fn init(handle: gdnative::init::InitHandle) { 93 | handle.add_class::(); 94 | } 95 | 96 | godot_gdnative_init!(); 97 | godot_nativescript_init!(init); 98 | godot_gdnative_terminate!(); 99 | -------------------------------------------------------------------------------- /0.8/platformer/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schr3da/godot-rust-tutorials/69e6caf5c3c17dc3e71900716b71630665118358/0.8/platformer/tiles.png -------------------------------------------------------------------------------- /0.8/platformer/tiles.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://tiles.png" 13 | dest_files=[ "res://.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=false 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /0.8/platformer/tileset.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=14 format=2] 2 | 3 | [ext_resource path="res://tiles.png" type="Texture" id=1] 4 | [ext_resource path="res://player.png" type="Texture" id=2] 5 | [ext_resource path="res://KinematicBody2D.gdns" type="Script" id=3] 6 | 7 | [sub_resource type="ConvexPolygonShape2D" id=1] 8 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 9 | 10 | [sub_resource type="ConvexPolygonShape2D" id=2] 11 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 12 | 13 | [sub_resource type="ConvexPolygonShape2D" id=3] 14 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 15 | 16 | [sub_resource type="ConvexPolygonShape2D" id=4] 17 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 18 | 19 | [sub_resource type="ConvexPolygonShape2D" id=5] 20 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 21 | 22 | [sub_resource type="ConvexPolygonShape2D" id=6] 23 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 24 | 25 | [sub_resource type="ConvexPolygonShape2D" id=7] 26 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 27 | 28 | [sub_resource type="ConvexPolygonShape2D" id=8] 29 | points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 ) 30 | 31 | [sub_resource type="TileSet" id=9] 32 | 0/name = "tiles.png 0" 33 | 0/texture = ExtResource( 1 ) 34 | 0/tex_offset = Vector2( 0, 0 ) 35 | 0/modulate = Color( 1, 1, 1, 1 ) 36 | 0/region = Rect2( 0, 0, 32, 32 ) 37 | 0/tile_mode = 0 38 | 0/occluder_offset = Vector2( 0, 0 ) 39 | 0/navigation_offset = Vector2( 0, 0 ) 40 | 0/shape_offset = Vector2( 0, 0 ) 41 | 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 42 | 0/shape_one_way = false 43 | 0/shape_one_way_margin = 0.0 44 | 0/shapes = [ ] 45 | 0/z_index = 0 46 | 1/name = "tiles.png 1" 47 | 1/texture = ExtResource( 1 ) 48 | 1/tex_offset = Vector2( 0, 0 ) 49 | 1/modulate = Color( 1, 1, 1, 1 ) 50 | 1/region = Rect2( 0, 32, 32, 32 ) 51 | 1/tile_mode = 0 52 | 1/occluder_offset = Vector2( 0, 0 ) 53 | 1/navigation_offset = Vector2( 0, 0 ) 54 | 1/shape_offset = Vector2( 0, 0 ) 55 | 1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 56 | 1/shape = SubResource( 1 ) 57 | 1/shape_one_way = false 58 | 1/shape_one_way_margin = 1.0 59 | 1/shapes = [ { 60 | "autotile_coord": Vector2( 0, 0 ), 61 | "one_way": false, 62 | "one_way_margin": 1.0, 63 | "shape": SubResource( 1 ), 64 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 65 | } ] 66 | 1/z_index = 0 67 | 2/name = "tiles.png 2" 68 | 2/texture = ExtResource( 1 ) 69 | 2/tex_offset = Vector2( 0, 0 ) 70 | 2/modulate = Color( 1, 1, 1, 1 ) 71 | 2/region = Rect2( 32, 32, 32, 32 ) 72 | 2/tile_mode = 0 73 | 2/occluder_offset = Vector2( 0, 0 ) 74 | 2/navigation_offset = Vector2( 0, 0 ) 75 | 2/shape_offset = Vector2( 0, 0 ) 76 | 2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 77 | 2/shape = SubResource( 2 ) 78 | 2/shape_one_way = false 79 | 2/shape_one_way_margin = 1.0 80 | 2/shapes = [ { 81 | "autotile_coord": Vector2( 0, 0 ), 82 | "one_way": false, 83 | "one_way_margin": 1.0, 84 | "shape": SubResource( 2 ), 85 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 86 | } ] 87 | 2/z_index = 0 88 | 3/name = "tiles.png 3" 89 | 3/texture = ExtResource( 1 ) 90 | 3/tex_offset = Vector2( 0, 0 ) 91 | 3/modulate = Color( 1, 1, 1, 1 ) 92 | 3/region = Rect2( 0, 64, 32, 32 ) 93 | 3/tile_mode = 0 94 | 3/occluder_offset = Vector2( 0, 0 ) 95 | 3/navigation_offset = Vector2( 0, 0 ) 96 | 3/shape_offset = Vector2( 0, 0 ) 97 | 3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 98 | 3/shape = SubResource( 3 ) 99 | 3/shape_one_way = false 100 | 3/shape_one_way_margin = 1.0 101 | 3/shapes = [ { 102 | "autotile_coord": Vector2( 0, 0 ), 103 | "one_way": false, 104 | "one_way_margin": 1.0, 105 | "shape": SubResource( 3 ), 106 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 107 | } ] 108 | 3/z_index = 0 109 | 4/name = "tiles.png 4" 110 | 4/texture = ExtResource( 1 ) 111 | 4/tex_offset = Vector2( 0, 0 ) 112 | 4/modulate = Color( 1, 1, 1, 1 ) 113 | 4/region = Rect2( 32, 64, 32, 32 ) 114 | 4/tile_mode = 0 115 | 4/occluder_offset = Vector2( 0, 0 ) 116 | 4/navigation_offset = Vector2( 0, 0 ) 117 | 4/shape_offset = Vector2( 0, 0 ) 118 | 4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 119 | 4/shape = SubResource( 4 ) 120 | 4/shape_one_way = false 121 | 4/shape_one_way_margin = 1.0 122 | 4/shapes = [ { 123 | "autotile_coord": Vector2( 0, 0 ), 124 | "one_way": false, 125 | "one_way_margin": 1.0, 126 | "shape": SubResource( 4 ), 127 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 128 | } ] 129 | 4/z_index = 0 130 | 5/name = "tiles.png 5" 131 | 5/texture = ExtResource( 1 ) 132 | 5/tex_offset = Vector2( 0, 0 ) 133 | 5/modulate = Color( 1, 1, 1, 1 ) 134 | 5/region = Rect2( 64, 32, 32, 32 ) 135 | 5/tile_mode = 0 136 | 5/occluder_offset = Vector2( 0, 0 ) 137 | 5/navigation_offset = Vector2( 0, 0 ) 138 | 5/shape_offset = Vector2( 0, 0 ) 139 | 5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 140 | 5/shape = SubResource( 5 ) 141 | 5/shape_one_way = false 142 | 5/shape_one_way_margin = 1.0 143 | 5/shapes = [ { 144 | "autotile_coord": Vector2( 0, 0 ), 145 | "one_way": false, 146 | "one_way_margin": 1.0, 147 | "shape": SubResource( 5 ), 148 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 149 | } ] 150 | 5/z_index = 0 151 | 6/name = "tiles.png 6" 152 | 6/texture = ExtResource( 1 ) 153 | 6/tex_offset = Vector2( 0, 0 ) 154 | 6/modulate = Color( 1, 1, 1, 1 ) 155 | 6/region = Rect2( 64, 64, 32, 32 ) 156 | 6/tile_mode = 0 157 | 6/occluder_offset = Vector2( 0, 0 ) 158 | 6/navigation_offset = Vector2( 0, 0 ) 159 | 6/shape_offset = Vector2( 0, 0 ) 160 | 6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 161 | 6/shape = SubResource( 6 ) 162 | 6/shape_one_way = false 163 | 6/shape_one_way_margin = 1.0 164 | 6/shapes = [ { 165 | "autotile_coord": Vector2( 0, 0 ), 166 | "one_way": false, 167 | "one_way_margin": 1.0, 168 | "shape": SubResource( 6 ), 169 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 170 | } ] 171 | 6/z_index = 0 172 | 7/name = "tiles.png 7" 173 | 7/texture = ExtResource( 1 ) 174 | 7/tex_offset = Vector2( 0, 0 ) 175 | 7/modulate = Color( 1, 1, 1, 1 ) 176 | 7/region = Rect2( 0, 96, 32, 32 ) 177 | 7/tile_mode = 0 178 | 7/occluder_offset = Vector2( 0, 0 ) 179 | 7/navigation_offset = Vector2( 0, 0 ) 180 | 7/shape_offset = Vector2( 0, 0 ) 181 | 7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 182 | 7/shape = SubResource( 7 ) 183 | 7/shape_one_way = false 184 | 7/shape_one_way_margin = 1.0 185 | 7/shapes = [ { 186 | "autotile_coord": Vector2( 0, 0 ), 187 | "one_way": false, 188 | "one_way_margin": 1.0, 189 | "shape": SubResource( 7 ), 190 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 191 | } ] 192 | 7/z_index = 0 193 | 8/name = "tiles.png 8" 194 | 8/texture = ExtResource( 1 ) 195 | 8/tex_offset = Vector2( 0, 0 ) 196 | 8/modulate = Color( 1, 1, 1, 1 ) 197 | 8/region = Rect2( 32, 96, 32, 32 ) 198 | 8/tile_mode = 0 199 | 8/occluder_offset = Vector2( 0, 0 ) 200 | 8/navigation_offset = Vector2( 0, 0 ) 201 | 8/shape_offset = Vector2( 0, 0 ) 202 | 8/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 203 | 8/shape = SubResource( 8 ) 204 | 8/shape_one_way = false 205 | 8/shape_one_way_margin = 1.0 206 | 8/shapes = [ { 207 | "autotile_coord": Vector2( 0, 0 ), 208 | "one_way": false, 209 | "one_way_margin": 1.0, 210 | "shape": SubResource( 8 ), 211 | "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 212 | } ] 213 | 8/z_index = 0 214 | 9/name = "tiles.png 9" 215 | 9/texture = ExtResource( 1 ) 216 | 9/tex_offset = Vector2( 0, 0 ) 217 | 9/modulate = Color( 1, 1, 1, 1 ) 218 | 9/region = Rect2( 64, 96, 32, 32 ) 219 | 9/tile_mode = 0 220 | 9/occluder_offset = Vector2( 0, 0 ) 221 | 9/navigation_offset = Vector2( 0, 0 ) 222 | 9/shape_offset = Vector2( 0, 0 ) 223 | 9/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 224 | 9/shape_one_way = false 225 | 9/shape_one_way_margin = 0.0 226 | 9/shapes = [ ] 227 | 9/z_index = 0 228 | 229 | [sub_resource type="RectangleShape2D" id=10] 230 | extents = Vector2( 3.91809, 8.00985 ) 231 | 232 | [node name="Node2D" type="Node2D"] 233 | 234 | [node name="TileMap" type="TileMap" parent="."] 235 | tile_set = SubResource( 9 ) 236 | cell_size = Vector2( 32, 32 ) 237 | format = 1 238 | tile_data = PoolIntArray( 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0, 11, 0, 0, 12, 0, 0, 13, 0, 0, 14, 0, 0, 15, 0, 0, 16, 0, 0, 17, 0, 0, 18, 0, 0, 19, 0, 0, 20, 0, 0, 21, 0, 0, 22, 0, 0, 23, 0, 0, 24, 0, 0, 25, 0, 0, 26, 0, 0, 27, 0, 0, 28, 0, 0, 29, 0, 0, 30, 0, 0, 31, 0, 0, 65536, 0, 0, 65537, 0, 0, 65538, 0, 0, 65539, 0, 0, 65540, 0, 0, 65541, 0, 0, 65542, 0, 0, 65543, 0, 0, 65544, 0, 0, 65545, 0, 0, 65546, 0, 0, 65547, 0, 0, 65548, 0, 0, 65549, 0, 0, 65550, 0, 0, 65551, 0, 0, 65552, 0, 0, 65553, 0, 0, 65554, 0, 0, 65555, 0, 0, 65556, 0, 0, 65557, 0, 0, 65558, 0, 0, 65559, 0, 0, 65560, 0, 0, 65561, 0, 0, 65562, 0, 0, 65563, 0, 0, 65564, 0, 0, 65565, 0, 0, 65566, 0, 0, 65567, 0, 0, 131072, 0, 0, 131073, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 0, 0, 131080, 0, 0, 131081, 0, 0, 131082, 0, 0, 131083, 0, 0, 131084, 0, 0, 131085, 0, 0, 131086, 0, 0, 131087, 0, 0, 131088, 0, 0, 131089, 0, 0, 131090, 0, 0, 131091, 0, 0, 131092, 0, 0, 131093, 0, 0, 131094, 0, 0, 131095, 0, 0, 131096, 0, 0, 131097, 0, 0, 131098, 0, 0, 131099, 0, 0, 131100, 0, 0, 131101, 0, 0, 131102, 0, 0, 131103, 0, 0, 196608, 0, 0, 196609, 0, 0, 196610, 0, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 196616, 0, 0, 196617, 0, 0, 196618, 0, 0, 196619, 0, 0, 196620, 0, 0, 196621, 0, 0, 196622, 0, 0, 196623, 0, 0, 196624, 0, 0, 196625, 0, 0, 196626, 0, 0, 196627, 0, 0, 196628, 0, 0, 196629, 0, 0, 196630, 0, 0, 196631, 0, 0, 196632, 0, 0, 196633, 0, 0, 196634, 0, 0, 196635, 0, 0, 196636, 0, 0, 196637, 0, 0, 196638, 0, 0, 196639, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 0, 0, 262147, 0, 0, 262148, 0, 0, 262149, 0, 0, 262150, 0, 0, 262151, 0, 0, 262152, 0, 0, 262153, 0, 0, 262154, 0, 0, 262155, 0, 0, 262156, 0, 0, 262157, 0, 0, 262158, 0, 0, 262159, 0, 0, 262160, 0, 0, 262161, 0, 0, 262162, 0, 0, 262163, 0, 0, 262164, 0, 0, 262165, 0, 0, 262166, 0, 0, 262167, 0, 0, 262168, 0, 0, 262169, 0, 0, 262170, 0, 0, 262171, 0, 0, 262172, 0, 0, 262173, 0, 0, 262174, 0, 0, 262175, 0, 0, 327680, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 327687, 0, 0, 327688, 0, 0, 327689, 0, 0, 327690, 0, 0, 327691, 0, 0, 327692, 0, 0, 327693, 0, 0, 327694, 0, 0, 327695, 0, 0, 327696, 0, 0, 327697, 0, 0, 327698, 0, 0, 327699, 0, 0, 327700, 0, 0, 327701, 0, 0, 327702, 0, 0, 327703, 0, 0, 327704, 0, 0, 327705, 0, 0, 327706, 0, 0, 327707, 0, 0, 327708, 0, 0, 327709, 0, 0, 327710, 0, 0, 327711, 0, 0, 393216, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 393223, 0, 0, 393224, 0, 0, 393225, 0, 0, 393226, 0, 0, 393227, 0, 0, 393228, 0, 0, 393229, 0, 0, 393230, 0, 0, 393231, 0, 0, 393232, 0, 0, 393233, 0, 0, 393234, 0, 0, 393235, 0, 0, 393236, 0, 0, 393237, 0, 0, 393238, 0, 0, 393239, 0, 0, 393240, 0, 0, 393241, 0, 0, 393242, 0, 0, 393243, 0, 0, 393244, 0, 0, 393245, 0, 0, 393246, 0, 0, 393247, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 458758, 0, 0, 458759, 0, 0, 458760, 0, 0, 458761, 0, 0, 458762, 0, 0, 458763, 0, 0, 458764, 0, 0, 458765, 0, 0, 458766, 0, 0, 458767, 0, 0, 458768, 0, 0, 458769, 0, 0, 458770, 0, 0, 458771, 0, 0, 458772, 0, 0, 458773, 0, 0, 458774, 0, 0, 458775, 0, 0, 458776, 0, 0, 458777, 0, 0, 458778, 0, 0, 458779, 0, 0, 458780, 0, 0, 458781, 0, 0, 458782, 0, 0, 458783, 0, 0, 524288, 0, 0, 524289, 0, 0, 524290, 0, 0, 524291, 0, 0, 524292, 0, 0, 524293, 0, 0, 524294, 0, 0, 524295, 0, 0, 524296, 0, 0, 524297, 0, 0, 524298, 0, 0, 524299, 0, 0, 524300, 0, 0, 524301, 0, 0, 524302, 0, 0, 524303, 0, 0, 524304, 0, 0, 524305, 0, 0, 524306, 0, 0, 524307, 0, 0, 524308, 0, 0, 524309, 0, 0, 524310, 0, 0, 524311, 0, 0, 524312, 0, 0, 524313, 0, 0, 524314, 0, 0, 524315, 0, 0, 524316, 0, 0, 524317, 0, 0, 524318, 0, 0, 524319, 0, 0, 589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0, 589837, 0, 0, 589838, 0, 0, 589839, 0, 0, 589840, 0, 0, 589841, 0, 0, 589842, 0, 0, 589843, 0, 0, 589844, 0, 0, 589845, 0, 0, 589846, 0, 0, 589847, 0, 0, 589848, 0, 0, 589849, 0, 0, 589850, 0, 0, 589851, 0, 0, 589852, 0, 0, 589853, 0, 0, 589854, 0, 0, 589855, 0, 0, 655360, 0, 0, 655361, 0, 0, 655362, 0, 0, 655363, 0, 0, 655364, 0, 0, 655365, 0, 0, 655366, 0, 0, 655367, 0, 0, 655368, 0, 0, 655369, 0, 0, 655370, 0, 0, 655371, 0, 0, 655372, 0, 0, 655373, 0, 0, 655374, 0, 0, 655375, 0, 0, 655376, 0, 0, 655377, 0, 0, 655378, 0, 0, 655379, 0, 0, 655380, 0, 0, 655381, 0, 0, 655382, 0, 0, 655383, 0, 0, 655384, 0, 0, 655385, 0, 0, 655386, 0, 0, 655387, 0, 0, 655388, 1, 0, 655389, 2, 0, 655390, 536870913, 0, 655391, 0, 0, 720896, 0, 0, 720897, 0, 0, 720898, 0, 0, 720899, 0, 0, 720900, 0, 0, 720901, 0, 0, 720902, 0, 0, 720903, 0, 0, 720904, 0, 0, 720905, 0, 0, 720906, 0, 0, 720907, 0, 0, 720908, 0, 0, 720909, 0, 0, 720910, 0, 0, 720911, 0, 0, 720912, 0, 0, 720913, 0, 0, 720914, 0, 0, 720915, 0, 0, 720916, 1, 0, 720917, 536870914, 0, 720918, 536870914, 0, 720919, 536870914, 0, 720920, 536870914, 0, 720921, 536870913, 0, 720922, 0, 0, 720923, 0, 0, 720924, 3, 0, 720925, 0, 0, 720926, 536870915, 0, 720927, 0, 0, 786432, 0, 0, 786433, 0, 0, 786434, 0, 0, 786435, 0, 0, 786436, 0, 0, 786437, 0, 0, 786438, 0, 0, 786439, 0, 0, 786440, 0, 0, 786441, 0, 0, 786442, 0, 0, 786443, 0, 0, 786444, 0, 0, 786445, 0, 0, 786446, 0, 0, 786447, 0, 0, 786448, 1, 0, 786449, 536870913, 0, 786450, 0, 0, 786451, 0, 0, 786452, 7, 0, 786453, 536870920, 0, 786454, 536870920, 0, 786455, 536870920, 0, 786456, 536870920, 0, 786457, 536870919, 0, 786458, 0, 0, 786459, 0, 0, 786460, 3, 0, 786461, 0, 0, 786462, 536870915, 0, 786463, 0, 0, 851968, 0, 0, 851969, 0, 0, 851970, 0, 0, 851971, 0, 0, 851972, 0, 0, 851973, 0, 0, 851974, 0, 0, 851975, 0, 0, 851976, 0, 0, 851977, 1, 0, 851978, 2, 0, 851979, 2, 0, 851980, 2, 0, 851981, 536870913, 0, 851982, 0, 0, 851983, 0, 0, 851984, 6, 0, 851985, 536870915, 0, 851986, 0, 0, 851987, 0, 0, 851988, 0, 0, 851989, 1073741833, 0, 851990, 0, 0, 851991, 0, 0, 851992, 0, 0, 851993, 1073741833, 0, 851994, 0, 0, 851995, 0, 0, 851996, 3, 0, 851997, 0, 0, 851998, 536870915, 0, 851999, 0, 0, 917504, 0, 0, 917505, 0, 0, 917506, 1, 0, 917507, 2, 0, 917508, 2, 0, 917509, 2, 0, 917510, 536870913, 0, 917511, 0, 0, 917512, 0, 0, 917513, 1073741827, 0, 917514, 0, 0, 917515, 0, 0, 917516, 0, 0, 917517, 536870915, 0, 917518, 0, 0, 917519, 0, 0, 917520, 6, 0, 917521, 536870915, 0, 917522, 0, 0, 917523, 0, 0, 917524, 0, 0, 917525, 0, 0, 917526, 0, 0, 917527, 0, 0, 917528, 0, 0, 917529, 0, 0, 917530, 0, 0, 917531, 0, 0, 917532, 3, 0, 917533, 0, 0, 917534, 536870915, 0, 917535, 0, 0, 983040, 0, 0, 983041, 0, 0, 983042, 1073741827, 0, 983043, 0, 0, 983044, 0, 0, 983045, 0, 0, 983046, 536870915, 0, 983047, 0, 0, 983048, 0, 0, 983049, 1073741827, 0, 983050, 0, 0, 983051, 0, 0, 983052, 0, 0, 983053, 536870915, 0, 983054, 0, 0, 983055, 0, 0, 983056, 7, 0, 983057, 536870919, 0, 983058, 0, 0, 983059, 0, 0, 983060, 0, 0, 983061, 0, 0, 983062, 0, 0, 983063, 0, 0, 983064, 0, 0, 983065, 0, 0, 983066, 0, 0, 983067, 0, 0, 983068, 7, 0, 983069, 8, 0, 983070, 536870919, 0, 983071, 0, 0, 1048576, 0, 0, 1048577, 0, 0, 1048578, 1073741827, 0, 1048579, 0, 0, 1048580, 0, 0, 1048581, 0, 0, 1048582, 536870915, 0, 1048583, 0, 0, 1048584, 0, 0, 1048585, 7, 0, 1048586, 536870920, 0, 1048587, 536870920, 0, 1048588, 536870920, 0, 1048589, 536870919, 0, 1048590, 0, 0, 1048591, 0, 0, 1048592, 0, 0, 1048593, 0, 0, 1048594, 0, 0, 1048595, 0, 0, 1048596, 0, 0, 1048597, 0, 0, 1048598, 0, 0, 1048599, 0, 0, 1048600, 0, 0, 1048601, 0, 0, 1048602, 0, 0, 1048603, 0, 0, 1048604, 0, 0, 1048605, 0, 0, 1048606, 0, 0, 1048607, 0, 0, 1114112, 0, 0, 1114113, 0, 0, 1114114, 7, 0, 1114115, 1610612738, 0, 1114116, 1610612738, 0, 1114117, 1610612738, 0, 1114118, 536870919, 0, 1114119, 0, 0, 1114120, 0, 0, 1114121, 0, 0, 1114122, 0, 0, 1114123, 0, 0, 1114124, 0, 0, 1114125, 0, 0, 1114126, 0, 0, 1114127, 0, 0, 1114128, 0, 0, 1114129, 0, 0, 1114130, 0, 0, 1114131, 0, 0, 1114132, 0, 0, 1114133, 0, 0, 1114134, 0, 0, 1114135, 0, 0, 1114136, 0, 0, 1114137, 0, 0, 1114138, 0, 0, 1114139, 0, 0, 1114140, 0, 0, 1114141, 0, 0, 1114142, 0, 0, 1114143, 0, 0, 1179648, 0, 0, 1179649, 0, 0, 1179650, 0, 0, 1179651, 0, 0, 1179652, 0, 0, 1179653, 0, 0, 1179654, 0, 0, 1179655, 0, 0, 1179656, 0, 0, 1179657, 0, 0, 1179658, 0, 0, 1179659, 0, 0, 1179660, 0, 0, 1179661, 0, 0, 1179662, 0, 0, 1179663, 0, 0, 1179664, 0, 0, 1179665, 0, 0, 1179666, 0, 0, 1179667, 0, 0, 1179668, 0, 0, 1179669, 0, 0, 1179670, 0, 0, 1179671, 0, 0, 1179672, 0, 0, 1179673, 0, 0, 1179674, 0, 0, 1179675, 0, 0, 1179676, 0, 0, 1179677, 0, 0, 1179678, 0, 0, 1179679, 0, 0 ) 239 | 240 | [node name="KinematicBody2D" type="KinematicBody2D" parent="."] 241 | script = ExtResource( 3 ) 242 | 243 | [node name="player" type="Sprite" parent="KinematicBody2D"] 244 | position = Vector2( 92.8539, 329.645 ) 245 | scale = Vector2( 2.88087, 2.84952 ) 246 | texture = ExtResource( 2 ) 247 | 248 | [node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"] 249 | position = Vector2( 93.1601, 329.645 ) 250 | scale = Vector2( 2.88087, 2.84952 ) 251 | shape = SubResource( 10 ) 252 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # godot-rust-tutorials 2 | This is a tutorial project showing how to use the Rust Programming Language with Godot Game Engine 3 | 4 | Video materials associated with this tutorial project can be found under my youtube channel https://www.youtube.com/user/schr3da 5 | 6 | ## Assets 7 | 8 | Huge Thanks to Adam Saltsman for the free tile assets 9 | https://adamatomic.itch.io/cavernas 10 | 11 | ## Basics 12 | 13 | Basic Setup of GDNative script with Rust 14 | https://youtu.be/6EItG3B-YH4 15 | 16 | Basic Keyboard Controls I 17 | https://youtu.be/qEHrRLLYc3Q 18 | 19 | Basic Keyboard Controls Input II 20 | https://www.youtube.com/watch?v=_Lxr6pAXBsQ 21 | 22 | Basic Debugging GDNative Script with LLDB 23 | https://www.youtube.com/watch?v=aMaT6pyDocg 24 | 25 | Basic File Watcher for Godot Native Script 26 | https://www.youtube.com/watch?v=McNgUqzmQkk 27 | 28 | ## Simple Platformer 29 | 30 | Simple Platformer I (Tilemap) 31 | https://www.youtube.com/watch?v=SIesTvp_ZD8 32 | 33 | Simple Platformer II (Gravity & Collision) 34 | https://www.youtube.com/watch?v=GKIUWbW4G9o&feature=youtu.be 35 | 36 | Simple Platformer III (Movement & Collision) 37 | https://www.youtube.com/watch?v=_n_5MDEquk4 38 | 39 | Simple Platformer IV (Modules extra) 40 | https://www.youtube.com/watch?v=0CUu111YJIk&feature=youtu.be 41 | 42 | ## Entity-Component-System (Bevy ECS) 43 | 44 | Godot & Rust: Entity-Component-System (part I) 45 | https://www.youtube.com/watch?v=83wr4XsnfWc 46 | 47 | Godot & Rust: Entity-Component-System (part II) 48 | https://youtu.be/4One9EvMr_w 49 | 50 | 51 | Godot & Rust: Entity-Component-System (part III) 52 | https://youtu.be/NDFZiB6ssXk 53 | --------------------------------------------------------------------------------