diff options
author | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-16 21:09:11 +0200 |
---|---|---|
committer | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-16 21:09:11 +0200 |
commit | 9c061b9997d0add3298b1230426dd7332b91420f (patch) | |
tree | e26c6f23178e6dc3078ddc1948cd37180336e7d4 /godot | |
parent | 28e29e51e2c48868d0a75586ba3f8d73858342e3 (diff) | |
download | 2022-9c061b9997d0add3298b1230426dd7332b91420f.tar.gz 2022-9c061b9997d0add3298b1230426dd7332b91420f.tar.bz2 2022-9c061b9997d0add3298b1230426dd7332b91420f.zip |
goal post hitbox and level loader in gd script
Diffstat (limited to 'godot')
-rw-r--r-- | godot/native/GoalTriggerBox.gdns | 8 | ||||
-rw-r--r-- | godot/native/game.gdnlib | 6 | ||||
-rw-r--r-- | godot/project.godot | 26 | ||||
-rw-r--r-- | godot/scenes/Game.tscn | 52 | ||||
-rw-r--r-- | godot/scripts/GoalTriggerBox.gd | 22 | ||||
-rw-r--r-- | godot/scripts/LevelLoader.gd | 30 |
6 files changed, 135 insertions, 9 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/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() + |