Added Pickup

This commit is contained in:
2024-09-08 17:25:44 +03:00
parent 7f44b2cbc9
commit f2a9e83bcb
8 changed files with 419 additions and 6 deletions
+1 -1
View File
@@ -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

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -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]
+1 -1
View File
@@ -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]
]
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

+37
View File
@@ -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
+61
View File
@@ -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()
+314
View File
@@ -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"]