VEX Brain Art Problems

I and my teammate am trying to find a cool logo for the brain. We want to make dots move on the screen. We have a current program, shown below. We want to make dots move downward on the screen kinda like a lightning bolt. We start with a random amount of dots and then they are supposed to move downward with a constant Y value but a random X value. When we run the program, it only shows our logo. The dots appear in the top left corner, also known as coordinate (0,0). They don’t move, but they change colors, just like the logo.

``````Brain.Screen.clearScreen(color(0, 0, 102));
Brain.Screen.setPenColor(yellow);
Brain.Screen.setFillColor(color(0, 0, 51));
Brain.Screen.drawRectangle(-10, -10, 1000, 500);
Brain.Screen.setFont(mono40);
Brain.Screen.printAt(100,100, "teamname");
Brain.Screen.setPenColor(ClrBrown);
Brain.Screen.setFont(mono20);
Brain.Screen.printAt(195, 150, "Authentic");

//pixels
Brain.Screen.setPenColor(yellow);

int dotpos[30] = {};

int randnum = rand()%500+100;

int speed = 1;

srand(time(NULL));

for (int x = 0; x < 30; x+=3) {

if(x%3 ==0) {

dotpos[x] = rand()%250;

} else if (x%3 == 1){

dotpos[x] = rand()%500;

} else if (x%3 == 1) {

dotpos[x] = rand()%4 + 1;

}

//logo color change
while (1) {

if (Logo_Color%2 == 0) {
Brain.Screen.setPenColor(color(0, 204, 255));
} else if (Logo_Color%2 == 1) {
Brain.Screen.setPenColor(yellow);
}
Brain.Screen.setFont(prop60);
Brain.Screen.printAt(85, 100, "teamname");
Logo_Color++;

for(int x = 0; x < 30; x+=3){

Brain.Screen.drawPixel(dotpos[x], dotpos[x+1]);
int new_x = dotpos[x]; //+ dotpos[x+2];
int new_y = dotpos[x+1] + speed;

if(new_y > 250) {

speed = -speed;

} //else if (new_x < 0)

dotpos[x] = new_x;
dotpos [x+1] = new_y;

}
}
}
}
``````

But it does not work. Can anybody find what’s wrong in the code?

1 Like

Yes, but no one responded. I wanted to see if there was anyone new that was on the VEXForum who new how to fix it. I know that a lot of people do not know how to fix this but with the amount of very good and very experienced VEXFourum users that reply to many different coding problems, and a good amount of complex ones too, i was thinking that maybe they did not see my post as they were not on at the time because most only look at the top post.

1 Like

Trust me people probably saw it but did not know how, but soon enough someone will come around with the magic powers of understating code. It did not get lost in the forum. Just delete this thread or the other one.

It is not exactly clear what you are trying to do, because you have several errors in your code.

First, you declare an array of 30 ints as `dotpos[30]`.
Then you initialize only every third element (x=0,3,6,9,…) with the value of rand%250
Then you are trying to draw points using uninitialized dotpos elements (x=1,4,7,…)

I don’t want to speculate if uninitialized array elements will always default to 0, or what Brain.Screen.drawPixel() does if you pass it arguments outside of allowed range. I feel like you could simplify your algorithm at the same time as you fix those issues.

1 Like