From f2a9e83bcb9d1e7bb1e97b065df0d49ea72107e1 Mon Sep 17 00:00:00 2001 From: Ruslan Ignatov Date: Sun, 8 Sep 2024 17:25:44 +0300 Subject: [PATCH] Added Pickup --- LICENSE | 2 +- .../data/images/{Items.png => Pickups.png} | Bin .../{Items.png.import => Pickups.png.import} | 8 +- vegeconda/door.gd | 2 +- vegeconda/icon.svg | 1 + vegeconda/icon.svg.import | 37 +++ vegeconda/pickup.gd | 61 ++++ vegeconda/pickup.tscn | 314 ++++++++++++++++++ 8 files changed, 419 insertions(+), 6 deletions(-) rename vegeconda/data/images/{Items.png => Pickups.png} (100%) rename vegeconda/data/images/{Items.png.import => Pickups.png.import} (69%) create mode 100644 vegeconda/icon.svg create mode 100644 vegeconda/icon.svg.import create mode 100644 vegeconda/pickup.gd create mode 100644 vegeconda/pickup.tscn diff --git a/LICENSE b/LICENSE index 0aad41b..3e2b39b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 IRUSlan92I +Copyright (c) 2024 Ruslan Ignatov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vegeconda/data/images/Items.png b/vegeconda/data/images/Pickups.png similarity index 100% rename from vegeconda/data/images/Items.png rename to vegeconda/data/images/Pickups.png diff --git a/vegeconda/data/images/Items.png.import b/vegeconda/data/images/Pickups.png.import similarity index 69% rename from vegeconda/data/images/Items.png.import rename to vegeconda/data/images/Pickups.png.import index bc2b083..6fb9fd8 100644 --- a/vegeconda/data/images/Items.png.import +++ b/vegeconda/data/images/Pickups.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dhpkj7orafb2o" -path="res://.godot/imported/Items.png-c7d096b9e23f1f297839b86fe453a627.ctex" +uid="uid://cf3o6ne8t4feg" +path="res://.godot/imported/Pickups.png-c32a01c8756166732563b42e41cc5e10.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://data/images/Items.png" -dest_files=["res://.godot/imported/Items.png-c7d096b9e23f1f297839b86fe453a627.ctex"] +source_file="res://data/images/Pickups.png" +dest_files=["res://.godot/imported/Pickups.png-c32a01c8756166732563b42e41cc5e10.ctex"] [params] diff --git a/vegeconda/door.gd b/vegeconda/door.gd index 9bdf904..b3c69e3 100644 --- a/vegeconda/door.gd +++ b/vegeconda/door.gd @@ -35,7 +35,7 @@ func _ready() -> void: func play_animation() -> void: - var animation = "%s_%s" % [ + var animation : String = "%s_%s" % [ ANIMATIONS_BY_TYPE[door_type], ANIMATIONS_BY_STATE[door_state] ] diff --git a/vegeconda/icon.svg b/vegeconda/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/vegeconda/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/vegeconda/icon.svg.import b/vegeconda/icon.svg.import new file mode 100644 index 0000000..14c62b5 --- /dev/null +++ b/vegeconda/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://btqf3sc51m16d" +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/vegeconda/pickup.gd b/vegeconda/pickup.gd new file mode 100644 index 0000000..9085942 --- /dev/null +++ b/vegeconda/pickup.gd @@ -0,0 +1,61 @@ +extends StaticBody2D + + +enum PickupType {CHERRY, FLY_AGARIC, GREEN_APPLE, RED_APPLE} +@export var pickup_type: PickupType + +enum PickupState {PREPARING, SHOWING_UP, IDLING, HIGHLIGHTING} +@export var pickup_state: PickupState = PickupState.PREPARING + + +var ANIMATIONS_BY_TYPE : Dictionary = { + PickupType.CHERRY: "cherry", + PickupType.FLY_AGARIC: "fly_agaric", + PickupType.GREEN_APPLE: "green_apple", + PickupType.RED_APPLE: "red_apple", +} + +var ANIMATIONS_BY_STATE : Dictionary = { + PickupState.PREPARING: "preparing", + PickupState.SHOWING_UP: "showing_up", + PickupState.IDLING: "idling", + PickupState.HIGHLIGHTING: "highlighting", +} + + + +func _init(type : PickupType = PickupType.RED_APPLE) -> void: + pickup_type = type + + +func _ready() -> void: + play_animation() + + +func highlight() -> void: + pickup_state = PickupState.HIGHLIGHTING + play_animation() + + +func play_animation() -> void: + var animation : String + if pickup_state == PickupState.PREPARING: + animation = ANIMATIONS_BY_STATE[pickup_state] + else: + animation = "%s_%s" % [ + ANIMATIONS_BY_TYPE[pickup_type], + ANIMATIONS_BY_STATE[pickup_state] + ] + $AnimatedSprite2D.play(animation) + + +func _on_animated_sprite_2d_animation_finished() -> void: + if pickup_state == PickupState.PREPARING: + pickup_state = PickupState.SHOWING_UP + play_animation() + elif pickup_state == PickupState.SHOWING_UP: + pickup_state = PickupState.IDLING + play_animation() + elif pickup_state == PickupState.HIGHLIGHTING: + pickup_state = PickupState.IDLING + play_animation() diff --git a/vegeconda/pickup.tscn b/vegeconda/pickup.tscn new file mode 100644 index 0000000..ab49d95 --- /dev/null +++ b/vegeconda/pickup.tscn @@ -0,0 +1,314 @@ +[gd_scene load_steps=37 format=3 uid="uid://bxfiehrwd5lvm"] + +[ext_resource type="Texture2D" uid="uid://cf3o6ne8t4feg" path="res://data/images/Pickups.png" id="1_qc6lb"] +[ext_resource type="Script" path="res://pickup.gd" id="2_rayse"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_2wuor"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 48, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_imavv"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 64, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yhmql"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 80, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_emby7"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 96, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kakww"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 32, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_373d3"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_60pr6"] +atlas = ExtResource("1_qc6lb") +region = Rect2(16, 16, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bj7nn"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 48, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_snm2e"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 64, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_41vo0"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 80, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hji6o"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 96, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ohymx"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 32, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sfcv2"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_t6abu"] +atlas = ExtResource("1_qc6lb") +region = Rect2(48, 16, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eoxck"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 48, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_khlec"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 64, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_q0d5w"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 80, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_45l3f"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 96, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wa1iy"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 32, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v63jo"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kglnt"] +atlas = ExtResource("1_qc6lb") +region = Rect2(32, 16, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8gg3o"] +atlas = ExtResource("1_qc6lb") +region = Rect2(64, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fhs7f"] +atlas = ExtResource("1_qc6lb") +region = Rect2(64, 16, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a8i6g"] +atlas = ExtResource("1_qc6lb") +region = Rect2(64, 32, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bpol0"] +atlas = ExtResource("1_qc6lb") +region = Rect2(64, 48, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2x4wg"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 48, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5gh16"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 64, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_i6l0e"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 80, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_stn1r"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 96, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rrr4p"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 32, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3yir7"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d383k"] +atlas = ExtResource("1_qc6lb") +region = Rect2(0, 16, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_00ngh"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_2wuor") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_imavv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yhmql") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_emby7") +}], +"loop": false, +"name": &"cherry_highlighting", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_kakww") +}], +"loop": false, +"name": &"cherry_idling", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_373d3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_60pr6") +}], +"loop": false, +"name": &"cherry_showing_up", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_bj7nn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_snm2e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_41vo0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hji6o") +}], +"loop": false, +"name": &"fly_agaric_highlighting", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_ohymx") +}], +"loop": true, +"name": &"fly_agaric_idleing", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_sfcv2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_t6abu") +}], +"loop": false, +"name": &"fly_agaric_showing_up", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_eoxck") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_khlec") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_q0d5w") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_45l3f") +}], +"loop": false, +"name": &"green_apple_highlighting", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_wa1iy") +}], +"loop": true, +"name": &"green_apple_idling", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_v63jo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kglnt") +}], +"loop": false, +"name": &"green_apple_showing_up", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_8gg3o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fhs7f") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a8i6g") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bpol0") +}], +"loop": false, +"name": &"preparing", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_2x4wg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5gh16") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_i6l0e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_stn1r") +}], +"loop": false, +"name": &"red_apple_highlighting", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_rrr4p") +}], +"loop": false, +"name": &"red_apple_idling", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_3yir7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d383k") +}], +"loop": false, +"name": &"red_apple_showing_up", +"speed": 10.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_jph8c"] +size = Vector2(16, 16) + +[node name="Pickup" type="StaticBody2D"] +script = ExtResource("2_rayse") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +position = Vector2(13, 9) +sprite_frames = SubResource("SpriteFrames_00ngh") +animation = &"red_apple_showing_up" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false +shape = SubResource("RectangleShape2D_jph8c") + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]