diff --git a/Assets/Sprites/Jesus/Jesus Back.png b/Assets/Sprites/Jesus/Jesus Back.png new file mode 100644 index 0000000..51840ac Binary files /dev/null and b/Assets/Sprites/Jesus/Jesus Back.png differ diff --git a/Assets/Sprites/Jesus_Left_Idle.png.import b/Assets/Sprites/Jesus/Jesus Back.png.import similarity index 66% rename from Assets/Sprites/Jesus_Left_Idle.png.import rename to Assets/Sprites/Jesus/Jesus Back.png.import index 7e997b4..b6bde28 100644 --- a/Assets/Sprites/Jesus_Left_Idle.png.import +++ b/Assets/Sprites/Jesus/Jesus Back.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://c6n0go8l4gaak" -path="res://.godot/imported/Jesus_Left_Idle.png-591d029c8d8b8b573a2665b70cf0e031.ctex" +uid="uid://ct2del6b6jorm" +path="res://.godot/imported/Jesus Back.png-6132a4979edf4d1442fefae322c4ce7c.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/Sprites/Jesus_Left_Idle.png" -dest_files=["res://.godot/imported/Jesus_Left_Idle.png-591d029c8d8b8b573a2665b70cf0e031.ctex"] +source_file="res://Assets/Sprites/Jesus/Jesus Back.png" +dest_files=["res://.godot/imported/Jesus Back.png-6132a4979edf4d1442fefae322c4ce7c.ctex"] [params] diff --git a/Assets/Sprites/Jesus/Jesus Front.png b/Assets/Sprites/Jesus/Jesus Front.png new file mode 100644 index 0000000..2f4f5ff Binary files /dev/null and b/Assets/Sprites/Jesus/Jesus Front.png differ diff --git a/Assets/Sprites/Jesus/Jesus Front.png.import b/Assets/Sprites/Jesus/Jesus Front.png.import new file mode 100644 index 0000000..f35491f --- /dev/null +++ b/Assets/Sprites/Jesus/Jesus Front.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c03lntytfivr1" +path="res://.godot/imported/Jesus Front.png-b78bfa6c3ed674009555f7ab3f93e778.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Jesus/Jesus Front.png" +dest_files=["res://.godot/imported/Jesus Front.png-b78bfa6c3ed674009555f7ab3f93e778.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/Assets/Sprites/Jesus/Jesus Left.png b/Assets/Sprites/Jesus/Jesus Left.png new file mode 100644 index 0000000..fba652f Binary files /dev/null and b/Assets/Sprites/Jesus/Jesus Left.png differ diff --git a/Assets/Sprites/Jesus/Jesus Left.png.import b/Assets/Sprites/Jesus/Jesus Left.png.import new file mode 100644 index 0000000..34a5751 --- /dev/null +++ b/Assets/Sprites/Jesus/Jesus Left.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cn4kqa1p845wl" +path="res://.godot/imported/Jesus Left.png-2949c2879ed5f5e8def57f2eb1498de4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Jesus/Jesus Left.png" +dest_files=["res://.godot/imported/Jesus Left.png-2949c2879ed5f5e8def57f2eb1498de4.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/Assets/Sprites/Jesus/Jesus Spritesheet.png b/Assets/Sprites/Jesus/Jesus Spritesheet.png new file mode 100644 index 0000000..3d67761 Binary files /dev/null and b/Assets/Sprites/Jesus/Jesus Spritesheet.png differ diff --git a/Assets/Sprites/Jesus/Jesus Spritesheet.png.import b/Assets/Sprites/Jesus/Jesus Spritesheet.png.import new file mode 100644 index 0000000..7b6d151 --- /dev/null +++ b/Assets/Sprites/Jesus/Jesus Spritesheet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bl7vfn05ul1vu" +path="res://.godot/imported/Jesus Spritesheet.png-821a08dd328b5743c2bc86e42539e57a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Jesus/Jesus Spritesheet.png" +dest_files=["res://.godot/imported/Jesus Spritesheet.png-821a08dd328b5743c2bc86e42539e57a.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/Assets/Sprites/Jesus/Shadow.png b/Assets/Sprites/Jesus/Shadow.png new file mode 100644 index 0000000..5d4d0c5 Binary files /dev/null and b/Assets/Sprites/Jesus/Shadow.png differ diff --git a/Assets/Sprites/Jesus/Shadow.png.import b/Assets/Sprites/Jesus/Shadow.png.import new file mode 100644 index 0000000..dbfe369 --- /dev/null +++ b/Assets/Sprites/Jesus/Shadow.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cubc3m81pdyvq" +path="res://.godot/imported/Shadow.png-e182ddfbb5e0bd7753fe3ec1e6b362c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Jesus/Shadow.png" +dest_files=["res://.godot/imported/Shadow.png-e182ddfbb5e0bd7753fe3ec1e6b362c7.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/Assets/Sprites/Jesus_Left_Idle.png b/Assets/Sprites/Jesus_Left_Idle.png deleted file mode 100644 index 4082dd7..0000000 Binary files a/Assets/Sprites/Jesus_Left_Idle.png and /dev/null differ diff --git a/Scenes/PlayerMovement.tscn b/Scenes/PlayerMovement.tscn index ac57954..d13fce9 100644 --- a/Scenes/PlayerMovement.tscn +++ b/Scenes/PlayerMovement.tscn @@ -1,35 +1,151 @@ -[gd_scene load_steps=5 format=3 uid="uid://ccgpsim5nfxd6"] +[gd_scene load_steps=12 format=3 uid="uid://ccgpsim5nfxd6"] [ext_resource type="Script" path="res://Scripts/PlayerController.gd" id="1_x3102"] -[ext_resource type="Texture2D" uid="uid://c6n0go8l4gaak" path="res://Assets/Sprites/Jesus_Left_Idle.png" id="2_48vut"] [ext_resource type="TileSet" uid="uid://b7cqbf6xdbeal" path="res://Assets/Test_Tileset.tres" id="3_0at2g"] [ext_resource type="Script" path="res://Scripts/MapGenerator.gd" id="4_8st0q"] +[ext_resource type="Texture2D" uid="uid://bl7vfn05ul1vu" path="res://Assets/Sprites/Jesus/Jesus Spritesheet.png" id="4_e5cec"] -[node name="Node2D" type="Node2D"] +[sub_resource type="Animation" id="Animation_kdxam"] +resource_name = "Idle" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} -[node name="TileMap" type="TileMap" parent="."] +[sub_resource type="Animation" id="Animation_dwpep"] +resource_name = "MoveDown" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = false +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3] +} + +[sub_resource type="Animation" id="Animation_2jvl5"] +resource_name = "MoveLeft" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": [12, 13, 14, 15] +} + +[sub_resource type="Animation" id="Animation_4ig1u"] +resource_name = "MoveRight" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": [4, 5, 6, 7] +} + +[sub_resource type="Animation" id="Animation_pswkh"] +resource_name = "MoveUp" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 1, +"values": [8, 9, 10, 11] +} + +[sub_resource type="Animation" id="Animation_o3hln"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_bi1h3"] +_data = { +"Idle": SubResource("Animation_kdxam"), +"MoveDown": SubResource("Animation_dwpep"), +"MoveLeft": SubResource("Animation_2jvl5"), +"MoveRight": SubResource("Animation_4ig1u"), +"MoveUp": SubResource("Animation_pswkh"), +"RESET": SubResource("Animation_o3hln") +} + +[node name="Player Movement" type="Node2D"] + +[node name="Map Generator" type="TileMap" parent="."] tile_set = ExtResource("3_0at2g") cell_quadrant_size = 8 collision_visibility_mode = 1 format = 2 script = ExtResource("4_8st0q") -[node name="CharacterBody2D" type="CharacterBody2D" parent="."] +[node name="Player" type="CharacterBody2D" parent="." node_paths=PackedStringArray("animation_player")] position = Vector2(512, 300) scale = Vector2(0.25, 0.25) script = ExtResource("1_x3102") -speed = 80 +animation_player = NodePath("Player Animator") -[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"] -texture = ExtResource("2_48vut") +[node name="Player Sprite" type="Sprite2D" parent="Player"] +position = Vector2(0, -20) +texture = ExtResource("4_e5cec") +hframes = 4 +vframes = 4 -[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="CharacterBody2D"] -polygon = PackedVector2Array(16, 32, -14, 32, -14, -22, 16, -22) +[node name="Player Collider" type="CollisionPolygon2D" parent="Player"] +polygon = PackedVector2Array(12, 32, -16, 32, -16, -24, 12, -24) -[node name="Camera2D" type="Camera2D" parent="CharacterBody2D"] +[node name="Player Camera" type="Camera2D" parent="Player"] zoom = Vector2(10, 10) position_smoothing_enabled = true drag_horizontal_enabled = true drag_vertical_enabled = true editor_draw_limits = true editor_draw_drag_margin = true + +[node name="Player Animator" type="AnimationPlayer" parent="Player"] +libraries = { +"": SubResource("AnimationLibrary_bi1h3") +} diff --git a/Scripts/PlayerController.gd b/Scripts/PlayerController.gd index f167eb8..584f977 100644 --- a/Scripts/PlayerController.gd +++ b/Scripts/PlayerController.gd @@ -1,24 +1,43 @@ extends CharacterBody2D -@export var speed = 100 -@export_range(0, 1) var damping_factor := 0.6 +@export var speed = 20 +@export_range(0, 1) var damping_factor = 0.6 +@export var animation_player : AnimationPlayer -func get_move_vector(): +func _physics_process(delta : float): + update_player_movement(delta) + pass + +func get_move_input_vector() -> Vector2: var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized() return input_direction -func move_player(delta : float): - if get_move_vector() == Vector2.ZERO: - # Damp Players Velocity if no Input - self.velocity = self.velocity * (1 - min(1, damping_factor * 60 * delta)) - else: - # Set Players Velocity to the Input Direction in the Players Speed - self.velocity = get_move_vector() * speed * delta * 60 - - # Update The Players Physics Calculations +func update_player_movement(delta : float): + var input = get_move_input_vector() + + # Damp Movement if not moving, Accelerate if Moving + var is_moving = input != Vector2.ZERO + self.velocity = input * speed * delta * 60 if is_moving else self.velocity * (1 - min(1, damping_factor * 60 * delta)) + + update_player_animation() + + # Update Objects Physics calculations self.move_and_slide() pass -func _physics_process(delta : float): - move_player(delta) +func update_player_animation(): + var move_vector = get_move_input_vector() + match move_vector: + Vector2.ZERO: animation_player.play("Idle") + Vector2.LEFT: animation_player.play("MoveLeft") + Vector2.RIGHT: animation_player.play("MoveRight") + Vector2.UP: animation_player.play("MoveUp") + Vector2.DOWN: animation_player.play("MoveDown") + _: handle_diagonal_animations(move_vector) + pass + +func handle_diagonal_animations(dir : Vector2): + if (dir.y > 0 and dir.x < 0) or (dir.y < 0 and dir.x < 0): animation_player.play("MoveLeft") + elif (dir.y > 0 and dir.x > 0) or (dir.y < 0 and dir.x > 0): animation_player.play("MoveRight") + else: animation_player.play("Idle") pass diff --git a/project.godot b/project.godot index 148a2ef..5397ca5 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="HoppyEaster" -run/main_scene="res://Scenes/Movement.tscn" +run/main_scene="res://Scenes/PlayerMovement.tscn" config/features=PackedStringArray("4.0", "GL Compatibility") config/icon="res://icon.svg"