diff --git a/Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg.import b/Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg.import index 607b005..e5bd6d2 100644 --- a/Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg.import +++ b/Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://b0bmwarkx2fxb" -path="res://.godot/imported/mpv-shot0001.jpg-4c0b1d2bc221c05906c91de8aef5b655.ctex" +path.s3tc="res://.godot/imported/mpv-shot0001.jpg-4c0b1d2bc221c05906c91de8aef5b655.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg" -dest_files=["res://.godot/imported/mpv-shot0001.jpg-4c0b1d2bc221c05906c91de8aef5b655.ctex"] +dest_files=["res://.godot/imported/mpv-shot0001.jpg-4c0b1d2bc221c05906c91de8aef5b655.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Prototypes/tiredbun-prototype-1/test-scene.tscn b/Prototypes/tiredbun-prototype-1/test-scene.tscn index fba255a..74628ed 100644 --- a/Prototypes/tiredbun-prototype-1/test-scene.tscn +++ b/Prototypes/tiredbun-prototype-1/test-scene.tscn @@ -1,15 +1,15 @@ [gd_scene load_steps=13 format=3 uid="uid://7l1u7y2xvwa6"] -[ext_resource type="Texture2D" path="res://mpv-shot0001.jpg" id="1_ix3x0"] -[ext_resource type="Script" path="res://Player.gd" id="2_fy1jm"] -[ext_resource type="Texture2D" path="res://player/down-go.png" id="3_hrt1y"] -[ext_resource type="Texture2D" path="res://player/down-stay.png" id="4_fjw2y"] -[ext_resource type="Texture2D" path="res://player/lef-go.png" id="5_rxlf0"] -[ext_resource type="Texture2D" path="res://player/lef-stay.png" id="6_rohwl"] -[ext_resource type="Texture2D" path="res://player/right-go.png" id="7_l3vli"] -[ext_resource type="Texture2D" path="res://player/right-stay.png" id="8_ac52e"] -[ext_resource type="Texture2D" path="res://player/up-go.png" id="9_44ip5"] -[ext_resource type="Texture2D" path="res://player/up-stay.png" id="10_ddtxv"] +[ext_resource type="Texture2D" uid="uid://b0bmwarkx2fxb" path="res://Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg" id="1_ix3x0"] +[ext_resource type="Script" path="res://Prototypes/tiredbun-prototype-1/Player.gd" id="2_fy1jm"] +[ext_resource type="Texture2D" uid="uid://bn3ak3pxua6kr" path="res://Prototypes/tiredbun-prototype-1/player/down-go.png" id="3_hrt1y"] +[ext_resource type="Texture2D" uid="uid://oblvfn4a7jgr" path="res://Prototypes/tiredbun-prototype-1/player/down-stay.png" id="4_fjw2y"] +[ext_resource type="Texture2D" uid="uid://cr4m035rj17ob" path="res://Prototypes/tiredbun-prototype-1/player/lef-go.png" id="5_rxlf0"] +[ext_resource type="Texture2D" uid="uid://ryqgr3iw2cna" path="res://Prototypes/tiredbun-prototype-1/player/lef-stay.png" id="6_rohwl"] +[ext_resource type="Texture2D" uid="uid://bp5p8knf7n06i" path="res://Prototypes/tiredbun-prototype-1/player/right-go.png" id="7_l3vli"] +[ext_resource type="Texture2D" uid="uid://d11jduno6wolt" path="res://Prototypes/tiredbun-prototype-1/player/right-stay.png" id="8_ac52e"] +[ext_resource type="Texture2D" uid="uid://bup48pdr00h7a" path="res://Prototypes/tiredbun-prototype-1/player/up-go.png" id="9_44ip5"] +[ext_resource type="Texture2D" uid="uid://jduoxes2e4uh" path="res://Prototypes/tiredbun-prototype-1/player/up-stay.png" id="10_ddtxv"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ggyph"] size = Vector2(60, 60) diff --git a/Prototypes/tiredbun-prototype-2/Player.gd b/Prototypes/tiredbun-prototype-2/Player.gd new file mode 100644 index 0000000..4c1da8a --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/Player.gd @@ -0,0 +1,45 @@ +extends CharacterBody2D + +# Скорость хождения +@export var base_movement_speed = 300.0 + +func _ready(): + pass + +func _physics_process(_delta): + var horizontal_direction = Input.get_axis("ui_left", "ui_right") + var vertical_direction = Input.get_axis("ui_up", "ui_down") + if horizontal_direction: + velocity.x = horizontal_direction * base_movement_speed + if vertical_direction: + velocity.x = velocity.x/2 + # иначе будет складываться скорость по вертикали и горизонтали + else: + velocity.x = move_toward(velocity.x, 0, base_movement_speed) + if vertical_direction: + velocity.y = vertical_direction * base_movement_speed + if horizontal_direction: + velocity.x = velocity.x/2 + # иначе будет складываться скорость по вертикали и горизонтали + else: + velocity.y = move_toward(velocity.y, 0, base_movement_speed) + + # Проверка, куда должен смотреть персонаж + # вертикальная анимация имеет больший приоритет + if horizontal_direction < 0 and !vertical_direction: + $PlayerSprite.animation = "left-go" + if horizontal_direction > 0 and !vertical_direction: + $PlayerSprite.animation = "right-go" + if vertical_direction < 0: + $PlayerSprite.animation = "up-go" + if vertical_direction > 0: + $PlayerSprite.animation = "down-go" + + # Проверка, должна ли играть анимация + if (velocity.x == 0) and (velocity.y == 0): + $PlayerSprite.frame = 0 # поставить анимацию на первый кадр + $PlayerSprite.stop() # остановить анимацию + else: + $PlayerSprite.play() # играть анимацию + + move_and_slide() # Применяет передедвижение diff --git a/Prototypes/tiredbun-prototype-2/Player3D.gd b/Prototypes/tiredbun-prototype-2/Player3D.gd new file mode 100644 index 0000000..d0f2cc4 --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/Player3D.gd @@ -0,0 +1,48 @@ +extends CharacterBody3D + +@export var SPEED = 3.5 +@export var JUMP_VELOCITY = 4.5 + +@export var PlayerSprite: AnimatedSprite2D + +# Get the gravity from the project settings to be synced with RigidBody nodes. +var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") + +func _physics_process(delta): + # Add the gravity. + if not is_on_floor(): + velocity.y -= gravity * delta + + # Handle Jump. (currently removed) + #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. + # TODO: 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) + + if direction.x < 0 and !direction.z: + PlayerSprite.animation = "left-go" + if direction.x > 0 and !direction.z: + PlayerSprite.animation = "right-go" + if direction.z < 0: + PlayerSprite.animation = "up-go" + if direction.z > 0: + PlayerSprite.animation = "down-go" + + # Check if animation should play + if (velocity.x == 0) and (velocity.z == 0): # if not + PlayerSprite.frame = 0 # set to first animation frame + PlayerSprite.stop() # stop animation + else: # if yes + PlayerSprite.play() # play animation + + move_and_slide() # apply changes to position + diff --git a/Prototypes/tiredbun-prototype-2/camera-test.gd b/Prototypes/tiredbun-prototype-2/camera-test.gd new file mode 100644 index 0000000..fe96a44 --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/camera-test.gd @@ -0,0 +1,22 @@ +extends Node3D + +@export var AnimatedSprite: AnimatedSprite2D # 2d sprite +@export var Camera: Camera3D # current camera +@export var CharacterBody: Node3D # 3d object + +# Called every frame. 'delta' is the elapsed time since the previous frame. +# TODO: optimize to ensure it doesn't use CPU when both camera and object is idle +func _process(_delta): + const Z_MULTIPLIER = 10 # number of z indexes that 1m will take + # set 2d sprite z index (render order) to 3d object z coordinate, multiply by Z_MULTIPLIER + AnimatedSprite.z_index = CharacterBody.global_position.z * Z_MULTIPLIER + #print_debug(AnimatedSprite.z_index) + + if not Camera.is_position_behind(CharacterBody.global_position): # if not outide of camera range + AnimatedSprite.global_position = Camera.unproject_position(CharacterBody.global_position) # set sprite position to where 3d object is from camera's POV + var distance = pow(CharacterBody.global_position.distance_to(Camera.global_position),0.25) # calculate distance between camera and 3d object and smooth it out + if distance < 2: + AnimatedSprite.scale = Vector2(2,2) - Vector2(distance,distance) # the more distance the smaller is the scale of sprite + #print_debug(AnimatedSprite.scale) + else: + AnimatedSprite.scale = Vector2(0,0) # is distance big, prevent from going to negative diff --git a/Prototypes/tiredbun-prototype-2/randomBush/1.png b/Prototypes/tiredbun-prototype-2/randomBush/1.png new file mode 100644 index 0000000..a0912b3 Binary files /dev/null and b/Prototypes/tiredbun-prototype-2/randomBush/1.png differ diff --git a/Prototypes/tiredbun-prototype-2/randomBush/1.png.import b/Prototypes/tiredbun-prototype-2/randomBush/1.png.import new file mode 100644 index 0000000..7cfaaa5 --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/randomBush/1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dur4276gi0rkm" +path="res://.godot/imported/1.png-02577de67e305906c53828957662cdef.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Prototypes/tiredbun-prototype-2/randomBush/1.png" +dest_files=["res://.godot/imported/1.png-02577de67e305906c53828957662cdef.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 diff --git a/Prototypes/tiredbun-prototype-2/randomBush/source.svg b/Prototypes/tiredbun-prototype-2/randomBush/source.svg new file mode 100644 index 0000000..e67b70c --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/randomBush/source.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + diff --git a/Prototypes/tiredbun-prototype-2/randomBush/source.svg.import b/Prototypes/tiredbun-prototype-2/randomBush/source.svg.import new file mode 100644 index 0000000..9ae7330 --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/randomBush/source.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcmvv4qcf0pr5" +path="res://.godot/imported/source.svg-68e43a4cd7ad3514ba56973f65b8a350.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Prototypes/tiredbun-prototype-2/randomBush/source.svg" +dest_files=["res://.godot/imported/source.svg-68e43a4cd7ad3514ba56973f65b8a350.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 diff --git a/Prototypes/tiredbun-prototype-2/test_scene_3d.tscn b/Prototypes/tiredbun-prototype-2/test_scene_3d.tscn new file mode 100644 index 0000000..edfde51 --- /dev/null +++ b/Prototypes/tiredbun-prototype-2/test_scene_3d.tscn @@ -0,0 +1,148 @@ +[gd_scene load_steps=21 format=3 uid="uid://c31gp7om5lww4"] + +[ext_resource type="Texture2D" uid="uid://b0bmwarkx2fxb" path="res://Prototypes/tiredbun-prototype-1/mpv-shot0001.jpg" id="1_fbk20"] +[ext_resource type="Script" path="res://Prototypes/tiredbun-prototype-2/camera-test.gd" id="2_4b25q"] +[ext_resource type="Script" path="res://Prototypes/tiredbun-prototype-2/Player3D.gd" id="3_j7jmd"] +[ext_resource type="Texture2D" uid="uid://oblvfn4a7jgr" path="res://Prototypes/tiredbun-prototype-1/player/down-stay.png" id="4_lqg8o"] +[ext_resource type="Texture2D" uid="uid://bn3ak3pxua6kr" path="res://Prototypes/tiredbun-prototype-1/player/down-go.png" id="5_78ws4"] +[ext_resource type="Texture2D" uid="uid://ryqgr3iw2cna" path="res://Prototypes/tiredbun-prototype-1/player/lef-stay.png" id="6_ki7wl"] +[ext_resource type="Texture2D" uid="uid://cr4m035rj17ob" path="res://Prototypes/tiredbun-prototype-1/player/lef-go.png" id="7_c0fx0"] +[ext_resource type="Texture2D" uid="uid://d11jduno6wolt" path="res://Prototypes/tiredbun-prototype-1/player/right-stay.png" id="8_hmhe2"] +[ext_resource type="Texture2D" uid="uid://bp5p8knf7n06i" path="res://Prototypes/tiredbun-prototype-1/player/right-go.png" id="9_ugr25"] +[ext_resource type="Texture2D" uid="uid://jduoxes2e4uh" path="res://Prototypes/tiredbun-prototype-1/player/up-stay.png" id="10_gmxvm"] +[ext_resource type="Texture2D" uid="uid://bup48pdr00h7a" path="res://Prototypes/tiredbun-prototype-1/player/up-go.png" id="11_vwm5d"] +[ext_resource type="Texture2D" uid="uid://dur4276gi0rkm" path="res://Prototypes/tiredbun-prototype-2/randomBush/1.png" id="12_7gptv"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tw6je"] +albedo_texture = ExtResource("1_fbk20") + +[sub_resource type="PlaneMesh" id="PlaneMesh_tet4n"] +material = SubResource("StandardMaterial3D_tw6je") +size = Vector2(10, 10) + +[sub_resource type="BoxShape3D" id="BoxShape3D_3q2fk"] +size = Vector3(10.084, 1, 9.89738) + +[sub_resource type="Environment" id="Environment_vvato"] +background_mode = 1 +background_color = Color(0.729412, 0.729412, 0.729412, 1) +ambient_light_color = Color(1, 1, 1, 1) +ambient_light_energy = 2.85 +reflected_light_source = 1 + +[sub_resource type="SphereShape3D" id="SphereShape3D_1tnpf"] +radius = 0.205485 + +[sub_resource type="SpriteFrames" id="SpriteFrames_ep00u"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("4_lqg8o") +}, { +"duration": 1.0, +"texture": ExtResource("5_78ws4") +}], +"loop": true, +"name": &"down-go", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("6_ki7wl") +}, { +"duration": 1.0, +"texture": ExtResource("7_c0fx0") +}], +"loop": true, +"name": &"left-go", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("8_hmhe2") +}, { +"duration": 1.0, +"texture": ExtResource("9_ugr25") +}], +"loop": true, +"name": &"right-go", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("10_gmxvm") +}, { +"duration": 1.0, +"texture": ExtResource("11_vwm5d") +}], +"loop": true, +"name": &"up-go", +"speed": 5.0 +}] + +[sub_resource type="BoxShape3D" id="BoxShape3D_cns20"] +size = Vector3(0.977401, 0.5, 0.16768) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ev0qv"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("12_7gptv") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[node name="test-scene3d" type="Node3D"] + +[node name="Floor" type="MeshInstance3D" parent="."] +mesh = SubResource("PlaneMesh_tet4n") + +[node name="StaticBody3D" type="StaticBody3D" parent="Floor"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor/StaticBody3D"] +shape = SubResource("BoxShape3D_3q2fk") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_vvato") + +[node name="Player" type="Node3D" parent="." node_paths=PackedStringArray("AnimatedSprite", "Camera", "CharacterBody")] +script = ExtResource("2_4b25q") +AnimatedSprite = NodePath("CharacterBody3D/PlayerSprite") +Camera = NodePath("CharacterBody3D/Camera3D") +CharacterBody = NodePath("CharacterBody3D") + +[node name="CharacterBody3D" type="CharacterBody3D" parent="Player" node_paths=PackedStringArray("PlayerSprite")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) +script = ExtResource("3_j7jmd") +PlayerSprite = NodePath("PlayerSprite") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Player/CharacterBody3D"] +shape = SubResource("SphereShape3D_1tnpf") + +[node name="Camera3D" type="Camera3D" parent="Player/CharacterBody3D"] +transform = Transform3D(1, 0, 0, 0, 0.897405, 0.441208, 0, -0.441208, 0.897405, 0, 1.47635, 2.63733) + +[node name="PlayerSprite" type="AnimatedSprite2D" parent="Player/CharacterBody3D"] +position = Vector2(177, 68) +sprite_frames = SubResource("SpriteFrames_ep00u") +animation = &"down-go" + +[node name="Bush" type="Node3D" parent="." node_paths=PackedStringArray("AnimatedSprite", "Camera", "CharacterBody")] +script = ExtResource("2_4b25q") +AnimatedSprite = NodePath("AnimatedSprite2D") +Camera = NodePath("../Player/CharacterBody3D/Camera3D") +CharacterBody = NodePath("StaticBody3D") + +[node name="StaticBody3D" type="StaticBody3D" parent="Bush"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.85931, 0, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Bush/StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.220076) +shape = SubResource("BoxShape3D_cns20") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Bush"] +position = Vector2(299, 64) +sprite_frames = SubResource("SpriteFrames_ev0qv")