- adding coins

- performance improvements
- shake effect
- keyboard support
This commit is contained in:
megamichi 2024-11-04 19:10:10 +01:00
parent 78b4a3bba2
commit 45193fc27f
48 changed files with 609 additions and 74 deletions

20
scenes/coin/coin.gd Normal file
View file

@ -0,0 +1,20 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$AnimationPlayer.play("rotate")
func _physics_process(delta: float) -> void:
if $"/root/Global".gamerunning:
global_position.x -= $"/root/Global".speed*delta
func _on_body_entered(body: Node2D) -> void:
if body.name == "Duck":
$AnimationPlayer.play("explode")
await $AnimationPlayer.animation_finished
queue_free()
# add coin
if body.name == "hurdle":
queue_free()

BIN
scenes/coin/coin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dtn6mbn4q0plm"
path="res://.godot/imported/coin.png-08ace616f8004d0714e7855bfad24d21.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://scenes/coin/coin.png"
dest_files=["res://.godot/imported/coin.png-08ace616f8004d0714e7855bfad24d21.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

93
scenes/coin/coin.tscn Normal file
View file

@ -0,0 +1,93 @@
[gd_scene load_steps=8 format=3 uid="uid://b0au341yw6g52"]
[ext_resource type="Texture2D" uid="uid://dtn6mbn4q0plm" path="res://scenes/coin/coin.png" id="1_4vkkb"]
[ext_resource type="Script" path="res://scenes/coin/coin.gd" id="1_xp82m"]
[sub_resource type="Animation" id="Animation_jfpvc"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_64j7p"]
resource_name = "rotate"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.666667, 0.766667, 0.9),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [0, 1, 2, 1]
}
[sub_resource type="Animation" id="Animation_6xqsk"]
resource_name = "explode"
length = 0.1
step = 0.01
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.09),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_om3ic"]
_data = {
"RESET": SubResource("Animation_jfpvc"),
"explode": SubResource("Animation_6xqsk"),
"rotate": SubResource("Animation_64j7p")
}
[sub_resource type="CircleShape2D" id="CircleShape2D_qamc5"]
radius = 3.0
[node name="Coin" type="Area2D"]
script = ExtResource("1_xp82m")
[node name="Sprite" type="Sprite2D" parent="."]
texture = ExtResource("1_4vkkb")
hframes = 3
metadata/_edit_lock_ = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_om3ic")
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource("CircleShape2D_qamc5")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -0,0 +1,22 @@
extends Marker2D
var speed
func _ready() -> void:
speed = $"/root/Global".speed #get_parent().speed
_spawn()
func _spawn() -> void:
var coin = preload("res://scenes/coin/coin.tscn").instantiate()
speed = $"/root/Global".speed
var v1 = 1.5 - (speed / 200)#260
var v2 = 2.0 - (speed / 200)
coin.global_position.y -= randi_range(0,2)*16
$"../CoinSpawnTimer".wait_time = randf_range(v1,v2)
add_child(coin)
func del_all():
for child in get_children():
child.queue_free()