diff --git a/sidescroller/.editorconfig b/sidescroller/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/sidescroller/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/sidescroller/.gitattributes b/sidescroller/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/sidescroller/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/sidescroller/.gitignore b/sidescroller/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/sidescroller/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/sidescroller/assets/textures/360x360 idle 4.png b/sidescroller/assets/textures/360x360 idle 4.png new file mode 100644 index 0000000..71d87b2 Binary files /dev/null and b/sidescroller/assets/textures/360x360 idle 4.png differ diff --git a/sidescroller/assets/textures/360x360 idle 4.png.import b/sidescroller/assets/textures/360x360 idle 4.png.import new file mode 100644 index 0000000..b450a66 --- /dev/null +++ b/sidescroller/assets/textures/360x360 idle 4.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2vs4ssjqtd2i" +path="res://.godot/imported/360x360 idle 4.png-6f340b4285f1ced246665e4a52a5b3e6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/360x360 idle 4.png" +dest_files=["res://.godot/imported/360x360 idle 4.png-6f340b4285f1ced246665e4a52a5b3e6.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/sidescroller/assets/textures/Player Crouch-Idle 144x144.png b/sidescroller/assets/textures/Player Crouch-Idle 144x144.png new file mode 100644 index 0000000..3512c15 Binary files /dev/null and b/sidescroller/assets/textures/Player Crouch-Idle 144x144.png differ diff --git a/sidescroller/assets/textures/Player Crouch-Idle 144x144.png.import b/sidescroller/assets/textures/Player Crouch-Idle 144x144.png.import new file mode 100644 index 0000000..6c2ef42 --- /dev/null +++ b/sidescroller/assets/textures/Player Crouch-Idle 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://co5l6328i3y76" +path="res://.godot/imported/Player Crouch-Idle 144x144.png-8bb58e8325f4327962c29b68b7d698ef.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/Player Crouch-Idle 144x144.png" +dest_files=["res://.godot/imported/Player Crouch-Idle 144x144.png-8bb58e8325f4327962c29b68b7d698ef.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/sidescroller/assets/textures/Player Idle 144x144.png b/sidescroller/assets/textures/Player Idle 144x144.png new file mode 100644 index 0000000..5abdb4f Binary files /dev/null and b/sidescroller/assets/textures/Player Idle 144x144.png differ diff --git a/sidescroller/assets/textures/Player Idle 144x144.png.import b/sidescroller/assets/textures/Player Idle 144x144.png.import new file mode 100644 index 0000000..a44ca6f --- /dev/null +++ b/sidescroller/assets/textures/Player Idle 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c1my4xbvhsdq8" +path="res://.godot/imported/Player Idle 144x144.png-3347334270aeebf54a15245eeec485a5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/Player Idle 144x144.png" +dest_files=["res://.godot/imported/Player Idle 144x144.png-3347334270aeebf54a15245eeec485a5.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/sidescroller/assets/textures/player air spin 144x144.png b/sidescroller/assets/textures/player air spin 144x144.png new file mode 100644 index 0000000..0ada770 Binary files /dev/null and b/sidescroller/assets/textures/player air spin 144x144.png differ diff --git a/sidescroller/assets/textures/player air spin 144x144.png.import b/sidescroller/assets/textures/player air spin 144x144.png.import new file mode 100644 index 0000000..07eb0ef --- /dev/null +++ b/sidescroller/assets/textures/player air spin 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dletf8p3wr4n4" +path="res://.godot/imported/player air spin 144x144.png-154eb3e2272f4705408bc408cfbdc00c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/player air spin 144x144.png" +dest_files=["res://.godot/imported/player air spin 144x144.png-154eb3e2272f4705408bc408cfbdc00c.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/sidescroller/assets/textures/player crouch-walk 144x144.png b/sidescroller/assets/textures/player crouch-walk 144x144.png new file mode 100644 index 0000000..2ae0676 Binary files /dev/null and b/sidescroller/assets/textures/player crouch-walk 144x144.png differ diff --git a/sidescroller/assets/textures/player crouch-walk 144x144.png.import b/sidescroller/assets/textures/player crouch-walk 144x144.png.import new file mode 100644 index 0000000..9e505a8 --- /dev/null +++ b/sidescroller/assets/textures/player crouch-walk 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cox74najv0828" +path="res://.godot/imported/player crouch-walk 144x144.png-b3233c7c993219b2d16a671bf8f882a8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/player crouch-walk 144x144.png" +dest_files=["res://.godot/imported/player crouch-walk 144x144.png-b3233c7c993219b2d16a671bf8f882a8.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/sidescroller/assets/textures/player fall 144x144.png b/sidescroller/assets/textures/player fall 144x144.png new file mode 100644 index 0000000..8746151 Binary files /dev/null and b/sidescroller/assets/textures/player fall 144x144.png differ diff --git a/sidescroller/assets/textures/player fall 144x144.png.import b/sidescroller/assets/textures/player fall 144x144.png.import new file mode 100644 index 0000000..3179105 --- /dev/null +++ b/sidescroller/assets/textures/player fall 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dvy7cws4egkmh" +path="res://.godot/imported/player fall 144x144.png-f693c452f4368db049be18c7616d7863.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/player fall 144x144.png" +dest_files=["res://.godot/imported/player fall 144x144.png-f693c452f4368db049be18c7616d7863.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/sidescroller/assets/textures/player new jump 144x144.png b/sidescroller/assets/textures/player new jump 144x144.png new file mode 100644 index 0000000..7b42fb2 Binary files /dev/null and b/sidescroller/assets/textures/player new jump 144x144.png differ diff --git a/sidescroller/assets/textures/player new jump 144x144.png.import b/sidescroller/assets/textures/player new jump 144x144.png.import new file mode 100644 index 0000000..991d297 --- /dev/null +++ b/sidescroller/assets/textures/player new jump 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crkx6pt8e4cmc" +path="res://.godot/imported/player new jump 144x144.png-fc8c1e8ae2efcaf0c0c9a0de9b7b7199.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/player new jump 144x144.png" +dest_files=["res://.godot/imported/player new jump 144x144.png-fc8c1e8ae2efcaf0c0c9a0de9b7b7199.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/sidescroller/assets/textures/player run 144x144.png b/sidescroller/assets/textures/player run 144x144.png new file mode 100644 index 0000000..49619c2 Binary files /dev/null and b/sidescroller/assets/textures/player run 144x144.png differ diff --git a/sidescroller/assets/textures/player run 144x144.png.import b/sidescroller/assets/textures/player run 144x144.png.import new file mode 100644 index 0000000..ce497aa --- /dev/null +++ b/sidescroller/assets/textures/player run 144x144.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d11goqqiewsdg" +path="res://.godot/imported/player run 144x144.png-fc5c22f92bafdf1438f84397fd2bc8a2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/player run 144x144.png" +dest_files=["res://.godot/imported/player run 144x144.png-fc5c22f92bafdf1438f84397fd2bc8a2.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/sidescroller/icon.svg b/sidescroller/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/sidescroller/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sidescroller/icon.svg.import b/sidescroller/icon.svg.import new file mode 100644 index 0000000..ef9b47a --- /dev/null +++ b/sidescroller/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://nfa8op27ovg1" +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 diff --git a/sidescroller/project.godot b/sidescroller/project.godot new file mode 100644 index 0000000..3ca3963 --- /dev/null +++ b/sidescroller/project.godot @@ -0,0 +1,52 @@ +; 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="Sidescroller" +run/main_scene="uid://21dnwl0rfjcd" +config/features=PackedStringArray("4.4", "Mobile") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=640 +window/size/viewport_height=360 +window/size/window_width_override=1280 +window/size/window_height_override=720 +window/stretch/mode="canvas_items" + +[input] + +jump={ +"deadzone": 0.2, +"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":32,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_left={ +"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":65,"key_label":0,"unicode":97,"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) +] +} +crouch={ +"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) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +renderer/rendering_method="mobile" diff --git a/sidescroller/resources/360x360 idle 4.png b/sidescroller/resources/360x360 idle 4.png new file mode 100644 index 0000000..71d87b2 Binary files /dev/null and b/sidescroller/resources/360x360 idle 4.png differ diff --git a/sidescroller/resources/360x360 idle 4.png.import b/sidescroller/resources/360x360 idle 4.png.import new file mode 100644 index 0000000..7b07966 --- /dev/null +++ b/sidescroller/resources/360x360 idle 4.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dee2owliuw21p" +path="res://.godot/imported/360x360 idle 4.png-117ef8683eb12d17036155a97c6705d5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/360x360 idle 4.png" +dest_files=["res://.godot/imported/360x360 idle 4.png-117ef8683eb12d17036155a97c6705d5.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/sidescroller/resources/player crouching cshape.tres b/sidescroller/resources/player crouching cshape.tres new file mode 100644 index 0000000..62f787d --- /dev/null +++ b/sidescroller/resources/player crouching cshape.tres @@ -0,0 +1,4 @@ +[gd_resource type="RectangleShape2D" format=3 uid="uid://xplr3bgjsfor"] + +[resource] +size = Vector2(58, 62) diff --git a/sidescroller/resources/player standing cshape.tres b/sidescroller/resources/player standing cshape.tres new file mode 100644 index 0000000..0833b7d --- /dev/null +++ b/sidescroller/resources/player standing cshape.tres @@ -0,0 +1,4 @@ +[gd_resource type="RectangleShape2D" format=3 uid="uid://bsdsjlbi8h6cf"] + +[resource] +size = Vector2(58, 86.5) diff --git a/sidescroller/scenes/Player.tscn b/sidescroller/scenes/Player.tscn new file mode 100644 index 0000000..122fe17 --- /dev/null +++ b/sidescroller/scenes/Player.tscn @@ -0,0 +1,513 @@ +[gd_scene load_steps=21 format=3 uid="uid://c3w3n7ysd02bd"] + +[ext_resource type="Texture2D" uid="uid://c1my4xbvhsdq8" path="res://assets/textures/Player Idle 144x144.png" id="1_p0vlq"] +[ext_resource type="Shape2D" uid="uid://bsdsjlbi8h6cf" path="res://resources/player standing cshape.tres" id="2_khinc"] +[ext_resource type="Texture2D" uid="uid://crkx6pt8e4cmc" path="res://assets/textures/player new jump 144x144.png" id="2_qu4a1"] +[ext_resource type="Texture2D" uid="uid://dvy7cws4egkmh" path="res://assets/textures/player fall 144x144.png" id="3_70d11"] +[ext_resource type="Texture2D" uid="uid://d11goqqiewsdg" path="res://assets/textures/player run 144x144.png" id="4_cw2d6"] +[ext_resource type="Texture2D" uid="uid://dletf8p3wr4n4" path="res://assets/textures/player air spin 144x144.png" id="5_khinc"] +[ext_resource type="Texture2D" uid="uid://cox74najv0828" path="res://assets/textures/player crouch-walk 144x144.png" id="6_70d11"] +[ext_resource type="Texture2D" uid="uid://co5l6328i3y76" path="res://assets/textures/Player Crouch-Idle 144x144.png" id="6_cw2d6"] + +[sub_resource type="GDScript" id="GDScript_khinc"] +script/source = "extends CharacterBody2D +" + +[sub_resource type="Animation" id="Animation_6eyey"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("1_p0vlq")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [10] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} + +[sub_resource type="Animation" id="Animation_cw2d6"] +resource_name = "crouch idle" +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("6_cw2d6")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [10] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +} + +[sub_resource type="Animation" id="Animation_khinc"] +resource_name = "crouch walk" +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("6_70d11")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [10] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +} + +[sub_resource type="Animation" id="Animation_p7iby"] +resource_name = "double jump" +length = 0.55 +step = 0.05 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("5_khinc")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [6] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5] +} + +[sub_resource type="Animation" id="Animation_o4126"] +resource_name = "fall" +length = 0.05 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("3_70d11")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} + +[sub_resource type="Animation" id="Animation_bruh7"] +resource_name = "idle" +length = 0.95 +loop_mode = 1 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("1_p0vlq")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [10] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +} + +[sub_resource type="Animation" id="Animation_d3wef"] +resource_name = "jump" +length = 0.55 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("2_qu4a1")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [6] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5] +} + +[sub_resource type="Animation" id="Animation_lkdrv"] +resource_name = "run" +length = 0.81 +loop_mode = 1 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:texture") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [ExtResource("4_cw2d6")] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite2D:hframes") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [8] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("../Sprite2D:vframes") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [1] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("../Sprite2D:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5, 6, 7] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_0rnld"] +_data = { +&"RESET": SubResource("Animation_6eyey"), +&"crouch idle": SubResource("Animation_cw2d6"), +&"crouch walk": SubResource("Animation_khinc"), +&"double jump": SubResource("Animation_p7iby"), +&"fall": SubResource("Animation_o4126"), +&"idle": SubResource("Animation_bruh7"), +&"jump": SubResource("Animation_d3wef"), +&"run": SubResource("Animation_lkdrv") +} + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_bruh7"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_6eyey"] + +[node name="Player" type="CharacterBody2D"] +script = SubResource("GDScript_khinc") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(4, -48) +texture = ExtResource("1_p0vlq") +hframes = 10 +frame = 1 + +[node name="mainbody" type="CollisionShape2D" parent="."] +position = Vector2(0, -43) +shape = ExtResource("2_khinc") + +[node name="Camera2D" type="Camera2D" parent="."] +position = Vector2(0, -90) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +root_node = NodePath("../Camera2D") +libraries = { +&"": SubResource("AnimationLibrary_0rnld") +} +autoplay = "idle" + +[node name="crouchrc1" type="RayCast2D" parent="."] +position = Vector2(-29, -50) +target_position = Vector2(0, -37) + +[node name="crouchrc2" type="RayCast2D" parent="."] +position = Vector2(29, -50) +target_position = Vector2(0, -37) + +[node name="wallrunrcright1" type="RayCast2D" parent="."] +position = Vector2(0, -22) +target_position = Vector2(150, 0) + +[node name="wallrunrcright2" type="RayCast2D" parent="."] +position = Vector2(0, -97) +target_position = Vector2(150, 0) + +[node name="wallrunrcleft1" type="RayCast2D" parent="."] +position = Vector2(0, -22) +target_position = Vector2(-150, 0) + +[node name="wallrunrcleft2" type="RayCast2D" parent="."] +position = Vector2(0, -97) +target_position = Vector2(-150, 0) + +[node name="floorcheck" type="RayCast2D" parent="."] +position = Vector2(-1.90735e-06, -42) +scale = Vector2(3.5, 1) + +[node name="wallcheck" type="ShapeCast2D" parent="."] +position = Vector2(0, -68) +scale = Vector2(3.4, 1) +shape = SubResource("RectangleShape2D_bruh7") + +[node name="ledgecollision" type="CollisionShape2D" parent="."] +position = Vector2(0, -90) +scale = Vector2(3.4, 1e-05) +shape = SubResource("RectangleShape2D_6eyey") diff --git a/sidescroller/scenes/box.tscn b/sidescroller/scenes/box.tscn new file mode 100644 index 0000000..5cfa9bb --- /dev/null +++ b/sidescroller/scenes/box.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://bnaknh1h8isk0"] + +[sub_resource type="QuadMesh" id="QuadMesh_on5l8"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_on5l8"] +size = Vector2(144, 231) + +[node name="Box" type="StaticBody2D"] + +[node name="MeshInstance2D" type="MeshInstance2D" parent="."] +modulate = Color(0.72817, 0.433509, 0.493915, 1) +position = Vector2(96, 39.125) +scale = Vector2(143.5, 232.25) +mesh = SubResource("QuadMesh_on5l8") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(96, 39.5) +shape = SubResource("RectangleShape2D_on5l8") diff --git a/sidescroller/scenes/character.tscn b/sidescroller/scenes/character.tscn new file mode 100644 index 0000000..40fe77d --- /dev/null +++ b/sidescroller/scenes/character.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://delsecj4na672"] + +[ext_resource type="Texture2D" uid="uid://nfa8op27ovg1" path="res://icon.svg" id="1_lkv7d"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ushfy"] +size = Vector2(63, 125) + +[node name="CharacterBody2D" type="CharacterBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0.5, -66.5) +shape = SubResource("RectangleShape2D_ushfy") + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(0, -66) +scale = Vector2(0.515625, 1) +texture = ExtResource("1_lkv7d") diff --git a/sidescroller/scenes/world.tscn b/sidescroller/scenes/world.tscn new file mode 100644 index 0000000..6a40069 --- /dev/null +++ b/sidescroller/scenes/world.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=6 format=3 uid="uid://21dnwl0rfjcd"] + +[ext_resource type="PackedScene" uid="uid://c3w3n7ysd02bd" path="res://scenes/Player.tscn" id="1_go701"] +[ext_resource type="Script" uid="uid://d2jx8gdq5o5d7" path="res://scripts/player.gd" id="2_5a7ea"] +[ext_resource type="PackedScene" uid="uid://bnaknh1h8isk0" path="res://scenes/box.tscn" id="3_4wyf3"] + +[sub_resource type="QuadMesh" id="QuadMesh_go701"] +size = Vector2(1000, 100) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_go701"] +size = Vector2(1001, 98) + +[node name="World" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_go701")] +position = Vector2(601, 137) +script = ExtResource("2_5a7ea") +speed = 350 +gravity = 40 +jump_force = 800 +fallvelocity_cap = 1000 +max_air_jumps = 1 +crouch_mult = 1 +sprint_mult = 1 + +[node name="Platform" type="StaticBody2D" parent="."] +position = Vector2(604, 135) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="Platform"] +position = Vector2(-35, 194) +mesh = SubResource("QuadMesh_go701") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"] +position = Vector2(-35.5, 194) +shape = SubResource("RectangleShape2D_go701") + +[node name="Platform2" type="StaticBody2D" parent="."] +position = Vector2(2118, 133) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="Platform2"] +position = Vector2(-35, 194) +mesh = SubResource("QuadMesh_go701") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform2"] +position = Vector2(-35.5, 194) +shape = SubResource("RectangleShape2D_go701") + +[node name="Platform3" type="StaticBody2D" parent="."] +position = Vector2(1385, 233) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="Platform3"] +position = Vector2(-35, 194) +mesh = SubResource("QuadMesh_go701") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform3"] +position = Vector2(-35.5, 194) +shape = SubResource("RectangleShape2D_go701") + +[node name="Box" parent="." instance=ExtResource("3_4wyf3")] +position = Vector2(1808, 48) + +[node name="Box2" parent="." instance=ExtResource("3_4wyf3")] +position = Vector2(2500, 121) + +[node name="Box3" parent="." instance=ExtResource("3_4wyf3")] +position = Vector2(2500, -108) diff --git a/sidescroller/scenes/world.tscn1658547053.tmp b/sidescroller/scenes/world.tscn1658547053.tmp new file mode 100644 index 0000000..6a97af4 --- /dev/null +++ b/sidescroller/scenes/world.tscn1658547053.tmp @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=3 uid="uid://21dnwl0rfjcd"] + +[ext_resource type="PackedScene" uid="uid://c3w3n7ysd02bd" path="res://Scenes/Player.tscn" id="1_go701"] +[ext_resource type="Script" uid="uid://d2jx8gdq5o5d7" path="res://Scripts/player.gd" id="2_5a7ea"] + +[node name="World" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_go701")] +script = ExtResource("2_5a7ea") +speed = null +gravity = null diff --git a/sidescroller/scenes/world.tscn1742165030.tmp b/sidescroller/scenes/world.tscn1742165030.tmp new file mode 100644 index 0000000..8af8b4a --- /dev/null +++ b/sidescroller/scenes/world.tscn1742165030.tmp @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://21dnwl0rfjcd"] + +[ext_resource type="PackedScene" uid="uid://c3w3n7ysd02bd" path="res://Scenes/Player.tscn" id="1_go701"] +[ext_resource type="Script" uid="uid://d2jx8gdq5o5d7" path="res://Scripts/player.gd" id="2_5a7ea"] + +[node name="World" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_go701")] +script = ExtResource("2_5a7ea") diff --git a/sidescroller/scenes/world.tscn5787324462.tmp b/sidescroller/scenes/world.tscn5787324462.tmp new file mode 100644 index 0000000..e34444e --- /dev/null +++ b/sidescroller/scenes/world.tscn5787324462.tmp @@ -0,0 +1,32 @@ +[gd_scene load_steps=5 format=3 uid="uid://21dnwl0rfjcd"] + +[ext_resource type="PackedScene" uid="uid://c3w3n7ysd02bd" path="res://scenes/Player.tscn" id="1_go701"] +[ext_resource type="Script" uid="uid://d2jx8gdq5o5d7" path="res://scripts/player.gd" id="2_5a7ea"] + +[sub_resource type="QuadMesh" id="QuadMesh_go701"] +size = Vector2(1000, 100) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_go701"] +size = Vector2(1001, 98) + +[node name="World" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_go701")] +position = Vector2(601, 137) +script = ExtResource("2_5a7ea") +speed = null +gravity = null +jump_force = null +fallvelocity_cap = null +max_air_jumps = null + +[node name="Platform" type="StaticBody2D" parent="."] +position = Vector2(604, 135) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="Platform"] +position = Vector2(-35, 194) +mesh = SubResource("QuadMesh_go701") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"] +position = Vector2(-35.5, 194) +shape = SubResource("RectangleShape2D_go701") diff --git a/sidescroller/scenes/world.tscn5829515682.tmp b/sidescroller/scenes/world.tscn5829515682.tmp new file mode 100644 index 0000000..a8aa557 --- /dev/null +++ b/sidescroller/scenes/world.tscn5829515682.tmp @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=3 uid="uid://21dnwl0rfjcd"] + +[ext_resource type="PackedScene" uid="uid://c3w3n7ysd02bd" path="res://scenes/Player.tscn" id="1_go701"] +[ext_resource type="Script" uid="uid://d2jx8gdq5o5d7" path="res://scripts/player.gd" id="2_5a7ea"] + +[sub_resource type="QuadMesh" id="QuadMesh_go701"] +size = Vector2(1000, 100) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_go701"] +size = Vector2(1001, 98) + +[node name="World" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_go701")] +position = Vector2(601, 137) +script = ExtResource("2_5a7ea") + +[node name="Platform" type="StaticBody2D" parent="."] +position = Vector2(604, 135) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="Platform"] +position = Vector2(-35, 194) +mesh = SubResource("QuadMesh_go701") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"] +position = Vector2(-35.5, 194) +shape = SubResource("RectangleShape2D_go701") diff --git a/sidescroller/scripts/player.gd b/sidescroller/scripts/player.gd new file mode 100644 index 0000000..e7a33a2 --- /dev/null +++ b/sidescroller/scripts/player.gd @@ -0,0 +1,183 @@ +extends CharacterBody2D + +@export var speed = 350 +@export var gravity = 40 +@export var jump_force = 800 +@export var fallvelocity_cap = 1000 # How fast the player can get when falling +@export var max_air_jumps = 1 # Number of total jumps allowed (1 = normal, 2 = double jump) +@export var crouch_mult = 1 +@export var sprint_mult = 1 + +@onready var ap = $AnimationPlayer +@onready var sprite = $Sprite2D +@onready var cshape = $mainbody +@onready var crouch_raycast1 = $crouchrc1 +@onready var crouch_raycast2 = $crouchrc2 +@onready var wallrun_raycast_left1 = $wallrunrcleft1 +@onready var wallrun_raycast_left2 = $wallrunrcleft2 +@onready var wallrun_raycast_right1 = $wallrunrcright1 +@onready var wallrun_raycast_right2 = $wallrunrcright2 +@onready var wallcheck = $wallcheck +@onready var floorcheck = $floorcheck + +var air_jumps_done = 0 +var is_crouching = false +var stuck_under_object = false + +var wallrun_available := true +var wallrun_timer := 0.0 #:= bedeutet, dass der Typ fest festgelegt ist (z.B int, bool etc.) +var wallrun_time := 1 # Dauer des Wallruns in Sekunden +var wallrun_speed := -250.0 # Geschwindigkeit nach oben (negativ wegen y-Achse) +var wallpushoff_force := 450 # Stärke des Abstoßens +var wallpushoff_timer := 0.0 +var wallpushoff_time := 0.5 # dauer des pushoffs +var wallrunning := false +var pushingoffwall := false +var wallrun_direction := 0 # -1 = links, 1 = rechts + +var standing_cshape = preload("res://resources/player standing cshape.tres") +var crouching_cshape = preload("res://resources/player crouching cshape.tres") + +func _process(delta): + pass + +func _physics_process(delta): + var horizontal_direction = Input.get_axis("move_left", "move_right") + + if !is_on_floor(): + velocity.y += gravity + if velocity.y > fallvelocity_cap: + velocity.y = fallvelocity_cap + else: + air_jumps_done = 0 + wallrun_available = true + + if Input.is_action_just_pressed("jump") && Input.is_action_pressed("move_right") && wall_detected_right() && wallrun_available: + start_wallrun(1) + elif Input.is_action_just_pressed("jump") && Input.is_action_pressed("move_left") && wall_detected_left() && wallrun_available: + start_wallrun(-1) + elif Input.is_action_just_pressed("jump"): + if is_on_floor(): + velocity.y = -jump_force + elif air_jumps_done < max_air_jumps: + velocity.y = -jump_force + air_jumps_done += 1 + + if wallrunning: + wallrun_timer += delta + velocity.y = wallrun_speed # Bewegt nach oben + + if wallrun_direction > 0 && !wallrun_raycast_right2.is_colliding(): + ledgedetected() + if wallrun_direction < 1 && !wallrun_raycast_left2.is_colliding(): + ledgedetected() + elif wallrun_timer >= wallrun_time: + wallpushoff() + + elif pushingoffwall: + wallpushoff_timer += delta + velocity.x = speed * 0.3 * horizontal_direction + (-wallrun_direction * wallpushoff_force) + + if wallpushoff_timer >= wallpushoff_time: + pushingoffwall = false + + else: + velocity.x = speed * horizontal_direction * crouch_mult + if horizontal_direction != 0: + switchdirection(horizontal_direction) + + + if Input.is_action_just_pressed("crouch"): + crouch() + elif Input.is_action_just_released("crouch"): + if above_head_empty(): + stand() + else: + if stuck_under_object != true: + stuck_under_object = true + print("player stuck under object") + + if stuck_under_object && above_head_empty(): + if !Input.is_action_pressed("crouch"): + stand() + stuck_under_object = false + + move_and_slide() + + update_animation(horizontal_direction) + +func above_head_empty() -> bool: + var result = !crouch_raycast1.is_colliding() && !crouch_raycast2.is_colliding() + return result + +func wall_detected_left() -> bool: + var result = wallrun_raycast_left1.is_colliding() && wallrun_raycast_left2.is_colliding() + return result + +func wall_detected_right() -> bool: + var result = wallrun_raycast_right1.is_colliding() && wallrun_raycast_right2.is_colliding() + return result + +func start_wallrun(direction: int): + wallrunning = true + wallrun_available = false + wallrun_direction = direction + velocity.x = 1000 * wallrun_direction # An Wand haften + print("start wallrun called") + +func wallpushoff(): + wallrunning = false + pushingoffwall = true + wallpushoff_timer = 0.0 + wallrun_timer = 0.0 + print("stop wallrun called") + +func ledgedetected(): + wallrunning = false + wallrun_timer = 0.0 + +func checkledgegrab() -> bool: + var result = wallcheck.is_colliding() && !floorcheck.is_colliding() && velocity.y == 0 + return result + +func update_animation(horizontal_direction): + if is_on_floor(): + if horizontal_direction == 0: + if is_crouching: + ap.play("crouch idle") + else: + ap.play("idle") + else: + if is_crouching: + ap.play("crouch walk") + else: + ap.play("run") + else: + if velocity.y < 0: + if air_jumps_done == 0 : + ap.play("jump") + elif air_jumps_done == 1: + ap.play("double jump") + elif velocity.y > 0: + ap.play("fall") + +func crouch(): + if is_crouching: + return + is_crouching = true + crouch_mult = 0.4 + cshape.shape = crouching_cshape + cshape.position.y = -31 + +func stand(): + if is_crouching == false: + return + is_crouching = false + crouch_mult = 1 + cshape.shape = standing_cshape + cshape.position.y = -44 + +func switchdirection(horizontal_direction): + sprite.flip_h = (horizontal_direction == -1) + sprite.position.x = horizontal_direction * 4 + diff --git a/sidescroller/scripts/player.gd.uid b/sidescroller/scripts/player.gd.uid new file mode 100644 index 0000000..aedd216 --- /dev/null +++ b/sidescroller/scripts/player.gd.uid @@ -0,0 +1 @@ +uid://d2jx8gdq5o5d7