A Quadrilateral Cowboy clone intended to help me learn Game Dev

Attempting to get back to feature parity, working on terminal script rn

+143
+17
rust/src/levels.rs
··· 1 + use godot::prelude::*; 2 + use godot::classes::{Node3D, INode3D}; 3 + 4 + #[derive(GodotClass)] 5 + #[class(base=Node3D)] 6 + pub struct Level1 { 7 + base: Base<Node3D> 8 + } 9 + 10 + #[godot_api] 11 + impl INode3D for Level1 { 12 + fn init(base: Base<Node3D>) -> Self { 13 + Self { 14 + base 15 + } 16 + } 17 + }
+5
rust/src/lib.rs
··· 1 1 use godot::prelude::*; 2 2 3 + mod terminal; 4 + mod main_scene; 5 + mod levels; 6 + mod player_camera; 7 + 3 8 struct TriangularViking; 4 9 5 10 #[gdextension]
+21
rust/src/main_scene.rs
··· 1 + use godot::prelude::*; 2 + use godot::classes::{Node, INode}; 3 + 4 + #[derive(GodotClass)] 5 + #[class(base=Node)] 6 + pub struct MainScene { 7 + base: Base<Node> 8 + } 9 + 10 + #[godot_api] 11 + impl INode for MainScene { 12 + fn init(base: Base<Node>) -> Self { 13 + Self { 14 + base 15 + } 16 + } 17 + 18 + fn ready(&mut self) { 19 + self.base().get_tree().unwrap().change_scene_to_file("res://levels/level1.tscn"); 20 + } 21 + }
+22
rust/src/player_camera.rs
··· 1 + use godot::prelude::*; 2 + use godot::classes::{Camera3D, ICamera3D, Input, input::MouseMode}; 3 + 4 + #[derive(GodotClass)] 5 + #[class(base=Camera3D)] 6 + pub struct PlayerCamera { 7 + base: Base<Camera3D> 8 + } 9 + 10 + #[godot_api] 11 + impl ICamera3D for PlayerCamera { 12 + fn init(base: Base<Camera3D>) -> Self { 13 + Self { 14 + base 15 + } 16 + } 17 + 18 + fn ready(&mut self) { 19 + let mut input = Input::singleton(); 20 + input.set_mouse_mode(MouseMode::CONFINED); 21 + } 22 + }
+78
rust/src/terminal.rs
··· 1 + use godot::prelude::*; 2 + use godot::classes::{Area3D, INode3D, InputEvent, MeshInstance3D, Node3D, SubViewport}; 3 + 4 + #[derive(GodotClass)] 5 + #[class(base=Node3D)] 6 + pub struct Terminal { 7 + base: Base<Node3D>, 8 + /// Used for checking if the mouse is inside the Area3D. 9 + is_mouse_inside: bool, 10 + /// The last processed input touch/mouse event. To calculate relative movement. 11 + last_event_pos2D: Option<Vector2>, 12 + /// The time of the last event in seconds since engine start. 13 + last_event_time: f32, 14 + 15 + node_viewport: Option<Gd<SubViewport>>, 16 + node_quad: Option<Gd<MeshInstance3D>>, 17 + node_area: Option<Gd<Area3D>> 18 + } 19 + 20 + #[godot_api] 21 + impl INode3D for Terminal { 22 + fn init(base: Base<Node3D>) -> Self { 23 + Self { 24 + base, 25 + is_mouse_inside: false, 26 + last_event_pos2D: None, 27 + last_event_time: -1.0, 28 + node_viewport: None, 29 + node_quad: None, 30 + node_area: None 31 + } 32 + } 33 + 34 + fn ready(&mut self) { 35 + self.node_viewport = Some(self.base().get_node_as::<SubViewport>("SubViewport")); 36 + self.node_quad = Some(self.base().get_node_as::<MeshInstance3D>("Quad")); 37 + let mut node_area = Some(self.base().get_node_as::<Area3D>("Quad/Area3D")); 38 + 39 + node_area 40 + .as_mut() 41 + .unwrap() 42 + .signals() 43 + .mouse_entered() 44 + .connect_other(&mut *self, Self::on_mouse_entered); 45 + 46 + node_area 47 + .as_mut() 48 + .unwrap() 49 + .signals() 50 + .mouse_exited() 51 + .connect_other(&mut *self, Self::on_mouse_exited); 52 + 53 + node_area 54 + .as_mut() 55 + .unwrap() 56 + .signals() 57 + .input_event() 58 + .connect_other(&mut *self, Self::mouse_input_event); 59 + } 60 + 61 + fn unhandled_input(&mut self, event: Gd<InputEvent>) { 62 + 63 + } 64 + } 65 + 66 + impl Terminal { 67 + fn on_mouse_entered(&mut self) { 68 + self.is_mouse_inside = true; 69 + } 70 + 71 + fn on_mouse_exited(&mut self) { 72 + self.is_mouse_inside = false; 73 + } 74 + 75 + fn mouse_input_event(&mut self, _camera: Gd<Node>, event: Gd<InputEvent>, event_position: Vector3, _normal: Vector3, _shape_idx: i64) { 76 + 77 + } 78 + }
terminal.glb godot/terminal/terminal.glb