godot: add initial game
This commit is contained in:
4
game/.editorconfig
Normal file
4
game/.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
57
game/Player.gd
Normal file
57
game/Player.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
const SENSITIVITY = 0.005
|
||||
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
@onready var head = $Head
|
||||
@onready var camera = $Head/Camera3D
|
||||
@onready var dash_timer = $DashTimer
|
||||
@onready var player_debug = $Head/Camera3D/PlayerDebug
|
||||
|
||||
func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
head.rotate_y(-event.relative.x * SENSITIVITY)
|
||||
camera.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-40), deg_to_rad(80))
|
||||
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
if Input.is_action_just_pressed("debug_overlay"):
|
||||
player_debug.visible = !player_debug.visible
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
var direction = (head.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 = 0.0
|
||||
velocity.z = 0.0
|
||||
|
||||
if Input.is_action_just_pressed("dash") and dash_timer.is_stopped():
|
||||
velocity.x = velocity.x * 10
|
||||
velocity.z = velocity.z * 10
|
||||
dash_timer.start()
|
||||
|
||||
if player_debug.visible:
|
||||
player_debug.add_stat("vel_x", str(velocity.x))
|
||||
player_debug.add_stat("vel_y", str(velocity.y))
|
||||
player_debug.add_stat("vel_z", str(velocity.z))
|
||||
player_debug.add_stat("dash_cd", str(dash_timer.time_left))
|
||||
|
||||
move_and_slide()
|
1
game/Player.gd.uid
Normal file
1
game/Player.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://5vty5riyfef2
|
1
game/icon.svg
Normal file
1
game/icon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
After Width: | Height: | Size: 994 B |
37
game/icon.svg.import
Normal file
37
game/icon.svg.import
Normal file
@@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c5q4unny4gqid"
|
||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
44
game/player.tscn
Normal file
44
game/player.tscn
Normal file
@@ -0,0 +1,44 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dkldpdufpl28x"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://5vty5riyfef2" path="res://Player.gd" id="1_4flbx"]
|
||||
[ext_resource type="Script" uid="uid://cad5seggccvp6" path="res://player_debug.gd" id="2_onrkg"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_fj7yv"]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_tlwt5"]
|
||||
points = PackedVector3Array(-0.125207, -0.532801, -0.480507, 0.0227831, 0.47607, 0.498884, 0.169713, 0.559144, 0.464172, 0.231051, -0.803591, 0.320455, 0.40741, 0.651043, -0.243523, -0.482789, 0.594843, 0.0822132, -0.362868, -0.682312, 0.289697, 0.469044, -0.654529, -0.0662713, -0.127444, 0.842701, -0.338103, -0.393435, -0.683942, -0.244717, 0.438255, 0.623309, 0.200849, 0.0841477, 0.977454, 0.114795, -0.0682023, -0.976458, -0.12927, 0.20055, -0.563129, -0.451454, -0.185527, 0.595453, -0.453475, -0.273363, 0.592268, 0.407754, -0.00693649, -0.476823, 0.49966, 0.375821, -0.588614, 0.316955, 0.111579, 0.563059, -0.481177, -0.41725, 0.527866, -0.270497, -0.484546, -0.596972, -0.0665097, -0.279747, 0.908561, 0.0533361, -0.250197, -0.880712, 0.205319, 0.263647, -0.902771, -0.127394, 0.293368, 0.871526, -0.157196, 0.373412, -0.526319, -0.328246, 0.499663, 0.476641, -0.00688856, 0.0531056, 0.875001, 0.324703, -0.154543, -0.590854, 0.465879, -0.0972799, -0.782358, -0.398188, -0.387649, -0.498171, 0.31565, -0.30068, -0.587995, -0.388901)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_4flbx"]
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
visible = false
|
||||
script = ExtResource("1_4flbx")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.035977, 1.01008, 0.068555)
|
||||
mesh = SubResource("CapsuleMesh_fj7yv")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.035977, 1.11008, 0.068555)
|
||||
shape = SubResource("ConvexPolygonShape3D_tlwt5")
|
||||
|
||||
[node name="Head" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00735188, 1.73848, -0.314173)
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Head"]
|
||||
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 1, 0.00688243, 0.00469124, -0.343256)
|
||||
mesh = SubResource("BoxMesh_4flbx")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="Head"]
|
||||
|
||||
[node name="PlayerDebug" type="CanvasLayer" parent="Head/PlayerCamera"]
|
||||
visible = false
|
||||
script = ExtResource("2_onrkg")
|
||||
|
||||
[node name="PlayerDebugText" type="RichTextLabel" parent="Head/PlayerCamera/PlayerDebug"]
|
||||
offset_right = 635.0
|
||||
offset_bottom = 283.0
|
||||
|
||||
[node name="DashTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
15
game/player_debug.gd
Normal file
15
game/player_debug.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var debug_text = $PlayerDebugText
|
||||
|
||||
var stats: Dictionary = {}
|
||||
|
||||
func add_stat(name: String, value: String):
|
||||
stats[name] = value
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
debug_text.clear()
|
||||
for key in stats:
|
||||
var value = stats[key]
|
||||
debug_text.append_text("%s: %s\n" % [key, value])
|
||||
|
1
game/player_debug.gd.uid
Normal file
1
game/player_debug.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cad5seggccvp6
|
54
game/project.godot
Normal file
54
game/project.godot
Normal file
@@ -0,0 +1,54 @@
|
||||
; 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=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="fmm"
|
||||
run/main_scene="uid://co2f5i23gyp03"
|
||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[input]
|
||||
|
||||
move_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"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":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
move_forward={
|
||||
"deadzone": 0.2,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
move_backward={
|
||||
"deadzone": 0.2,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
jump={
|
||||
"deadzone": 0.2,
|
||||
"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
dash={
|
||||
"deadzone": 0.2,
|
||||
"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":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
debug_overlay={
|
||||
"deadzone": 0.2,
|
||||
"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":4194332,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
61
game/world.tscn
Normal file
61
game/world.tscn
Normal file
@@ -0,0 +1,61 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://co2f5i23gyp03"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dkldpdufpl28x" path="res://player.tscn" id="1_f3sb7"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_f3sb7"]
|
||||
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_fj7yv"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_f3sb7")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_tlwt5"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_fj7yv")
|
||||
tonemap_mode = 2
|
||||
glow_enabled = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f3sb7"]
|
||||
albedo_color = Color(0.398875, 0.46629, 0.228578, 1)
|
||||
|
||||
[node name="World" type="Node3D"]
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 14.6596, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_tlwt5")
|
||||
|
||||
[node name="Ground" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 1)
|
||||
use_collision = true
|
||||
size = Vector3(100, 1, 100)
|
||||
material = SubResource("StandardMaterial3D_f3sb7")
|
||||
|
||||
[node name="Wall1" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.61707, -49.5431)
|
||||
size = Vector3(100, 10, 1)
|
||||
|
||||
[node name="Wall2" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.61706, 49.9496)
|
||||
size = Vector3(100, 10, 1)
|
||||
|
||||
[node name="Wall3" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 49.4113, -4.61706, 0.548481)
|
||||
size = Vector3(100, 10, 1)
|
||||
|
||||
[node name="Wall4" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -48.8424, -4.61706, 0.548481)
|
||||
size = Vector3(100, 10, 1)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, -0.970131, 27.9382)
|
||||
size = Vector3(5, 1, 5)
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="Ground"]
|
||||
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 10.554, -2.97013, 27.9382)
|
||||
size = Vector3(5, 5, 5)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_f3sb7")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.55964, 0)
|
Reference in New Issue
Block a user