#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include “vex.h”
using namespace vex;
// Brain should be defined by default
brain Brain;
// START V5 MACROS
#define waitUntil(condition)
do {
wait(5, msec);
} while (!(condition))
#define repeat(iterations)
for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS
// Robot configuration code.
controller Controller1 = controller(primary);
// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
#pragma endregion VEXcode Generated Robot Configuration
/----------------------------------------------------------------------------/
/* /
/ Module: main.cpp /
/ Author: {Gavin} /
/ Created: {4/6/'23} /
/ Description: DVD_Rangefinder_Project.6.0 /
/ /
/----------------------------------------------------------------------------*/
// Include the V5 Library
#include “vex.h”
using namespace vex;
void moveDVD() {
int x = 1; //Height
int y = 1; //Width
int dx = 1; //Direction of movement in the X
int dy = 1 ; //Direction of movement in the y
int screenWidth = 480;
int screenHeight = 245;
color colors[] = {color::red, color::green, color::blue, color::white, color::orange, color::purple};
int numColors = sizeof(colors) / sizeof(colors[0]);
int colorIndex = 0;
while (true) {
// Move DVD box
wait(20, msec);
Brain.Screen.setPenColor(colors[colorIndex]);
Brain.Screen.drawRectangle(x, y, 40, 20);
x += dx; //move box in x
y += dy; // move box in y
// Change direction when box hits a wall
if (x <= 0 || x + 40 >= screenWidth) {
dx = -dx;
colorIndex = (colorIndex + 1) % numColors;
}
//change color when box hits a wall
if (y <= 0 || y + 20 >= screenHeight) {
dy = -dy;
colorIndex = (colorIndex + 1) % numColors;
}
}
}
int main() {
// Start moving Box on a separate thread
thread d(moveDVD); //Call DVD Thread
}