Clearing Two Dimensional Arrays in VexCode

I’m trying to recreate some basic games on the brain. I’ve already finished Pong, and I am now working on Tron. The game works great for the first point, but when it comes to resetting the array I use to check collisions, the game falls apart. I’m currently using a while loop just going through and manually set all the values back to zero, however I would really like to find a better way of doing this. Any Ideas?

Some steps you need to do first:

  1. Post your code

I have not tested this but the compiler accepted it.

#include <algorithm>

int main() {
  //Declare Tron / snake board
  bool tronMatrix[100][100];

  //Reset board to 0

  //Alternative way to set the values in an array. 
  //The last argument is the value.  Ex: Everything in the array is set to false.
  std::fill(&tronMatrix[0][0], &tronMatrix[0][0]+ sizeof(tronMatrix), false);

This is perfect, thank you!

Or you could declare it as global if you need it initialized to zero only once.