31 lines
581 B
GDScript
31 lines
581 B
GDScript
extends Sprite2D
|
|
|
|
class_name Tile
|
|
|
|
enum States {
|
|
EMPTY,
|
|
SNAKE,
|
|
APPLE
|
|
}
|
|
|
|
@export var state : States
|
|
# 0 means no snake at all, 1 means head and the biger, the further it is from the head
|
|
@export var snake_pos := 0
|
|
@export var tile_color : TileColors
|
|
|
|
func _init():
|
|
state = States.EMPTY
|
|
|
|
func update_color():
|
|
match state:
|
|
States.EMPTY:
|
|
self.modulate = tile_color.empty
|
|
States.SNAKE:
|
|
self.modulate = tile_color.snake_body if snake_pos > 1 else tile_color.snake_head
|
|
States.APPLE:
|
|
self.modulate = tile_color.apple
|
|
pass
|
|
|
|
func _process(delta):
|
|
update_color()
|
|
pass
|