level 2 - moving plattforms

level2 almost finished
This commit is contained in:
Jonas Braus
2024-08-02 22:44:01 +02:00
parent a4476f2ce2
commit a706375da0
18 changed files with 46260 additions and 150 deletions
+10 -1
View File
@@ -1,5 +1,14 @@
extends Area2D
@export var load_level: String
@onready var animation_player = $AnimationPlayer
@onready var player = %player
func _on_body_entered(body):
pass
animation_player.play("change_scene")
player.on_pause = true
func load_new_scene():
get_tree().change_scene_to_file("res://scenes/levels/" + load_level + ".tscn")
+6 -2
View File
@@ -4,7 +4,9 @@ extends Area2D
@onready var player = %player
func _on_body_entered(body):
body.player_die()
player.shrink()
player.shrink()
player.shrink()
func _ready():
timer.start()
@@ -14,4 +16,6 @@ func _process(delta):
label.text = x
func _on_timer_timeout():
player.player_die()
player.shrink()
player.shrink()
player.shrink()
+6
View File
@@ -0,0 +1,6 @@
extends RigidBody2D
@export var veloc : Vector2
func _physics_process(delta):
linear_velocity = veloc
+22
View File
@@ -0,0 +1,22 @@
extends Node2D
@onready var timer = $Timer
@export var obj : PackedScene
@export var delay : float
var instances = []
func _ready():
timer.wait_time = delay
timer.start()
func _on_timer_timeout():
var instance = obj.instantiate()
instance.position.x = 0
instance.position.y = 0
add_child(instance)
instances.append(instance)
if len(instances) > 5:
var curr = instances.pop_front()
curr.queue_free()
+6 -3
View File
@@ -10,6 +10,7 @@ extends RigidBody2D
@onready var ray_cast_right_2 = $RayCastRight2
var innocent = false
@onready var timer_2 = $Timer2
@onready var gumba = $"."
func _physics_process(delta):
linear_velocity.x = speed
@@ -41,10 +42,12 @@ func f_die():
animated_sprite_2d.play("die")
timer.start()
if die != null:
gumba.collision_layer = 32
die.queue_free()
die_sound.play()
ray_cast_left_2.queue_free()
ray_cast_right_2.queue_free()
die_sound.play()
ray_cast_left_2.queue_free()
ray_cast_right_2.queue_free()
func _on_die_body_entered(body):
f_die()
+9 -5
View File
@@ -67,6 +67,8 @@ func _unhandled_input(event):
func _ready():
color_rect.visible = false
pipedetector_ground.position.y = 0
collision_shape_2d.shape.height = 15
func _process(delta):
# set camera
@@ -89,7 +91,7 @@ func _process(delta):
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
if not is_on_floor() and not on_pause:
velocity.y += gravity * delta
# Handle jump.
@@ -151,17 +153,18 @@ func _physics_process(delta):
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
if not on_pause:
move_and_slide()
func grow():
if not is_big:
is_big = true
collision_shape_2d.shape.height = 32
collision_shape_2d.shape.height = 31
pipedetector_ground.position.y += 8
func flower():
if not is_big:
collision_shape_2d.shape.height = 32
collision_shape_2d.shape.height = 31
pipedetector_ground.position.y += 8
is_big = true
is_flower = true
@@ -172,7 +175,7 @@ func shrink():
shrink_sound.play()
elif is_big:
is_big = false
collision_shape_2d.shape.height = 16
collision_shape_2d.shape.height = 15
pipedetector_ground.position.y -= 8
shrink_sound.play()
else:
@@ -180,6 +183,7 @@ func shrink():
func player_die():
die_player.play("die")
on_pause = true
music.stop()
func reload_scene():