crabs-game/scripts/game1/Flatfish.gd

41 lines
740 B
GDScript3
Raw Permalink Normal View History

extends Sprite
class_name Flatfish
const s = preload('res://images/game1/flatfish_s.tres')
const s_h = preload('res://images/game1/flatfish_s_h.tres')
const t = preload('res://images/game1/flatfish_t.tres')
const t_h = preload('res://images/game1/flatfish_t_h.tres')
2020-08-18 17:45:22 +02:00
var appeared = false
var half_rotation = false
2020-08-18 17:45:22 +02:00
func _init():
update_texture()
func update_texture():
if appeared:
if half_rotation:
texture = t
else:
texture = s
else:
2020-08-18 17:45:22 +02:00
if half_rotation:
texture = t_h
else:
texture = s_h
2020-08-18 17:45:22 +02:00
func appear():
appeared = true
update_texture()
func do_rotation():
half_rotation = !half_rotation
if half_rotation:
rotation_degrees += 90
update_texture()
func disappear():
appeared = false
update_texture()