Layer count increased to 256, palette size increased to 256

This commit is contained in:
Shylie
2024-05-15 13:33:18 -05:00
parent 615ea631e2
commit 4b7991a3a6
5 changed files with 144 additions and 73 deletions

View File

@@ -9,4 +9,13 @@ add_executable(basic WIN32
target_link_libraries(basic
PRIVATE
glerminal
)
add_executable(towers WIN32
towers.cpp
)
target_link_libraries(towers
PRIVATE
glerminal
)

83
examples/towers.cpp Normal file
View File

@@ -0,0 +1,83 @@
#include <glerminal.h>
#include <cstdlib>
#include <cmath>
namespace
{
void init()
{
for (int i = 1; i < 256; i++)
{
constexpr unsigned char c = 0;
const unsigned char v = (255 - c) * powf((i - 1) / 256.0f, 4.0f) + c;
glerminal_update_palette(i, (v << 24) | (v << 16) | (v << 8) | 0xE0);
}
for (int i = 1; i < 256; i++)
{
const unsigned char j = i;
glerminal_update_sprite(i,
{
0,j,0,0,0,0,j,0,
j,j,j,j,j,j,j,j,
0,j,0,0,0,0,j,0,
0,j,0,0,0,0,j,0,
0,j,0,0,0,0,j,0,
0,j,0,0,0,0,j,0,
j,j,j,j,j,j,j,j,
0,j,0,0,0,0,j,0,
});
}
for (int i = 0; i < 40; i++)
{
for (int j = 0; j < 25; j++)
{
for (int k = 0; k < 256; k++)
{
glerminal_set(i, j, k, k);
}
}
}
}
void mainloop(float dt)
{
static float time = 1;
time += dt;
if (time < 1.0f)
{
return;
}
else
{
time = 0;
}
const int cx = rand() % 40;
const int cy = rand() % 25;
for (int i = 0; i < 40; i++)
{
for (int j = 0; j < 25; j++)
{
for (int k = 0; k < 256; k++)
{
const float ox = 0.05f * powf(k, 0.55f) * copysignf(sqrtf((i - cx) * (i - cx)), i - cx);
const float oy = 0.05f * powf(k, 0.55f) * copysignf(sqrtf((j - cy) * (j - cy)), j - cy);
glerminal_offset(i, j, k, ox, oy);
}
}
}
glerminal_flush();
}
}
int main(int argc, char** argv)
{
glerminal_run(init, mainloop);
}