This commit is contained in:
Jonas Braus
2024-08-04 17:23:08 +02:00
parent 2e845bf217
commit 08f75b79d8
18 changed files with 392 additions and 129 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
extends CanvasLayer
@onready var buttons = [$Control/Button_1, $Control/Button_2, $Control/Button_3,
$Control/Button_4
$Control/Button_4, $Control/Button_5
]
var available_level = 0
+14 -2
View File
@@ -2,10 +2,22 @@ extends RigidBody2D
@onready var animated_sprite_2d = $AnimatedSprite2D
@onready var animation_player = $AnimationPlayer
@export var hit_object : PackedScene
@export var auto_collect : bool
const ITEMBLOCK = preload("res://scenes/blocks/itemblock.tscn")
func _ready():
animated_sprite_2d.play("default")
func _on_activate_body_entered(body):
if body.is_big:
animation_player.play("destroy")
if hit_object == null:
if body.is_big:
animation_player.play("destroy")
else:
var inst2 = ITEMBLOCK.instantiate()
get_parent().add_child(inst2)
inst2.position.x = position.x
inst2.position.y = position.y
inst2.hit_object = hit_object
inst2.auto_collect = auto_collect
queue_free()
+19
View File
@@ -0,0 +1,19 @@
extends RigidBody2D
@export var hit_object:PackedScene
@onready var collision_shape_2d = $CollisionShape2D
func _ready():
collision_shape_2d.disabled = true
func _on_activate_body_entered(body):
if hit_object == null:
return
if body.velocity.y > 0:
return
var instance = hit_object.instantiate()
get_parent().add_child(instance)
instance.position.x = position.x
instance.position.y = position.y
queue_free()
+3 -1
View File
@@ -14,6 +14,7 @@ var is_down = false
@onready var collision_shape_2d = $CollisionShape2D
@onready var ray_cast_left_3 = $RayCastLeft3
@onready var ray_cast_right_3 = $RayCastRight3
@onready var player = %player
func _ready():
var coll = CapsuleShape2D.new()
@@ -22,7 +23,8 @@ func _ready():
collision_shape_2d.shape = coll
func _physics_process(delta):
linear_velocity.x = speed
if abs(position.x - player.position.x) < 220 or is_down:
linear_velocity.x = speed
if ray_cast_left_2 == null:
return
+3 -1
View File
@@ -11,9 +11,11 @@ extends RigidBody2D
var innocent = false
@onready var timer_2 = $Timer2
@onready var gumba = $"."
@onready var player = %player
func _physics_process(delta):
linear_velocity.x = speed
if abs(position.x - player.position.x) < 220:
linear_velocity.x = speed
if ray_cast_left_2 == null:
return
+18
View File
@@ -0,0 +1,18 @@
extends Node2D
@onready var animated_sprite_2d = $AnimatedSprite2D
@onready var collision_shape_2d = $StaticBody2D/CollisionShape2D
func _on_area_2d_body_entered(body):
animated_sprite_2d.play("down")
body.JUMPt_velocity *= 1.6
animated_sprite_2d.position.y += 8
collision_shape_2d.position.y += 8
collision_shape_2d.shape.size.y -= 16
func _on_area_2d_body_exited(body):
animated_sprite_2d.play("default")
body.JUMPt_velocity /= 1.6
animated_sprite_2d.position.y -= 8
collision_shape_2d.position.y -= 8
collision_shape_2d.shape.size.y += 16
+1 -3
View File
@@ -17,7 +17,6 @@ extends CharacterBody2D
const SPEED = 130.0
var JUMPt_velocity = -360.0
var org_jump_veloc : int
var on_pipe = false
var right_pipe = false
var left_pipe = false
@@ -70,7 +69,6 @@ func _unhandled_input(event):
func _ready():
color_rect.visible = false
org_jump_veloc = JUMPt_velocity
pipedetector_ground.position.y = 0
collision_shape_2d.shape.height = 15
@@ -85,9 +83,9 @@ func _process(delta):
# check pipe
if on_pipe and (Input.is_action_just_pressed("crawl") or crawl) and is_on_floor() or right_pipe and (Input.is_action_pressed("move_right") or t_velocity > 0):
on_pause = true
pipe_sound.play()
crawl = false
on_pause = true
t_velocity = 0
color_rect.visible = true
pipe_timer.start()