added gumba mushroom and sound

This commit is contained in:
Jonas Braus
2024-07-29 18:54:40 +02:00
parent e06f422597
commit b339ef3c29
60 changed files with 1142 additions and 9 deletions
+26 -3
View File
@@ -5,6 +5,8 @@ extends CharacterBody2D
@onready var pipe_timer = $pipe_timer
@onready var pipe_timer_half = $pipe_timer_half
@onready var coin_amt = $CanvasLayer/Control/CoinAmt
@onready var collision_shape_2d = $CollisionShape2D
@onready var pipedetector_ground = $pipedetector_ground
const SPEED = 130.0
@@ -19,6 +21,7 @@ var coins = 0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var on_pause = false
var is_big = false
# touch controls
var touch_anchor = Vector2.ZERO
@@ -96,11 +99,20 @@ func _physics_process(delta):
# play animation
if is_on_floor():
if direction != 0:
animated_sprite_2d.play("run")
if is_big:
animated_sprite_2d.play("run_big")
else:
animated_sprite_2d.play("run")
else:
animated_sprite_2d.play("idle")
if is_big:
animated_sprite_2d.play("idle_big")
else:
animated_sprite_2d.play("idle")
else:
animated_sprite_2d.play("jump")
if is_big:
animated_sprite_2d.play("jump_big")
else:
animated_sprite_2d.play("jump")
if direction:
velocity.x = direction * SPEED
@@ -109,6 +121,17 @@ func _physics_process(delta):
move_and_slide()
func grow():
is_big = true
collision_shape_2d.shape.height = 32
pipedetector_ground.position.y += 8
func shrink():
if is_big:
is_big = false
collision_shape_2d.shape.height = 16
pipedetector_ground.position.y -= 8
func increase_coins():
coins += 1
coin_amt.text = str(coins)