aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-16 21:09:11 +0200
committerLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-16 21:09:11 +0200
commit9c061b9997d0add3298b1230426dd7332b91420f (patch)
treee26c6f23178e6dc3078ddc1948cd37180336e7d4
parent28e29e51e2c48868d0a75586ba3f8d73858342e3 (diff)
download2022-9c061b9997d0add3298b1230426dd7332b91420f.tar.gz
2022-9c061b9997d0add3298b1230426dd7332b91420f.tar.bz2
2022-9c061b9997d0add3298b1230426dd7332b91420f.zip
goal post hitbox and level loader in gd script
-rw-r--r--.gitattributes2
-rw-r--r--godot/native/GoalTriggerBox.gdns8
-rw-r--r--godot/native/game.gdnlib6
-rw-r--r--godot/project.godot26
-rw-r--r--godot/scenes/Game.tscn52
-rw-r--r--godot/scripts/GoalTriggerBox.gd22
-rw-r--r--godot/scripts/LevelLoader.gd30
-rw-r--r--lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dllbin0 -> 397824 bytes
-rw-r--r--rust/src/game.rs1
-rw-r--r--rust/src/goal_trigger.rs30
-rw-r--r--rust/src/lib.rs2
11 files changed, 167 insertions, 12 deletions
diff --git a/.gitattributes b/.gitattributes
index 4257496..24d1f8f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -11,8 +11,6 @@ thirdparty/* linguist-vendored
*.png filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.tza filter=lfs diff=lfs merge=lfs -text
-*.godot filter=lfs diff=lfs merge=lfs -text
*.material filter=lfs diff=lfs merge=lfs -text
*.import filter=lfs diff=lfs merge=lfs -text
-*.tscn filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
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/project.godot b/godot/project.godot
index 199576e..a8f6586 100644
--- a/godot/project.godot
+++ b/godot/project.godot
@@ -1,3 +1,23 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:51efcd6bc26f0e3caf847b2f9c7249d1d9144f428911fc2615a6433d07b3a5a6
-size 529
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+; [section] ; section goes between []
+; param=value ; assign values to parameters
+
+config_version=4
+
+[application]
+
+config/name="code-with-your-friends2022"
+run/main_scene="res://scenes/Game.tscn"
+config/icon="res://assets/godot-ferris-32x32.png"
+
+[gdnative]
+
+singletons=[ ]
+
+[rendering]
+
+environment/default_environment="res://default_env.tres"
diff --git a/godot/scenes/Game.tscn b/godot/scenes/Game.tscn
index 641f17b..68704bb 100644
--- a/godot/scenes/Game.tscn
+++ b/godot/scenes/Game.tscn
@@ -1,3 +1,49 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:fc9007950d7925a994a0292c4879f61a16d8ef7a01bc52bd38e6472489e80e3e
-size 561
+[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]
+
+[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"]
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/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll b/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll
new file mode 100644
index 0000000..04c4295
--- /dev/null
+++ b/lib/x86_64-pc-windows-msvc/code_with_your_friends2022.dll
Binary files differ
diff --git a/rust/src/game.rs b/rust/src/game.rs
index ece5a54..7004f96 100644
--- a/rust/src/game.rs
+++ b/rust/src/game.rs
@@ -41,6 +41,5 @@ impl Game {
// This function will be called in every frame
#[export]
unsafe fn _process(&self, _owner: &Spatial, delta: f64) {
- godot_print!("Inside {} _process(), delta is {}", self.name, delta);
}
}
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 534955f..401b668 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;
use gdnative::prelude::{godot_init, InitHandle};
@@ -12,6 +13,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>();
}
// macros that create the entry-points of the dynamic library.