diff --git a/Assets/Characters/Friendly/Tellik/Tellick.tscn b/Assets/Characters/Friendly/Tellik/Tellick.tscn index 91fa163..3307426 100644 --- a/Assets/Characters/Friendly/Tellik/Tellick.tscn +++ b/Assets/Characters/Friendly/Tellik/Tellick.tscn @@ -179,12 +179,15 @@ radius = 21.0 height = 182.0 [node name="Tellick" type="CharacterBody2D"] +z_index = 100 +collision_layer = 2 script = ExtResource("1_q21sg") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] position = Vector2(0, 2) scale = Vector2(0.2, 0.2) sprite_frames = SubResource("SpriteFrames_jl8dy") +autoplay = "default" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CapsuleShape2D_aoset") diff --git a/Assets/Characters/Friendly/Tellik/tellick.gd b/Assets/Characters/Friendly/Tellik/tellick.gd index b1f4780..2df69d7 100644 --- a/Assets/Characters/Friendly/Tellik/tellick.gd +++ b/Assets/Characters/Friendly/Tellik/tellick.gd @@ -1,25 +1,52 @@ extends CharacterBody2D +const SPEED = 600.0 +const JUMP_VELOCITY = -1000.0 +const MAX_JUMP_DURATION = 0.3 +const MIN_JUMP_DURATION = 0.01 +const GRAVITY = 980 +const FALL_GRAVITY_MULTIPLIER = 2 -const SPEED = 300.0 -const JUMP_VELOCITY = -400.0 +var jump_timer = 0.0 +var is_jumping = false - -func _physics_process(delta: float) -> void: - # Add the gravity. +func _physics_process(delta): + # Apply gravity if not is_on_floor(): - velocity += get_gravity() * delta + var gravity_multiplier = FALL_GRAVITY_MULTIPLIER if velocity.y > 0 else 2 + velocity.y += GRAVITY * gravity_multiplier * delta - # Handle jump. - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): - velocity.y = JUMP_VELOCITY + # Handle Jump + if Input.is_action_just_pressed("jump") and is_on_floor(): + start_jump() + + if is_jumping: + if Input.is_action_pressed("jump"): + continue_jump(delta) + else: + end_jump() - # Get the input direction and handle the movement/deceleration. - # As good practice, you should replace UI actions with custom gameplay actions. - var direction := Input.get_axis("ui_left", "ui_right") + # Handle horizontal movement + var direction = Input.get_axis("move_left", "move_right") if direction: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) move_and_slide() + +func start_jump(): + velocity.y = JUMP_VELOCITY + is_jumping = true + +func continue_jump(delta): + pass + +func end_jump(): + if velocity.y < 0: + velocity.y *= 0.20 + is_jumping = false + + +func _on_kill_zone_body_entered(body: Node2D) -> void: + pass # Replace with function body. diff --git a/Assets/Collectables/GoldCoin.png b/Assets/Collectables/GoldCoin.png new file mode 100644 index 0000000..0f1067c Binary files /dev/null and b/Assets/Collectables/GoldCoin.png differ diff --git a/Assets/Collectables/GoldCoin.png.import b/Assets/Collectables/GoldCoin.png.import new file mode 100644 index 0000000..27e8024 --- /dev/null +++ b/Assets/Collectables/GoldCoin.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dj7grfg4awrf6" +path="res://.godot/imported/GoldCoin.png-25b6ee75d6b11e5a23115548c7f446c1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Collectables/GoldCoin.png" +dest_files=["res://.godot/imported/GoldCoin.png-25b6ee75d6b11e5a23115548c7f446c1.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/Collectables/coin.tscn b/Assets/Collectables/coin.tscn new file mode 100644 index 0000000..82c849b --- /dev/null +++ b/Assets/Collectables/coin.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=10 format=3 uid="uid://ctysf55pres8y"] + +[ext_resource type="Texture2D" uid="uid://dj7grfg4awrf6" path="res://Assets/Collectables/GoldCoin.png" id="1_6uh7u"] +[ext_resource type="Script" path="res://Scripts/coin.gd" id="1_isgrf"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_6apv0"] +atlas = ExtResource("1_6uh7u") +region = Rect2(0, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8md4o"] +atlas = ExtResource("1_6uh7u") +region = Rect2(16, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ai3ca"] +atlas = ExtResource("1_6uh7u") +region = Rect2(32, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sh070"] +atlas = ExtResource("1_6uh7u") +region = Rect2(48, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pi3db"] +atlas = ExtResource("1_6uh7u") +region = Rect2(64, 0, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_iigen"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_6apv0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8md4o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ai3ca") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sh070") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pi3db") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_piars"] + +[node name="Coin" type="Area2D"] +collision_mask = 2 +script = ExtResource("1_isgrf") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(3, 3) +sprite_frames = SubResource("SpriteFrames_iigen") +autoplay = "default" +frame_progress = 0.137011 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +scale = Vector2(2.08, 2.08) +shape = SubResource("CircleShape2D_piars") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="body_entered" from="." to="CollisionShape2D" method="_on_coin_body_entered"] diff --git a/Assets/World/Grounds/Dirt.png b/Assets/World/Grounds/Dirt.png new file mode 100644 index 0000000..cf5759b Binary files /dev/null and b/Assets/World/Grounds/Dirt.png differ diff --git a/Assets/World/Grounds/Dirt.png.import b/Assets/World/Grounds/Dirt.png.import new file mode 100644 index 0000000..af3a93f --- /dev/null +++ b/Assets/World/Grounds/Dirt.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c8wfwo1nixh7d" +path="res://.godot/imported/Dirt.png-d91541ba4a1d97b0a577c961c41f3137.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/World/Grounds/Dirt.png" +dest_files=["res://.godot/imported/Dirt.png-d91541ba4a1d97b0a577c961c41f3137.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/World/Grounds/Ground1.tscn b/Assets/World/Grounds/Ground1.tscn index 26889e2..61068e6 100644 --- a/Assets/World/Grounds/Ground1.tscn +++ b/Assets/World/Grounds/Ground1.tscn @@ -1,12 +1,20 @@ -[gd_scene load_steps=2 format=3 uid="uid://eo08vhsoltt6"] +[gd_scene load_steps=3 format=3 uid="uid://eo08vhsoltt6"] + +[ext_resource type="Texture2D" uid="uid://c8wfwo1nixh7d" path="res://Assets/World/Grounds/Dirt.png" id="1_437ln"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_2rdbk"] -size = Vector2(364, 54) +size = Vector2(455, 51) [node name="Ground1" type="Node2D"] +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(2, 3) +scale = Vector2(0.2, 0.2) +texture = ExtResource("1_437ln") + [node name="StaticBody2D" type="StaticBody2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(-8.5, 1.5) shape = SubResource("RectangleShape2D_2rdbk") debug_color = Color(0, 0.645698, 0.254313, 0.42) diff --git a/Assets/World/Platforms/platform.tscn b/Assets/World/Platforms/platform.tscn new file mode 100644 index 0000000..82e7547 --- /dev/null +++ b/Assets/World/Platforms/platform.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://bqb3ccnlh1t0s"] + +[ext_resource type="Texture2D" uid="uid://c8wfwo1nixh7d" path="res://Assets/World/Grounds/Dirt.png" id="1_4guyj"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vncw8"] +size = Vector2(452, 48) + +[node name="Platform" type="AnimatableBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.2, 0.2) +texture = ExtResource("1_4guyj") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-11, 0) +shape = SubResource("RectangleShape2D_vncw8") +one_way_collision = true diff --git a/Assets/World/kill_zone.tscn b/Assets/World/kill_zone.tscn new file mode 100644 index 0000000..05ec11d --- /dev/null +++ b/Assets/World/kill_zone.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://cyumvt28wwf28"] + +[ext_resource type="Script" path="res://Scripts/kill_zone.gd" id="1_vfalm"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_6667c"] + +[node name="KillZone" type="Area2D"] +collision_mask = 2 +script = ExtResource("1_vfalm") + +[node name="Timer" type="Timer" parent="."] +wait_time = 0.6 +one_shot = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("WorldBoundaryShape2D_6667c") +debug_color = Color(1, 0.012597, 0.0137024, 0.42) + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/Scripts/camera_2d.gd b/Scripts/camera_2d.gd new file mode 100644 index 0000000..ab1c6a7 --- /dev/null +++ b/Scripts/camera_2d.gd @@ -0,0 +1,11 @@ +extends Camera2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/Scripts/coin.gd b/Scripts/coin.gd new file mode 100644 index 0000000..99d6fa8 --- /dev/null +++ b/Scripts/coin.gd @@ -0,0 +1,16 @@ +extends Area2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_body_entered(body: Node2D) -> void: + print("coin touched") + queue_free() diff --git a/Scripts/kill_zone.gd b/Scripts/kill_zone.gd new file mode 100644 index 0000000..75c753e --- /dev/null +++ b/Scripts/kill_zone.gd @@ -0,0 +1,23 @@ +extends Area2D +@onready var timer: Timer = $Timer + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_body_entered(body: Node2D) -> void: + print("you died") + timer.start() + + + + +func _on_timer_timeout() -> void: + get_tree().reload_current_scene() diff --git a/project.godot b/project.godot index 2b80f35..c17bfa2 100644 --- a/project.godot +++ b/project.godot @@ -17,3 +17,25 @@ run/main_scene="res://world.tscn" >>>>>>> f25b89aa52bc76423cd04483e3b0644fe3df1dc6 config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" + +[input] + +jump={ +"deadzone": 0.5, +"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) +] +} +move_left={ +"deadzone": 0.5, +"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.5, +"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) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 diff --git a/world.tscn b/world.tscn index 7a03bfc..53d4cc0 100644 --- a/world.tscn +++ b/world.tscn @@ -1,29 +1,99 @@ -[gd_scene load_steps=5 format=3 uid="uid://b0jkivtwisycv"] +[gd_scene load_steps=10 format=3 uid="uid://b0jkivtwisycv"] [ext_resource type="PackedScene" uid="uid://cny5b638kjd3w" path="res://Assets/Characters/Friendly/Tellik/Tellick.tscn" id="1_dgu6h"] [ext_resource type="PackedScene" uid="uid://eo08vhsoltt6" path="res://Assets/World/Grounds/Ground1.tscn" id="2_gboim"] +[ext_resource type="Script" path="res://Scripts/camera_2d.gd" id="2_mpgh4"] +[ext_resource type="PackedScene" uid="uid://bqb3ccnlh1t0s" path="res://Assets/World/Platforms/platform.tscn" id="3_i3imp"] +[ext_resource type="PackedScene" uid="uid://ctysf55pres8y" path="res://Assets/Collectables/coin.tscn" id="4_qkdpl"] +[ext_resource type="PackedScene" uid="uid://cyumvt28wwf28" path="res://Assets/World/kill_zone.tscn" id="6_6a5uv"] -[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_5e4u7"] +[sub_resource type="Animation" id="Animation_ya3iv"] +resource_name = "move" +length = 3.0 +loop_mode = 2 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(-645, 31), Vector2(-269, 23)] +} -[sub_resource type="TileSet" id="TileSet_bke3u"] +[sub_resource type="Animation" id="Animation_lrrse"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(-645, 31)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_semk0"] +_data = { +"RESET": SubResource("Animation_lrrse"), +"move": SubResource("Animation_ya3iv") +} [node name="World" type="Node2D"] physics_interpolation_mode = 1 [node name="Tellick" parent="." instance=ExtResource("1_dgu6h")] -position = Vector2(-7, -130) +physics_interpolation_mode = 1 +position = Vector2(-245, -160) -[node name="Camera2D" type="Camera2D" parent="."] - -[node name="StaticBody2D" type="StaticBody2D" parent="."] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] -position = Vector2(1, 140) -shape = SubResource("WorldBoundaryShape2D_5e4u7") +[node name="Camera2D" type="Camera2D" parent="Tellick"] +position = Vector2(-39, 93) +zoom = Vector2(0.5, 0.5) +limit_bottom = 650 +position_smoothing_enabled = true +script = ExtResource("2_mpgh4") [node name="Ground1" parent="." instance=ExtResource("2_gboim")] -position = Vector2(-5, -2) +position = Vector2(-675, -57) -[node name="TileMap" type="TileMap" parent="."] -tile_set = SubResource("TileSet_bke3u") -format = 2 +[node name="Ground2" parent="." instance=ExtResource("2_gboim")] +position = Vector2(-312, 71) + +[node name="Platform" parent="." instance=ExtResource("3_i3imp")] +position = Vector2(391, -56) + +[node name="Platform2" parent="." instance=ExtResource("3_i3imp")] +position = Vector2(-645, 31) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Platform2"] +libraries = { +"": SubResource("AnimationLibrary_semk0") +} +autoplay = "move" + +[node name="Coin" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(183, -124) + +[node name="Coin2" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(253, -124) + +[node name="Coin3" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(308, -124) + +[node name="Coin4" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(363, -129) + +[node name="Coin5" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(444, -121) + +[node name="Coin6" parent="." instance=ExtResource("4_qkdpl")] +position = Vector2(518, -127) + +[node name="KillZone" parent="." instance=ExtResource("6_6a5uv")] +position = Vector2(-2, 257)