added more sounds and autocollect coin

This commit is contained in:
Jonas Braus
2024-07-31 19:49:20 +02:00
parent 85736f82e0
commit b18dfee7dc
10 changed files with 56 additions and 8 deletions
+7 -3
View File
@@ -9,6 +9,7 @@ extends CharacterBody2D
@onready var pipedetector_ground = $pipedetector_ground
@onready var pipe_sound = $PipeSound
@onready var jump_sound = $JumpSound
@onready var shrink_sound = $shrinkSound
const SPEED = 130.0
@@ -42,8 +43,9 @@ func _unhandled_input(event):
if event.position.x < get_viewport_rect().size.x / 2:
touch_anchor = event.position
else:
if event.position.y > get_viewport_rect().size.y / 2 and not jump:
jump = true
if event.position.y > get_viewport_rect().size.y / 2:
if not jump:
jump = true
elif not fire:
fire = true
elif event.position.x < get_viewport_rect().size.x / 2:
@@ -101,7 +103,7 @@ func _physics_process(delta):
get_parent().add_child(instance)
instance.position.x = position.x -8 if animated_sprite_2d.flip_h else position.x + 8
instance.position.y = position.y
instance.linear_velocity.x = -400 if animated_sprite_2d.flip_h else 400
instance.linear_velocity.x = -200 if animated_sprite_2d.flip_h else 200
instance.linear_velocity.y = 50
instance.angular_velocity = 0
@@ -165,10 +167,12 @@ func flower():
func shrink():
if is_flower:
is_flower = false
shrink_sound.play()
elif is_big:
is_big = false
collision_shape_2d.shape.height = 16
pipedetector_ground.position.y -= 8
shrink_sound.play()
else:
print("dead")