Simple level, simple player

This commit is contained in:
Vojtěch Struhár 2025-02-10 23:34:32 +01:00
parent 0abbcf96ff
commit 0c12992ba4
6 changed files with 427 additions and 1 deletions

File diff suppressed because one or more lines are too long

118
meshlib.tscn Normal file
View File

@ -0,0 +1,118 @@
[gd_scene load_steps=19 format=3 uid="uid://0t5aem4w2jel"]
[ext_resource type="Material" uid="uid://bx6qeabdhq2s" path="res://addons/kenney_prototype_tools/materials/dark/material_01.tres" id="1_rjyms"]
[ext_resource type="Material" uid="uid://i6ttymvfh5li" path="res://addons/kenney_prototype_tools/materials/green/material_09.tres" id="2_df5hk"]
[ext_resource type="Material" uid="uid://cg0b401okvr4w" path="res://addons/kenney_prototype_tools/materials/light/material_08.tres" id="3_bbsu3"]
[ext_resource type="Material" uid="uid://8ylcw0h1lkhg" path="res://addons/kenney_prototype_tools/materials/orange/material_01.tres" id="4_usipr"]
[ext_resource type="Material" uid="uid://cimqcwahb0vnh" path="res://addons/kenney_prototype_tools/materials/purple/material_05.tres" id="5_y3mb2"]
[ext_resource type="Material" uid="uid://bmrckkx3cdrkk" path="res://addons/kenney_prototype_tools/materials/red/material_13.tres" id="6_mkulm"]
[sub_resource type="BoxMesh" id="BoxMesh_orukj"]
material = ExtResource("1_rjyms")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_rjyms"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[sub_resource type="BoxMesh" id="BoxMesh_30w1r"]
material = ExtResource("2_df5hk")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_df5hk"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[sub_resource type="BoxMesh" id="BoxMesh_lnks6"]
material = ExtResource("3_bbsu3")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_bbsu3"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[sub_resource type="BoxMesh" id="BoxMesh_m8ioc"]
material = ExtResource("4_usipr")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_usipr"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[sub_resource type="BoxMesh" id="BoxMesh_ci2kk"]
material = ExtResource("5_y3mb2")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_y3mb2"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[sub_resource type="BoxMesh" id="BoxMesh_7qmby"]
material = ExtResource("6_mkulm")
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_mkulm"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)
[node name="meshlib" type="Node3D"]
[node name="Mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 2.5)
mesh = SubResource("BoxMesh_orukj")
skeleton = NodePath("")
[node name="StaticBody3D" type="StaticBody3D" parent="Mesh"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Mesh/StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_rjyms")
[node name="Mesh2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 4.5)
mesh = SubResource("BoxMesh_30w1r")
skeleton = NodePath("")
[node name="StaticBody3D2" type="StaticBody3D" parent="Mesh2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Mesh2/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_df5hk")
[node name="Mesh3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0.5, 2.5)
mesh = SubResource("BoxMesh_lnks6")
skeleton = NodePath("")
[node name="StaticBody3D3" type="StaticBody3D" parent="Mesh3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D3" type="CollisionShape3D" parent="Mesh3/StaticBody3D3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_bbsu3")
[node name="Mesh4" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0.5, 0.5)
mesh = SubResource("BoxMesh_m8ioc")
skeleton = NodePath("")
[node name="StaticBody3D4" type="StaticBody3D" parent="Mesh4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D4" type="CollisionShape3D" parent="Mesh4/StaticBody3D4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_usipr")
[node name="Mesh5" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0.5, 4.5)
mesh = SubResource("BoxMesh_ci2kk")
skeleton = NodePath("")
[node name="StaticBody3D5" type="StaticBody3D" parent="Mesh5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D5" type="CollisionShape3D" parent="Mesh5/StaticBody3D5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_y3mb2")
[node name="Mesh6" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
mesh = SubResource("BoxMesh_7qmby")
skeleton = NodePath("")
[node name="StaticBody3D6" type="StaticBody3D" parent="Mesh6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, -0.5, -0.5)
[node name="CollisionShape3D6" type="CollisionShape3D" parent="Mesh6/StaticBody3D6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
shape = SubResource("ConvexPolygonShape3D_mkulm")

40
player.gd Normal file
View File

@ -0,0 +1,40 @@
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
const MOUSE_SENSITIVITY = 0.01
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CONFINED_HIDDEN
func _process(delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * MOUSE_SENSITIVITY)
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()

1
player.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://bp1bo57yqtv65

35
portal-mesh.tres Normal file
View File

@ -0,0 +1,35 @@
[gd_resource type="ArrayMesh" load_steps=3 format=4 uid="uid://bqilnvlfws6xh"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_82kw5"]
[sub_resource type="ArrayMesh" id="ArrayMesh_4457b"]
_surfaces = [{
"aabb": AABB(-1.02429, -1.3, -0.2, 2.04857, 2.60001, 0.20001),
"format": 34896613377,
"index_count": 30,
"index_data": PackedByteArray("BwAFAAQABwAEAAYAAQAHAAMAAQAFAAcAAgAEAAAAAgAGAAQAAwAGAAIAAwAHAAYAAAAFAAEAAAAEAAUA"),
"lods": [0.156674, PackedByteArray("AwAFAAAAAQAFAAMAAwAAAAIAAAAFAAEA")],
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 8,
"vertex_data": PackedByteArray("AAD+//v/AAAAAAAA+/8AAP///v/7/wAA/v8AAPv/AACZGWXmAAAAAJkZmRkAAAAAZeZl5gAAAABl5pkZAAAAAA==")
}]
blend_shape_mode = 0
[resource]
resource_name = "room_Plane_001"
_surfaces = [{
"aabb": AABB(-1.02429, -1.3, -0.2, 2.04857, 2.60001, 0.20001),
"attribute_data": PackedByteArray("AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//"),
"format": 34896613399,
"index_count": 30,
"index_data": PackedByteArray("EQALAAgAEQAIAA4AAgASAAYAAgAMABIABAAJAAAABAAPAAkABwAQAAUABwATABAAAQANAAMAAQAKAA0A"),
"lods": [0.156674, PackedByteArray("BgAWAAAAAgAWAAYABgAAAAQAFAAXABUA")],
"material": SubResource("StandardMaterial3D_82kw5"),
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 24,
"vertex_data": PackedByteArray("AAD+//v/SGUAAP7/+/8AagAAAAD7/0hlAAAAAPv/AGr///7/+/9IZf///v/7/wBq/v8AAPv/SGX+/wAA+/8AapkZZeYAAP5/mRll5gAASGWZGWXmAAAAapkZmRkAAP5/mRmZGQAASGWZGZkZAAAAamXmZeYAAP5/ZeZl5gAASGVl5mXmAAAAamXmmRkAAP5/ZeaZGQAASGVl5pkZAAAAagAA/v/7/wBqAAAAAPv/AGqZGZkZAAD1b5kZmRkAAABqAAD/f/9/AAD///9//38AAAAA/3//f///////f/9/////f///AAD/f/9/AAD/f///////f/9/AAD/f///AAD/f/9/////f///////f/9/////fwAA/38AAP///3//fwAA")
}]
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_4457b")

166
prototypes.tres Normal file

File diff suppressed because one or more lines are too long