framerate tweaks
This commit is contained in:
parent
90d5c8bd63
commit
570643ec39
2
grid.c
2
grid.c
@ -98,7 +98,7 @@ void drawGrid(Grid* grid)
|
||||
height = grid->size/width;
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (grid->state[toIndex(grid, x, y)]) mvprintw(y, x, "x");
|
||||
if (grid->state[toIndex(grid, x, y)]) mvprintw(y, x, "X");
|
||||
else mvprintw(y, x, " ");
|
||||
}
|
||||
}
|
||||
|
10
main.c
10
main.c
@ -27,28 +27,20 @@ int main()
|
||||
// stdscr created by initscr()
|
||||
getmaxyx(stdscr, height, width);
|
||||
|
||||
Vect2i pos = {0, 0};
|
||||
Vect2i vel = {1, 1};
|
||||
|
||||
//hz
|
||||
const int FRAME_RATE = 30;
|
||||
const int FRAME_RATE = 10;
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
updateGrid(&grid);
|
||||
|
||||
usleep(DELAY);
|
||||
|
Loading…
Reference in New Issue
Block a user