From 157376861942fa39512f9aec69833c12624efe6f Mon Sep 17 00:00:00 2001 From: Egg Man Date: Sat, 7 Sep 2024 13:13:05 -0400 Subject: [PATCH] added moving platforms and "collectable" coins and death barrier --- .../Characters/Friendly/Tellik/Tellick.tscn | 3 + Assets/Characters/Friendly/Tellik/tellick.gd | 6 +- Assets/Collectables/GoldCoin.png | Bin 0 -> 663 bytes Assets/Collectables/GoldCoin.png.import | 34 ++++++ Assets/Collectables/coin.tscn | 66 ++++++++++++ Assets/World/Platforms/platform.tscn | 17 +++ Assets/World/kill_zone.tscn | 20 ++++ Scripts/camera_2d.gd | 11 ++ Scripts/coin.gd | 16 +++ Scripts/kill_zone.gd | 23 ++++ project.godot | 4 + world.tscn | 101 ++++++++++++++---- 12 files changed, 282 insertions(+), 19 deletions(-) create mode 100644 Assets/Collectables/GoldCoin.png create mode 100644 Assets/Collectables/GoldCoin.png.import create mode 100644 Assets/Collectables/coin.tscn create mode 100644 Assets/World/Platforms/platform.tscn create mode 100644 Assets/World/kill_zone.tscn create mode 100644 Scripts/camera_2d.gd create mode 100644 Scripts/coin.gd create mode 100644 Scripts/kill_zone.gd 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 535510d..2df69d7 100644 --- a/Assets/Characters/Friendly/Tellik/tellick.gd +++ b/Assets/Characters/Friendly/Tellik/tellick.gd @@ -1,6 +1,6 @@ extends CharacterBody2D -const SPEED = 300.0 +const SPEED = 600.0 const JUMP_VELOCITY = -1000.0 const MAX_JUMP_DURATION = 0.3 const MIN_JUMP_DURATION = 0.01 @@ -46,3 +46,7 @@ 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 0000000000000000000000000000000000000000..0f1067cf895ce50e4be771c2fcceff1d52eef677 GIT binary patch literal 663 zcmV;I0%-k-P)4_cA0^h#1~*$y*|s5 zb{D}|FU#ds{`GUYEUbIA>-Wk-C+nDMTgtL;Q+0U#ub{Bt>3qq!tXIqQ+v5myoX%&G zhly)guU0NuHah4Se1L6_T}_s+d3Chn*L=tTN~goV$gAy;kUbC?ynR#;x%hcFhVb_3 z2f@A^cJt&)|2_7b@gw&4+W!&YC|rUAHG&5a_}+pz0u=C|!V`epvPT1K#!rrEF(iPd z@D~44DRg901uxM4(584Hmj29@3(5buI`*6K%Y;%+p$$;LJM0!=vm1_LE1PadfbNYt za0EB6LmYEJKnBZm{3{Sn`zk=hAK}4%@}J;=h4e)SDB$t2Wq5snv3aCyC1}qAIKjRK zUS@4d9xSDV831#El!25*eSooZ#+^&cnE`b7_#p#&b_SO9zn_8JFjD=xb5r4=LZp^W@-}U6dK9;fP z0F~Jdf-?K2)IhFZbGtA)IIlTfc(hMVpsZi4I|EqEys~*}u@{3hb;#P8N9(i=v- zV+_nCU0)aX=rhXT@sFEWYGif?m0?;>Q1Tvgkgj$D7o-!Y1;^p8UM5%&r@)&Fu!87> zSI2*wdHFxffAeL+_ecIR0pPGa5A}ek$$MmFFs!4uY2|^D*~Cqt_Y5!X;=9*>^A(l% xb&hq~@0I6l@@|?2QC^#}dD1rPu;hOMD?= 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 d94962f..b43b02f 100644 --- a/project.godot +++ b/project.godot @@ -32,3 +32,7 @@ move_right={ "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 2be542f..53d4cc0 100644 --- a/world.tscn +++ b/world.tscn @@ -1,34 +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(-39, 47) +physics_interpolation_mode = 1 +position = Vector2(-245, -160) -[node name="Camera2D" type="Camera2D" parent="."] +[node name="Camera2D" type="Camera2D" parent="Tellick"] +position = Vector2(-39, 93) zoom = Vector2(0.5, 0.5) - -[node name="StaticBody2D" type="StaticBody2D" parent="."] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] -position = Vector2(1, 140) -shape = SubResource("WorldBoundaryShape2D_5e4u7") -debug_color = Color(0.994873, 0.0645888, 1.15514e-06, 0.42) +limit_bottom = 650 +position_smoothing_enabled = true +script = ExtResource("2_mpgh4") [node name="Ground1" parent="." instance=ExtResource("2_gboim")] -position = Vector2(-279, 114) - -[node name="TileMap" type="TileMap" parent="."] -tile_set = SubResource("TileSet_bke3u") -format = 2 +position = Vector2(-675, -57) [node name="Ground2" parent="." instance=ExtResource("2_gboim")] -position = Vector2(-245, -72) +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)