Initial commit
This commit is contained in:
commit
a0b34dd454
54 changed files with 1826 additions and 0 deletions
21
scripts/slime.gd
Normal file
21
scripts/slime.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends Node2D
|
||||
|
||||
@export var speed = 50
|
||||
|
||||
@onready var ray_cast_right: RayCast2D = $RayCastRight
|
||||
@onready var ray_cast_left: RayCast2D = $RayCastLeft
|
||||
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
var direction = 1
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if direction == 1 and ray_cast_right.is_colliding():
|
||||
direction = -1
|
||||
animated_sprite.flip_h = true
|
||||
|
||||
if direction == -1 and ray_cast_left.is_colliding():
|
||||
direction = 1
|
||||
animated_sprite.flip_h = false
|
||||
|
||||
position.x += direction * speed * delta
|
Loading…
Add table
Add a link
Reference in a new issue