x drive code

hey guys how to make a relative x drive code.
like the one in this video
But how do you do it for x drives
I am using Robotc by the way

Here is the code for RobotC:

motor[frontRight] = vexRT[Ch2] - vexRT[Ch4] - vexRT[Ch1];
motor[backRight] = vexRT[Ch2] - vexRT[Ch4] + vexRT[Ch1];
motor[frontLeft] = vexRT[Ch2] + vexRT[Ch4] + vexRT[Ch1];
motor[backLeft] = vexRT[Ch2] + vexRT[Ch4] - vexRT[Ch1];

This works for me. The right stick controls forward, backward, left, right, and all of the diagonals. While the left stick simply controls turning.

I have that part but what I want is that then I turn the robot 90 degrees and push the joystick up the robot will begin to strafe forward instead of going left/right even though that’s forward technically

The relative drive is achieved through a gyroscope sensor, which you can see if you look closely in the video.

There’s a thread about this video with code (which is probably the best thing about this forum):

What you have programmed is considered “Robot Centric”, meaning that the forward direction is defined by the direction the front of the robot is facing.

What you want is called “Field Centric” control, where the robot moves in correspondence with absolute directions. To achieve this, you need a yaw rate gyroscope. Using the gyroscope, you can tell the rotational displacement of the robot in relation to the field and then based on this value determine the motor power levels.

JPearman has some great posts on this stuff.