How to make code for robot like R-Hex

I could be wrong, but that looks like 6 motors to me.
And optical encoders.

You mention that you could not make the code work the way you need.
That is not adequate for us to help.

You have to tell us what you expected your code to do.
Then tell us what your code actually does and how that differs from your expectations.
Then post your code using code tags.