LED Matrix Flashing

Hello All,
Ive just found a new interest in the LED matrix. Ive messed around and learned the basics for controlling it. Now I want to make a game for it, a game similar to the infamous helicopter game.

I made code for the terrain using sprites and Ive got it running the way I desire. The problem is that when you run it and get closer to the end of the animation, it does some very noticeable flashing. I assume that its a delay when it is clearing and computing. The question I have is how do I fix it? Capacitors? Change the code?

Any help would be greatly appreciated.

Thank you,
Jack

#include <Sprite.h>
#include <Matrix.h>

Matrix mat = Matrix(2, 4, 3);

Sprite a = Sprite(
8,8,
B11111111, B00111111, B00001111, B00000000, B00000000, B00000000, B01111100, B11111111
);

Sprite b = Sprite(
8,8,
B11111111, B11111100, B11110000, B00000000, B00000000, B00000001, B00000111, B11111111
);

Sprite c = Sprite(
8,8,
B11111111, B00000000, B00000000, B00000000, B01110000, B11111100, B11111111, B11111111
);

Sprite d = Sprite(
8,8,
B11111111, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B11111111
);

Sprite e = Sprite(
8,8,
B11111111, B00000000, B00000000, B00001100, B00001100, B00001100, B00000000, B11111111
);

Sprite f = Sprite(
8,8,
B11111111, B01111110, B00011000, B00000000, B00000000, B00011000, B00111100, B11111111
);

Sprite g = Sprite(
8,8,
B11111111, B00000000, B00000110, B00000110, B00000110, B00000000, B00000000, B11111111
);

Sprite h = Sprite(
8,8,
B11111111, B00000000, B00000000, B11000000, B11000000, B00000000, B00000011, B11111111
);

void setup()
{
}

int x = 0;
int t = 40; // delay time for shift

void loop()
{
mat.write(x,0,a);
mat.write(x+8,0,b);
mat.write(x+16,0,c);
mat.write(x+24,0,d);
mat.write(x+32,0,e);
mat.write(x+40,0,d);
mat.write(x+48,0,f);
mat.write(x+56,0,g);
mat.write(x+64,0,d);
mat.write(x+72,0,d);
mat.write(x+80,0,h);
mat.write(x+88,0,d);
mat.write(x+96,0,d);
delay(t);
mat.clear();
x = x-1;

}