diff options
-rw-r--r-- | godot/scenes/Game.tscn | 30 | ||||
-rw-r--r-- | godot/scenes/levels/GoalTriggerZone.tscn | 14 | ||||
-rw-r--r-- | godot/scenes/levels/test_scene_movement/TestSceneMovement.tscn | 1 | ||||
-rw-r--r-- | godot/scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn | 10 | ||||
-rw-r--r-- | godot/scenes/objects/Player.tscn | 3 | ||||
-rw-r--r-- | godot/scripts/GoalTriggerBox.gd | 2 | ||||
-rw-r--r-- | godot/scripts/LevelLoader.gd | 27 | ||||
-rw-r--r-- | lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll | bin | 482304 -> 578048 bytes | |||
-rw-r--r-- | rust/src/basic_die.rs | 60 |
9 files changed, 93 insertions, 54 deletions
diff --git a/godot/scenes/Game.tscn b/godot/scenes/Game.tscn index 6d09370..38a4ceb 100644 --- a/godot/scenes/Game.tscn +++ b/godot/scenes/Game.tscn @@ -3,35 +3,16 @@ [ext_resource path="res://native/Game.gdns" type="Script" id=1] [ext_resource path="res://scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn" type="PackedScene" id=2] [ext_resource path="res://scripts/LevelLoader.gd" type="Script" id=3] -[ext_resource path="res://scripts/GoalTriggerBox.gd" type="Script" id=4] - -[sub_resource type="BoxShape" id=1] +[ext_resource path="res://scenes/levels/GoalTriggerZone.tscn" type="PackedScene" id=4] +[ext_resource path="res://scenes/objects/Player.tscn" type="PackedScene" id=5] [sub_resource type="CubeMesh" id=2] [sub_resource type="SphereMesh" id=3] -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://native/Game.gdns" type="Script" id=1] -[ext_resource path="res://scenes/levels/test_scene_movement/TestSceneMovement.tscn" type="PackedScene" id=2] [node name="Game" type="Spatial"] script = ExtResource( 1 ) -[node name="Camera" type="Camera" parent="."] -transform = Transform( -0.538224, 0.336461, -0.772728, 0, 0.916856, 0.399217, 0.842802, 0.214868, -0.493474, -6.58972, 3.31005, -7.31211 ) -current = true -fov = 64.6875 - -[node name="TestSceneUuuhhh" parent="." instance=ExtResource( 2 )] - -[node name="Area2" type="Area" parent="."] -transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0, 0 ) -script = ExtResource( 4 ) - -[node name="CollisionShape" type="CollisionShape" parent="Area2"] -shape = SubResource( 1 ) - [node name="LevelLoader" type="Node" parent="."] script = ExtResource( 3 ) @@ -42,6 +23,8 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.99199, 0 ) mesh = SubResource( 2 ) material/0 = null +[node name="GoalTriggerZone" parent="Level1" instance=ExtResource( 4 )] + [node name="Level2" type="Spatial" parent="."] visible = false @@ -50,5 +33,8 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.99549, 0 ) mesh = SubResource( 3 ) material/0 = null -[connection signal="body_entered" from="Area2" to="Area2" method="_on_Area2_body_entered"] +[node name="PlayerRoot" parent="." instance=ExtResource( 5 )] +input/camera_mouse_sensitivity = Vector2( 0.005, 0.005 ) +input/shoot_sensitivity = 0.005 + [node name="TestScene" parent="." instance=ExtResource( 2 )] diff --git a/godot/scenes/levels/GoalTriggerZone.tscn b/godot/scenes/levels/GoalTriggerZone.tscn new file mode 100644 index 0000000..861db4d --- /dev/null +++ b/godot/scenes/levels/GoalTriggerZone.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://scripts/GoalTriggerBox.gd" type="Script" id=1] + +[sub_resource type="BoxShape" id=1] + +[node name="GoalTriggerZone" type="Area"] +transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0, 0 ) +script = ExtResource( 1 ) + +[node name="CollisionShape" type="CollisionShape" parent="."] +shape = SubResource( 1 ) + +[connection signal="body_entered" from="." to="." method="_on_Area2_body_entered"] diff --git a/godot/scenes/levels/test_scene_movement/TestSceneMovement.tscn b/godot/scenes/levels/test_scene_movement/TestSceneMovement.tscn index d1c08e3..d23236b 100644 --- a/godot/scenes/levels/test_scene_movement/TestSceneMovement.tscn +++ b/godot/scenes/levels/test_scene_movement/TestSceneMovement.tscn @@ -28,4 +28,3 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, -1, -20 ) transform = Transform( 0.766044, 0, 0.642788, 0, 2, 0, -0.642788, 0, 0.766044, 19.47, 0, -14 ) [node name="PlayerRoot" parent="." instance=ExtResource( 3 )] -input/current_buff_index = 1 diff --git a/godot/scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn b/godot/scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn index a8f9003..0e4c8dc 100644 --- a/godot/scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn +++ b/godot/scenes/levels/test_scene_uuuhhh/TestSceneUuuhhh.tscn @@ -1,19 +1,11 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://scenes/levels/test_scene_uuuhhh/Wall.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/levels/test_scene_uuuhhh/Floor.tscn" type="PackedScene" id=2] -[ext_resource path="res://scenes/scripts/roblox-cube.gd" type="Script" id=3] [ext_resource path="res://assets/sounds/Uuhhh.mp3" type="AudioStream" id=4] -[ext_resource path="res://scenes/objects/W8.tscn" type="PackedScene" id=5] [node name="TestScene" type="Spatial"] -[node name="W8" parent="." instance=ExtResource( 5 )] -transform = Transform( 0.990268, 0.0360207, 0.134431, 0, 0.965926, -0.258819, -0.139173, 0.2563, 0.956525, -2.57174, 1.79727, 8.45058 ) -contacts_reported = 3 -contact_monitor = true -script = ExtResource( 3 ) - [node name="Floor" parent="." instance=ExtResource( 2 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0290833, -0.981747, 0.00208664 ) diff --git a/godot/scenes/objects/Player.tscn b/godot/scenes/objects/Player.tscn index 8cfdd6e..cc3662e 100644 --- a/godot/scenes/objects/Player.tscn +++ b/godot/scenes/objects/Player.tscn @@ -10,9 +10,6 @@ camera/camera_clamp = Vector2( 0, -1.3 ) shooting/max_force = 30.0 shooting/up_angle = 0.3 shooting/stopping_velocity = 0.003 -input/camera_mouse_sensitivity = Vector2( 0.003, 0.002 ) -input/shoot_sensitivity = 0.1 -input/current_buff_index = 5 [node name="W8" parent="." instance=ExtResource( 1 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0 ) diff --git a/godot/scripts/GoalTriggerBox.gd b/godot/scripts/GoalTriggerBox.gd index 9281f0f..17e98ad 100644 --- a/godot/scripts/GoalTriggerBox.gd +++ b/godot/scripts/GoalTriggerBox.gd @@ -5,7 +5,7 @@ var loader: Loader = null # Called when the node enters the scene tree for the first time. func _ready(): - loader = get_node("../LevelLoader") + loader = get_node("/root/Game/LevelLoader") # Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/godot/scripts/LevelLoader.gd b/godot/scripts/LevelLoader.gd index 538d4ef..2aec587 100644 --- a/godot/scripts/LevelLoader.gd +++ b/godot/scripts/LevelLoader.gd @@ -2,15 +2,26 @@ extends Node const NUM_LEVELS = 9 +# player node +var player: Spatial = null + +# level control var current_level_id = 0 var levels = [] +# stroke control +var current_strokes = 0 +var strokes_per_level = [] + # Called when the node enters the scene tree for the first time. func _ready(): for i in range(NUM_LEVELS): levels.append(get_node("/root/Game/Level%d" % (i+1))) + current_strokes = 0 levels[0].show() + + player = get_node("/root/Game/PlayerRoot") # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -25,6 +36,20 @@ func load_next_level(): # TODO load main menu return - # TODO teleport the die to the start point + # load next level levels[current_level_id].show() + # save current strokes and reset + strokes_per_level.append(current_strokes) + current_strokes = 0 + + # TODO teleport player back + + +func add_stroke(): + current_strokes += 1 + + +func revoke_stroke(): + current_strokes -= 1 + diff --git a/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll b/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll Binary files differindex 115f39f..9c500ba 100644 --- a/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll +++ b/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll diff --git a/rust/src/basic_die.rs b/rust/src/basic_die.rs index dbcccc8..304df90 100644 --- a/rust/src/basic_die.rs +++ b/rust/src/basic_die.rs @@ -1,6 +1,7 @@ use std::borrow::Borrow; use gdnative::api::*; use gdnative::prelude::*; +use gdnative::core_types::VariantArray; use crate::buff_trait::Buff; use crate::buff_ball::BuffBall; use crate::buff_bounce::BuffBounce; @@ -16,6 +17,7 @@ enum InputState { type SpatialRef = Option<Ref<Spatial>>; +type NodeRef = Option<Ref<Node>>; /// the basic die used by the player #[derive(NativeClass)] @@ -53,6 +55,7 @@ pub struct BasicDie { node_camera_arm_horizontal: SpatialRef, node_camera_arm_vertical: SpatialRef, node_camera: SpatialRef, + node_loader: NodeRef, } #[methods] @@ -86,6 +89,7 @@ impl BasicDie { node_camera_arm_horizontal: None, node_camera_arm_vertical: None, node_camera: None, + node_loader: None, } } @@ -120,10 +124,14 @@ impl BasicDie { self.node_camera_arm_vertical = search_node(&self.node_camera_arm_horizontal, String::from("CameraArmVertical")); self.node_camera = search_node(&self.node_camera_arm_vertical, String::from("Camera")); + // look for the level loader in the hierarchy + self.node_loader = owner.get_node("/root/Game/LevelLoader"); + godot_print!("{:?}", self.node_camera_root); godot_print!("{:?}", self.node_camera_arm_horizontal); godot_print!("{:?}", self.node_camera_arm_vertical); godot_print!("{:?}", self.node_camera); + godot_print!("{:?}", self.node_loader); self.node_die = search_node(&None, String::from("W8")); @@ -173,10 +181,7 @@ impl BasicDie { if matches!(self.input_state, InputState::Moving) && delta_ms > 5000 && self.current_buff_index == 1 { - match self.all_buffs[1] { - Some(ref mut buff) => buff.revert_buff(), - None => {} - } + self.stop_die(_owner); } // detect if the die stops moving @@ -188,14 +193,8 @@ impl BasicDie { if current_vel <= self.stopping_velocity { self.input_state = InputState::Default; godot_print!("Die stopped moving at velocity {} after {} ms", current_vel, delta_ms); - - //deactivate the old buff - godot_print!("Current Buff: {}", self.current_buff_index); - match self.all_buffs[self.current_buff_index as usize] { - Some(ref mut buff) => buff.revert_buff(), - None => {} - } - //TODO: find out which side is up and update the current buff index accordingly + + self.stop_die(_owner); } }; } @@ -361,16 +360,43 @@ impl BasicDie { } }; - // apply the current buff + // actually add the force + die.apply_impulse(die.transform().origin, impulse_dir); + + self.last_shot_time = OS::godot_singleton().get_ticks_msec(); + + // call the stuff in GDScript + match self.node_loader { + Some(loader) => { + let save_loader = loader.assume_safe(); + save_loader.call("add_stroke", &[]); + }, + None => godot_warn!("No node loader assigned"), + } + } + + unsafe fn stop_die(&mut self, owner: &Spatial) { + //deactivate the old buff godot_print!("Current Buff: {}", self.current_buff_index); match self.all_buffs[self.current_buff_index as usize] { - Some(ref mut buff) => buff.execute_buff(), + Some(ref mut buff) => buff.revert_buff(), None => {} } - // actually add the force - die.apply_impulse(die.transform().origin, impulse_dir); + // get the facing direction of the die and determine the next buff based on that + match self.node_die { + Some(die) => { + let forward = die.assume_safe().global_transform().basis.c().normalized(); + godot_print!("forward: {} | {} | {}", forward.x, forward.y, forward.z); + }, + None => {} + } - self.last_shot_time = OS::godot_singleton().get_ticks_msec(); + // apply the current buff + godot_print!("Current Buff: {}", self.current_buff_index); + match self.all_buffs[self.current_buff_index as usize] { + Some(ref mut buff) => buff.execute_buff(), + None => {} + } } } |