Enhanced snail entity with new features
Added a sprite to the Snail class and implemented animations for the snail's movements. The snail now has a body and shell texture, along with an eating shadow. Also, added logic to flip the sprite based on movement direction in the 'snail_eating' state. Furthermore, made CollisionShape2D invisible for better aesthetics.
This commit is contained in:
parent
7d47bdbf5a
commit
5777a7f2f1
9 changed files with 213 additions and 4 deletions
|
|
@ -8,12 +8,15 @@ var eat_timer : float = 0.0
|
|||
|
||||
var move_to : Vector2 = Vector2.ZERO
|
||||
|
||||
var original_snail_scale : float = 0.1
|
||||
|
||||
func enter(_msg : Dictionary = {}) -> void:
|
||||
Log.pr("I am a snail and I will eat!")
|
||||
snail.eating = true
|
||||
|
||||
func exit() -> void:
|
||||
snail.eating = false
|
||||
snail.sprite.flip_h = false
|
||||
|
||||
func update(delta : float) -> void:
|
||||
eat_timer += delta
|
||||
|
|
@ -28,9 +31,15 @@ func physics_update(_delta : float) -> void:
|
|||
move_to = snail.get_random_target()
|
||||
|
||||
if snail.global_position.distance_to(move_to) > 3:
|
||||
|
||||
snail.velocity = snail.global_position.direction_to(move_to) * snail.speed
|
||||
|
||||
if move_to.x > snail.global_position.x:
|
||||
snail.sprite.scale.x = original_snail_scale
|
||||
else:
|
||||
snail.sprite.scale.x = -original_snail_scale
|
||||
|
||||
snail.move_and_slide()
|
||||
snail.look_at(move_to)
|
||||
else:
|
||||
move_to = Vector2.ZERO
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue