diff options
-rw-r--r-- | godot/native/GoalTriggerBox.gdns | 8 | ||||
-rw-r--r-- | godot/native/game.gdnlib | 6 | ||||
-rw-r--r-- | godot/scenes/Game.tscn | 45 | ||||
-rw-r--r-- | godot/scripts/GoalTriggerBox.gd | 22 | ||||
-rw-r--r-- | godot/scripts/LevelLoader.gd | 30 | ||||
-rw-r--r-- | rust/src/goal_trigger.rs | 30 | ||||
-rw-r--r-- | rust/src/lib.rs | 2 |
7 files changed, 140 insertions, 3 deletions
diff --git a/godot/native/GoalTriggerBox.gdns b/godot/native/GoalTriggerBox.gdns new file mode 100644 index 0000000..249df19 --- /dev/null +++ b/godot/native/GoalTriggerBox.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://native/game.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "GoalTriggerZone" +class_name = "GoalTriggerZone" +library = ExtResource( 1 ) diff --git a/godot/native/game.gdnlib b/godot/native/game.gdnlib index 439db91..b7c3ec4 100644 --- a/godot/native/game.gdnlib +++ b/godot/native/game.gdnlib @@ -11,14 +11,14 @@ Android.arm64-v8a="res://../lib/aarch64-linux-android/libcode_with_your_friends2 Android.armeabi-v7a="res://../lib/armv7-linux-androideabi/libcode_with_your_friends2022.so" Android.x86="res://../lib/i686-linux-android/libcode_with_your_friends2022.so" Android.x86_64="res://../lib/x86_64-linux-android/libcode_with_your_friends2022.so" -HTML5.wasm32 = "res://../lib/wasm32-unknown-emscripten/code_with_your_friends2022.wasm" +HTML5.wasm32="res://../lib/wasm32-unknown-emscripten/code_with_your_friends2022.wasm" iOS.arm64="res://../lib/aarch64-apple-ios/libcode_with_your_friends2022.a" OSX.64="res://../lib/x86_64-apple-darwin/libcode_with_your_friends2022.dylib" Server.32="res://../lib/i686-unknown-linux-gnu/libcode_with_your_friends2022.so" Server.64="res://../lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so" -# Windows.32="res://../lib/i686-pc-windows-gnu/code_with_your_friends2022.dll" +#Windows.32="res://../lib/i686-pc-windows-gnu/code_with_your_friends2022.dll" Windows.32="res://../lib/i686-pc-windows-msvc/code_with_your_friends2022.dll" -# Windows.64="res://../lib/x86_64-pc-windows-gnu/code_with_your_friends2022.dll" +#Windows.64="res://../lib/x86_64-pc-windows-gnu/code_with_your_friends2022.dll" Windows.64="res://../lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll" X11.32="res://../lib/i686-unknown-linux-gnu/libcode_with_your_friends2022.so" X11.64="res://../lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so" diff --git a/godot/scenes/Game.tscn b/godot/scenes/Game.tscn index 72fef4e..6d09370 100644 --- a/godot/scenes/Game.tscn +++ b/godot/scenes/Game.tscn @@ -1,3 +1,15 @@ +[gd_scene load_steps=8 format=2] + +[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] + +[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] @@ -6,4 +18,37 @@ [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 ) + +[node name="Level1" type="Spatial" parent="."] + +[node name="MeshInstance" type="MeshInstance" parent="Level1"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.99199, 0 ) +mesh = SubResource( 2 ) +material/0 = null + +[node name="Level2" type="Spatial" parent="."] +visible = false + +[node name="MeshInstance" type="MeshInstance" parent="Level2"] +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="TestScene" parent="." instance=ExtResource( 2 )] diff --git a/godot/scripts/GoalTriggerBox.gd b/godot/scripts/GoalTriggerBox.gd new file mode 100644 index 0000000..9281f0f --- /dev/null +++ b/godot/scripts/GoalTriggerBox.gd @@ -0,0 +1,22 @@ +extends Area + +const Loader = preload("res://scripts/LevelLoader.gd") +var loader: Loader = null + +# Called when the node enters the scene tree for the first time. +func _ready(): + loader = get_node("../LevelLoader") + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_Area2_body_entered(body: RigidBody): + # return when body is not a rigidbody + if body == null: + return + + loader.load_next_level() + diff --git a/godot/scripts/LevelLoader.gd b/godot/scripts/LevelLoader.gd new file mode 100644 index 0000000..538d4ef --- /dev/null +++ b/godot/scripts/LevelLoader.gd @@ -0,0 +1,30 @@ +extends Node + +const NUM_LEVELS = 9 + +var current_level_id = 0 +var levels = [] + +# 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))) + + levels[0].show() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func load_next_level(): + levels[current_level_id].hide() + current_level_id = current_level_id + 1 + + if current_level_id >= NUM_LEVELS: + # TODO load main menu + return + + # TODO teleport the die to the start point + levels[current_level_id].show() + diff --git a/rust/src/goal_trigger.rs b/rust/src/goal_trigger.rs new file mode 100644 index 0000000..457eb7b --- /dev/null +++ b/rust/src/goal_trigger.rs @@ -0,0 +1,30 @@ +use gdnative::api::*; +use gdnative::prelude::*; +use gdnative::core_types::VariantArray; +use gdnative::object::*; + +/// The SpinningCube "class" +#[derive(NativeClass)] +#[inherit(Node)] +pub struct GoalTriggerZone { + level_loader: Option<Ref<Node>>, +} + +#[methods] +impl GoalTriggerZone { + fn new(_owner: &Node) -> Self { + GoalTriggerZone { + level_loader: None, + } + } + + #[export] + unsafe fn _ready(&mut self, owner: &Node) { + // TODO get loader + } + + #[export] + fn overlap(&mut self, owner: &Node) { + godot_print!("OVERLAPPED"); + } +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 30f4f2a..1be319a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -5,6 +5,7 @@ mod buff_phase; mod buff_trait; mod buff_ball; mod buff_extra; +pub mod goal_trigger; mod test; mod basic_die; @@ -14,6 +15,7 @@ use gdnative::prelude::{godot_init, InitHandle}; fn init(handle: InitHandle) { handle.add_class::<game::Game>(); handle.add_class::<spinning_cube::SpinningCube>(); + handle.add_class::<goal_trigger::GoalTriggerZone>(); handle.add_class::<test::SpinningCubeReverse>(); handle.add_class::<basic_die::BasicDie>(); } |