diff --git a/assets/quick_health.png b/assets/quick_health.png new file mode 100644 index 0000000..ac4d0e0 Binary files /dev/null and b/assets/quick_health.png differ diff --git a/assets/quick_health.png.import b/assets/quick_health.png.import new file mode 100644 index 0000000..676ea77 --- /dev/null +++ b/assets/quick_health.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/quick_health.png-ab4d63b30abc1b0088589c308b6afa54.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/quick_health.png" +dest_files=[ "res://.import/quick_health.png-ab4d63b30abc1b0088589c308b6afa54.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index b0a597c..9f9b604 100644 --- a/project.godot +++ b/project.godot @@ -24,15 +24,20 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/components/Health_Component.gd" }, { +"base": "Interactable", +"class": "HealthPickup", +"language": "GDScript", +"path": "res://src/Interactables/HealthPickup.gd" +}, { "base": "Area2D", "class": "Interactable", "language": "GDScript", -"path": "res://src/components/Interactable_Component.gd" +"path": "res://src/templates/Interactable/Interactable_Component.gd" }, { "base": "Node2D", "class": "Interactable_Receiver", "language": "GDScript", -"path": "res://src/components/Interactable_Receiver.gd" +"path": "res://src/templates/Interactable/Interactable_Receiver.gd" }, { "base": "Node", "class": "MovementComponent", @@ -73,6 +78,7 @@ _global_script_class_icons={ "Actor": "", "FrameSoundEffects": "", "HealthComponent": "", +"HealthPickup": "", "Interactable": "", "Interactable_Receiver": "", "MovementComponent": "", diff --git a/src/Interactables/Chest.gd b/src/Interactables/Chest.gd new file mode 100644 index 0000000..49ca906 --- /dev/null +++ b/src/Interactables/Chest.gd @@ -0,0 +1,14 @@ +extends Interactable + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +onready var sprite: Sprite = $Sprite + + +func trigger_interaction(): + # This is something that should maybe be extended for every differant interactible. + # They could inherit from this base class and implement this function. + sprite.frame = 1 diff --git a/src/Interactables/Chest.tscn b/src/Interactables/Chest.tscn new file mode 100644 index 0000000..eddf221 --- /dev/null +++ b/src/Interactables/Chest.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://src/templates/Interactable/Interactable_Component.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Interactables/Chest.gd" type="Script" id=2] +[ext_resource path="res://assets/High Forest/Assets/Interior-01.png" type="Texture" id=3] + +[sub_resource type="RectangleShape2D" id=1] + +[node name="Chest" instance=ExtResource( 1 )] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="." index="0"] +texture = ExtResource( 3 ) +vframes = 2 +region_enabled = true +region_rect = Rect2( 49, 80, 30, 64 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +modulate = Color( 0.0313726, 1, 0, 1 ) +position = Vector2( 0, 3 ) +shape = SubResource( 1 ) diff --git a/src/Interactables/HealthPickup.gd b/src/Interactables/HealthPickup.gd new file mode 100644 index 0000000..bc9b944 --- /dev/null +++ b/src/Interactables/HealthPickup.gd @@ -0,0 +1,12 @@ +class_name HealthPickup +extends Interactable + + +onready var health_icon: AnimatedSprite = $AnimatedSprite + +func trigger_interaction(): + # This is something that should maybe be extended for every differant interactible. + # They could inherit from this base class and implement this function. +# sprite.frame = 1 + queue_free() + diff --git a/src/Interactables/HealthPickup.tscn b/src/Interactables/HealthPickup.tscn new file mode 100644 index 0000000..a60ecf9 --- /dev/null +++ b/src/Interactables/HealthPickup.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://src/Interactables/HealthPickup.gd" type="Script" id=1] +[ext_resource path="res://src/templates/Interactable/Interactable_Component.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Interactables/QuickHealthPickup.tres" type="SpriteFrames" id=3] + +[sub_resource type="CircleShape2D" id=1] +radius = 6.0 + +[node name="HealthPickup" instance=ExtResource( 2 )] +script = ExtResource( 1 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"] +frames = ExtResource( 3 ) +frame = 1 +playing = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +shape = SubResource( 1 ) diff --git a/src/Interactables/QuickHealthPickup.tres b/src/Interactables/QuickHealthPickup.tres new file mode 100644 index 0000000..9daa0ec --- /dev/null +++ b/src/Interactables/QuickHealthPickup.tres @@ -0,0 +1,27 @@ +[gd_resource type="SpriteFrames" load_steps=6 format=2] + +[ext_resource path="res://assets/quick_health.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 15, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 30, 0, 15, 13 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 45, 0, 15, 13 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] diff --git a/src/Levels/Level.tscn b/src/Levels/Level.tscn index ca075d7..e1a16af 100644 --- a/src/Levels/Level.tscn +++ b/src/Levels/Level.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2] [ext_resource path="res://assets/Backgrounds/bgmuck.png" type="Texture" id=3] -[ext_resource path="res://src/components/Interactable_Component.tscn" type="PackedScene" id=4] +[ext_resource path="res://src/Interactables/Chest.tscn" type="PackedScene" id=4] +[ext_resource path="res://src/Interactables/HealthPickup.tscn" type="PackedScene" id=5] [ext_resource path="res://assets/Music/platformer_level03_loop.ogg" type="AudioStream" id=6] [ext_resource path="res://src/enemyC/EnemyC.tscn" type="PackedScene" id=7] @@ -73,5 +74,11 @@ __meta__ = { } actor_type = "NPC" -[node name="Interactable_Component" parent="." instance=ExtResource( 4 )] -position = Vector2( 186, 144 ) +[node name="HealthPickup" parent="." instance=ExtResource( 5 )] +position = Vector2( 226, 153 ) + +[node name="Chest2" parent="." instance=ExtResource( 4 )] +position = Vector2( 319, 112 ) + +[node name="Chest" parent="." instance=ExtResource( 4 )] +position = Vector2( 187, 144 ) diff --git a/src/components/Interactable_Component.tscn b/src/components/Interactable_Component.tscn deleted file mode 100644 index 9d31783..0000000 --- a/src/components/Interactable_Component.tscn +++ /dev/null @@ -1,24 +0,0 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://assets/High Forest/Assets/Interior-01.png" type="Texture" id=1] -[ext_resource path="res://src/components/Interactable_Component.gd" type="Script" id=2] - -[sub_resource type="RectangleShape2D" id=1] - -[node name="Interactable_Component" type="Area2D"] -script = ExtResource( 2 ) -sprite_node = NodePath("Sprite") - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 1 ) -vframes = 2 -region_enabled = true -region_rect = Rect2( 49, 80, 30, 64 ) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -modulate = Color( 0.290196, 1, 0, 1 ) -position = Vector2( -1, 3 ) -shape = SubResource( 1 ) - -[connection signal="body_entered" from="." to="." method="_on_Interactable_Component_body_entered"] -[connection signal="body_exited" from="." to="." method="_on_Interactable_Component_body_exited"] diff --git a/src/playerD/Player.gd b/src/playerD/Player.gd index 1e6a937..7f71ff1 100644 --- a/src/playerD/Player.gd +++ b/src/playerD/Player.gd @@ -26,7 +26,11 @@ func hit_Receiver(damage): func touch_the_thing(the_thing: Interactable) -> bool: print("You see! a THING...", the_thing.name) - return false + if the_thing is HealthPickup: + # Do some healthy stuff. + the_thing.trigger_interaction() + return false + return true func _on_attack_do_attack(): var is_shooting = false diff --git a/src/playerD/Player.tscn b/src/playerD/Player.tscn index 4fc4f34..b72c85f 100644 --- a/src/playerD/Player.tscn +++ b/src/playerD/Player.tscn @@ -15,7 +15,7 @@ [ext_resource path="res://src/Gun.gd" type="Script" id=13] [ext_resource path="res://src/playerD/states/roll.gd" type="Script" id=14] [ext_resource path="res://src/state_animated_actor.gd" type="Script" id=15] -[ext_resource path="res://src/components/Interactable_Receiver.gd" type="Script" id=16] +[ext_resource path="res://src/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16] [sub_resource type="StreamTexture" id=90] load_path = "res://.import/Mega.png-93dfe0790902b932f7b46f7b23c5d4e7.stex" diff --git a/src/components/Interactable_Component.gd b/src/templates/Interactable/Interactable_Component.gd similarity index 94% rename from src/components/Interactable_Component.gd rename to src/templates/Interactable/Interactable_Component.gd index 1728940..32116bd 100644 --- a/src/components/Interactable_Component.gd +++ b/src/templates/Interactable/Interactable_Component.gd @@ -17,9 +17,8 @@ extends Area2D # Declare member variables here. Examples: # var a = 2 # var b = "text" -export (NodePath) var sprite_node -onready var sprite: Sprite = get_node(sprite_node) +export var type_name :String # Called when the node enters the scene tree for the first time. func _ready(): @@ -28,8 +27,7 @@ func _ready(): func trigger_interaction(): # This is something that should maybe be extended for every differant interactible. # They could inherit from this base class and implement this function. - sprite.frame = 1 - +# sprite.frame = 1 pass # Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/src/templates/Interactable/Interactable_Component.tscn b/src/templates/Interactable/Interactable_Component.tscn new file mode 100644 index 0000000..c114073 --- /dev/null +++ b/src/templates/Interactable/Interactable_Component.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/templates/Interactable/Interactable_Component.gd" type="Script" id=2] + +[node name="Interactable_Template" type="Area2D"] +script = ExtResource( 2 ) + +[connection signal="body_entered" from="." to="." method="_on_Interactable_Component_body_entered"] +[connection signal="body_exited" from="." to="." method="_on_Interactable_Component_body_exited"] diff --git a/src/components/Interactable_Receiver.gd b/src/templates/Interactable/Interactable_Receiver.gd similarity index 100% rename from src/components/Interactable_Receiver.gd rename to src/templates/Interactable/Interactable_Receiver.gd