extends RigidBody2D
var Name = "Animal"
var working_planet = "none"
var working_planet_position = Vector2(0,0)
var velocity = Vector2()
var color1 = 0
var color2 = 0
var color3 = 0
var type = 0
var action = 0
var action_time = 0
var action_speed = 1
func _ready() -> void :
var rng = RandomNumberGenerator.new()
rng.randomize()
color1 = rng.randf_range(0, 1)
rng.randomize()
color2 = rng.randf_range(0, 1)
rng.randomize()
color3 = rng.randf_range(0, 1)
$AnimatedSprite.modulate = Color(color1, color2, color3, 1)
rng.randomize()
action_speed = rng.randf_range(1,2)
func _process(delta: float) -> void:
look_at(working_planet_position)
rotation_degrees += 270
var rotating = get_rotation_degrees()
var rng = RandomNumberGenerator.new()
action_time += action_speed
if action_time >= 100 :
rng.randomize()
action = rng.randi_range(0,2)
action_time = 0
if action == 0 :
velocity = Vector2(1, 0).rotated(rotation)
if $AnimatedSprite.frame > type * 5 + 3 :
$AnimatedSprite.frame = type * 5
$AnimatedSprite.flip_h = true
elif action == 1 :
velocity = Vector2(-1, 0).rotated(rotation)
if $AnimatedSprite.frame > type * 5 + 3 :
$AnimatedSprite.frame = type * 5
$AnimatedSprite.flip_h = false
elif action == 2 :
velocity = Vector2(0,0)
$AnimatedSprite.frame = type * 5 + 4
position += velocity
pass