develop #50

Merged
cromer merged 47 commits from develop into master 2022-09-02 00:37:34 -04:00
3 changed files with 29 additions and 2 deletions
Showing only changes of commit cb81734279 - Show all commits

View File

@ -16,6 +16,7 @@ func _ready() -> void:
$AnimatedSprite.flip_h = true
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
$FloorChecker.enabled = detect_edges
Event.connect("level_loaded", self, "_on_level_loaded")
func _physics_process(_delta: float) -> void:
@ -33,6 +34,13 @@ func _physics_process(_delta: float) -> void:
if collision.collider.name == "Player":
emit_signal("player_touched")
Event.emit_signal("object_updated", self.get_name(), "Walking", global_position, velocity)
func squash() -> void:
Event.emit_signal("object_removed", self.get_name())
queue_free()
func _on_level_loaded() -> void:
Event.emit_signal("object_created", self.get_name(), "Walking", global_position, Vector2(0, 0))

View File

@ -22,6 +22,8 @@ func _ready() -> void:
if direction == 1:
$AnimatedSprite.flip_h = true
Event.connect("level_loaded", self, "_on_level_loaded")
func _physics_process(delta: float) -> void:
if $LeftWallChecker.is_colliding():
@ -29,17 +31,18 @@ func _physics_process(delta: float) -> void:
elif $RightWallChecker.is_colliding():
wall_checker_collided($RightWallChecker)
var velocity: Vector2 = Vector2(0, 0)
if not follow_path:
var target_position = position
target_position.x *= 2 * direction
position = position.move_toward(target_position, round(speed * delta))
var velocity = get_velocity_towards_target(delta)
velocity = get_velocity_towards_target(delta)
var collision = move_and_collide(velocity, true, true, true)
if collision and collision.collider.name != "Player":
var _collision = move_and_collide(velocity)
else:
var velocity = get_velocity_towards_target(delta)
velocity = get_velocity_towards_target(delta)
var collision = move_and_collide(velocity, true, true, true)
if collision and collision.collider.name != "Player":
@ -60,6 +63,8 @@ func _physics_process(delta: float) -> void:
elif start_position.x + target.x < position.x:
$AnimatedSprite.flip_h = false
Event.emit_signal("object_updated", self.get_name(), "Flying", global_position, velocity)
func get_velocity_towards_target(delta: float) -> Vector2:
var velocity = Vector2(0, 0)
@ -80,3 +85,7 @@ func wall_checker_collided(wall_checker: RayCast2D) -> void:
emit_signal("player_touched")
direction *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
func _on_level_loaded() -> void:
Event.emit_signal("object_created", self.get_name(), "Flying", global_position, Vector2(0, 0))

View File

@ -11,9 +11,14 @@ export var fall_speed = 75.0
var return_to_start: bool = false
func _ready() -> void:
Event.connect("level_loaded", self, "_on_level_loaded")
func _physics_process(delta: float) -> void:
if return_to_start:
position = position.move_toward(start_position, speed * delta)
Event.emit_signal("object_updated", self.get_name(), "Rising", global_position, velocity)
else:
var collision = move_and_collide(Vector2(0, (position.y + fall_speed) * delta))
if collision:
@ -21,7 +26,12 @@ func _physics_process(delta: float) -> void:
$AnimatedSprite.play("normal")
if collision.collider.name == "Player":
emit_signal("player_touched")
Event.emit_signal("object_updated", self.get_name(), "Falling", global_position, velocity)
if position.y <= start_position.y:
return_to_start = false
$AnimatedSprite.play("angry")
func _on_level_loaded() -> void:
Event.emit_signal("object_created", self.get_name(), "Falling", global_position, Vector2(0, 0))