Animating a cude

With a state machine like:
image