glerminal/examples/basic.cpp
Shylie 4811e4d970
All checks were successful
Make PNG / build-app (push) Successful in 56s
Allow 1-tile offscreen rendering to prevent pop-in effect
2024-06-14 12:20:31 -04:00

43 lines
680 B
C++

#include <glerminal.h>
#include <cstdlib>
#include <cmath>
namespace
{
void init()
{
glerminal_load_sprites_file("resources/basic.png");
for (int i = 0; i < GRID_WIDTH + 2; i++)
{
for (int j = 0; j < GRID_HEIGHT + 2; j++)
{
glerminal_set(i, j, 0, 1);
}
}
}
void mainloop(double dt)
{
static double time = 0;
time += dt;
time = fmodf(time, 3.1415926f * 2);
for (int i = 0; i < GRID_WIDTH + 2; i++)
{
for (int j = 0; j < GRID_HEIGHT + 2; j++)
{
glerminal_offset(i, j, 0, cosf(time - i / 3.1415f), sinf(time - j / 3.1415f));
}
}
glerminal_flush();
}
}
int main(int argc, char** argv)
{
glerminal_run({init, mainloop});
}