From 6cb10041fb32555ac424ed4609850e99f8d0d81f Mon Sep 17 00:00:00 2001 From: Techwizz Date: Tue, 24 Jan 2023 12:43:19 -0700 Subject: [PATCH] first commit --- .gitattributes | 2 ++ .gitignore | 2 ++ LICENSE | 21 +++++++++++++++++ README.md | 3 +++ characters/teddy/Teddy.gd | 47 ++++++++++++++++++++++++++++++++++++++ icon.svg | 1 + icon.svg.import | 37 ++++++++++++++++++++++++++++++ project.godot | 48 +++++++++++++++++++++++++++++++++++++++ scenes/Teddy.tscn | 22 ++++++++++++++++++ scenes/playground.tscn | 43 +++++++++++++++++++++++++++++++++++ 10 files changed, 226 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 characters/teddy/Teddy.gd create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot create mode 100644 scenes/Teddy.tscn create mode 100644 scenes/playground.tscn diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d53fc9b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Paul Black, Jayden Wilkins + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..78adaab --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Project_Teddy + +The new code. Fun fun. diff --git a/characters/teddy/Teddy.gd b/characters/teddy/Teddy.gd new file mode 100644 index 0000000..7f3a98c --- /dev/null +++ b/characters/teddy/Teddy.gd @@ -0,0 +1,47 @@ +extends CharacterBody3D + + +var SPEED = 5.0 +const JUMP_VELOCITY = 4.5 + +# Get the gravity from the project settings to be synced with RigidBody nodes. +var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") + +@onready var neck := $Neck +@onready var camera := $Neck/Camera3D + +func _unhandled_input(event): + if event is InputEventMouseButton: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + elif event.is_action_pressed("ui_cancel"): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: + if event is InputEventMouseMotion: + neck.rotate_y(-event.relative.x * 0.01) + camera.rotate_x(-event.relative.y * 0.01) + camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-35), deg_to_rad(60)) + +func _physics_process(delta): + # Add the gravity. + if not is_on_floor(): + velocity.y -= 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("player_left", "player_right", "player_forward", "player_backward") + var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() + if Input.is_action_pressed("sprint"): + SPEED = 10.0 + if Input.is_action_just_released("sprint"): + SPEED = 5.0 + 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() diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..c66413e --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d1cyyp3i400mp" +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/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +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 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..b3c9088 --- /dev/null +++ b/project.godot @@ -0,0 +1,48 @@ +; 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="Project Teddy" +run/main_scene="res://scenes/playground.tscn" +config/features=PackedStringArray("4.0", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/mode=3 + +[input] + +player_left={ +"deadzone": 0.5, +"events": [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,"unicode":0,"echo":false,"script":null) +] +} +player_right={ +"deadzone": 0.5, +"events": [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":68,"unicode":0,"echo":false,"script":null) +] +} +player_forward={ +"deadzone": 0.5, +"events": [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":87,"unicode":0,"echo":false,"script":null) +] +} +player_backward={ +"deadzone": 0.5, +"events": [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":83,"unicode":0,"echo":false,"script":null) +] +} +sprint={ +"deadzone": 0.5, +"events": [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":4194325,"unicode":0,"echo":false,"script":null) +] +} diff --git a/scenes/Teddy.tscn b/scenes/Teddy.tscn new file mode 100644 index 0000000..4500213 --- /dev/null +++ b/scenes/Teddy.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://dp1q51kvd8uow"] + +[ext_resource type="Script" path="res://characters/teddy/Teddy.gd" id="1_ywxo5"] + +[sub_resource type="CapsuleMesh" id="CapsuleMesh_qq44a"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_rpt2n"] +size = Vector3(1, 1.99126, 1) + +[node name="Teddy" type="CharacterBody3D"] +script = ExtResource("1_ywxo5") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +mesh = SubResource("CapsuleMesh_qq44a") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("BoxShape3D_rpt2n") + +[node name="Neck" type="Node3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.859224, 0) + +[node name="Camera3D" type="Camera3D" parent="Neck"] diff --git a/scenes/playground.tscn b/scenes/playground.tscn new file mode 100644 index 0000000..e401f5d --- /dev/null +++ b/scenes/playground.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=7 format=3 uid="uid://bpq4yjx2gs3l6"] + +[ext_resource type="PackedScene" uid="uid://dp1q51kvd8uow" path="res://scenes/Teddy.tscn" id="1_p7gbl"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ell6n"] +sky_top_color = Color(0.870588, 0.894118, 0.92549, 1) +sky_horizon_color = Color(0.767647, 0.765779, 0.764623, 1) +ground_horizon_color = Color(0.767647, 0.765779, 0.764623, 1) + +[sub_resource type="Sky" id="Sky_08e8u"] +sky_material = SubResource("ProceduralSkyMaterial_ell6n") + +[sub_resource type="Environment" id="Environment_fnphj"] +background_mode = 2 +sky = SubResource("Sky_08e8u") +tonemap_mode = 2 +glow_enabled = true + +[sub_resource type="PlaneMesh" id="PlaneMesh_gx0jf"] + +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_qgsp1"] +data = PackedVector3Array(1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0, -1, 1, 0, -1) + +[node name="Node3D" type="Node3D"] + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_fnphj") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.0034906, -0.94887, 0.315647, 0, 0.315649, 0.948876, -0.999994, 0.00331215, -0.00110181, 0, 0, 0) +shadow_enabled = true + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(12.0887, 0, 0, 0, 12.0887, 0, 0, 0, 12.0887, 0, 0, 0) +mesh = SubResource("PlaneMesh_gx0jf") + +[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] +shape = SubResource("ConcavePolygonShape3D_qgsp1") + +[node name="Teddy" parent="." instance=ExtResource("1_p7gbl")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.097358, 1.01166, 0.029713)