Works. Generates random grid

This commit is contained in:
Sheldon Lee
2020-06-15 01:12:14 +01:00
parent 72435a2319
commit 90d5c8bd63
4 changed files with 524 additions and 169 deletions
+10 -6
View File
@@ -30,22 +30,26 @@ int main()
Vect2i pos = {0, 0};
Vect2i vel = {1, 1};
const int DELAY = 33*pow(10,3);
//hz
const int FRAME_RATE = 30;
const int DELAY = (float)pow(10,6)/(float)FRAME_RATE;
Grid grid;
initGrid(&grid, width, height);
randomizeGrid(&grid);
putPixel(&grid, pos.x, pos.y);
while (running) {
clearGrid(&grid);
putPixel(&grid, pos.x, pos.y);
drawGrid(&grid);
refresh();
moveVect2i(&pos, vel.x, vel.y);
contain(&pos.x, &vel.x, 0, width-1);
contain(&pos.y, &vel.y, 0, height-1);
//moveVect2i(&pos, vel.x, vel.y);
//contain(&pos.x, &vel.x, 0, width-1);
//contain(&pos.y, &vel.y, 0, height-1);
updateGrid(&grid);
usleep(DELAY);
}