scene manager + first scene + player

This commit is contained in:
2025-01-17 22:11:14 +01:00
parent e555f55e15
commit 148efcb388
5 changed files with 124 additions and 7 deletions

View File

@@ -3,25 +3,26 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://pr42rnokdw6w" uid="uid://pr42rnokdw6w"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://icon.svg" source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
[params] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@@ -31,7 +32,7 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0
svg/scale=1.0 svg/scale=1.0
editor/scale_with_editor_scale=false editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false editor/convert_colors_with_editor_theme=false

View File

@@ -14,3 +14,26 @@ config/name="New Game Project"
run/main_scene="res://scene/scene_manager/scene_manager.tscn" run/main_scene="res://scene/scene_manager/scene_manager.tscn"
config/features=PackedStringArray("4.3", "Forward Plus") config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[input]
up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
]
}
left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}

21
scene/player.tscn Normal file
View File

@@ -0,0 +1,21 @@
[gd_scene load_steps=3 format=3 uid="uid://c74354tlmcg6h"]
[ext_resource type="Script" path="res://script/player.gd" id="1_kjuyr"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_d8bnp"]
[node name="CharacterBody3D" type="CharacterBody3D" node_paths=PackedStringArray("head")]
script = ExtResource("1_kjuyr")
SENSI = 0.002
head = NodePath("head")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_d8bnp")
[node name="head" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.65, 0)
[node name="point_dir" type="Node3D" parent="head"]
transform = Transform3D(1, 7.81702e-05, -0.000170007, -7.81212e-05, 1, 0.000294683, 0.000170029, -0.00029467, 1, 0, 0, -1)
[node name="Camera3D" type="Camera3D" parent="head"]

View File

@@ -1,3 +1,27 @@
[gd_scene format=3 uid="uid://brc445tt624lb"] [gd_scene load_steps=6 format=3 uid="uid://brc445tt624lb"]
[ext_resource type="Texture2D" uid="uid://pr42rnokdw6w" path="res://icon.svg" id="1_hg70h"]
[ext_resource type="PackedScene" uid="uid://c74354tlmcg6h" path="res://scene/player.tscn" id="1_ka8xa"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2quhp"]
albedo_texture = ExtResource("1_hg70h")
[sub_resource type="PlaneMesh" id="PlaneMesh_2hvdi"]
size = Vector2(500, 500)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_0l50f"]
points = PackedVector3Array(-250, 0, -250, -250, 0, 250, 250, 0, -250, 250, 0, 250)
[node name="walk_zone" type="Node3D"] [node name="walk_zone" type="Node3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_2quhp")
mesh = SubResource("PlaneMesh_2hvdi")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
shape = SubResource("ConvexPolygonShape3D_0l50f")
[node name="CharacterBody3D" parent="." instance=ExtResource("1_ka8xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.37761, 10.7052, 2.9378)

48
script/player.gd Normal file
View File

@@ -0,0 +1,48 @@
extends CharacterBody3D
@export var SPEED: float = 10.0
@export var SENSI : float = 0.005
@export_group("Children")
@export var head: Node3D
var life: float = 100
var delay_shot:float = 0
var bullets:int = 11
var reloading:bool = false
var current_time_reloading: float = 0
var bump: Vector3 = Vector3.ZERO
var current_song = 0
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
add_to_group("player")
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
head.rotate_x(-event.relative.y * SENSI)
rotate_y(-event.relative.x * SENSI)
head.rotation.x = clamp(head.rotation.x, -PI/2, PI/2)
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
if velocity.y < 0:
velocity += get_gravity() * delta * 2
else:
velocity += get_gravity() * delta * 3
var input_dir := Input.get_vector("left", "right", "up", "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()