tile experimenting

This commit is contained in:
jacob 2026-01-10 05:12:14 -06:00
parent 86b12bf909
commit 574f591666
6 changed files with 60 additions and 36 deletions

View File

@ -177,9 +177,9 @@
//- Zero initialization
#if IsLanguageC
#define Zi { 0 }
#define Zi {0}
#else
#define Zi { }
#define Zi {}
#endif
//- Inline

BIN
src/pp/pp_res/sprite/tiles.ase (Stored with Git LFS)

Binary file not shown.

View File

@ -26,28 +26,32 @@ String S_PackWorld(Arena *arena, S_World *src_world)
result.len += PushString(arena, Lit("{\n")).len;
for (S_Ent *ent = S_FirstEnt(src_world); ent->valid; ent = S_NextEnt(ent))
{
result.len += StringF(arena, " 0x%F:\n", FmtHex(ent->key.v)).len;
result.len += PushString(arena, Lit(" {\n")).len;
// TODO: Pack bullets
if (!ent->is_bullet)
{
result.len += StringF(arena, " props: \n").len;
result.len += StringF(arena, " {\n").len;
result.len += StringF(arena, " 0x%F:\n", FmtHex(ent->key.v)).len;
result.len += PushString(arena, Lit(" {\n")).len;
{
if (ent->is_player)
result.len += StringF(arena, " props: \n").len;
result.len += StringF(arena, " {\n").len;
{
result.len += PushString(arena, Lit(" player\n")).len;
}
if (ent->is_bullet)
{
result.len += PushString(arena, Lit(" bullet\n")).len;
if (ent->is_player)
{
result.len += PushString(arena, Lit(" player\n")).len;
}
if (ent->is_bullet)
{
result.len += PushString(arena, Lit(" bullet\n")).len;
}
}
result.len += StringF(arena, " }\n").len;
result.len += StringF(arena, " pos: \"%F\"\n", FmtFloat2(ent->xf.og)).len;
result.len += StringF(arena, " rot: \"%F\"\n", FmtFloat2(RightFromXform(ent->xf))).len;
result.len += StringF(arena, " exists: \"%F\"\n", FmtFloat(ent->exists)).len;
result.len += StringF(arena, " look: \"%F\"\n", FmtFloat2(ent->look)).len;
}
result.len += StringF(arena, " }\n").len;
result.len += StringF(arena, " pos: \"%F\"\n", FmtFloat2(ent->xf.og)).len;
result.len += StringF(arena, " rot: \"%F\"\n", FmtFloat2(RightFromXform(ent->xf))).len;
result.len += StringF(arena, " exists: \"%F\"\n", FmtFloat(ent->exists)).len;
result.len += StringF(arena, " look: \"%F\"\n", FmtFloat2(ent->look)).len;
result.len += PushString(arena, Lit(" }\n")).len;
}
result.len += PushString(arena, Lit(" }\n")).len;
}
result.len += PushString(arena, Lit("}\n")).len;
@ -166,7 +170,10 @@ S_UnpackedWorld S_UnpackWorld(Arena *arena, String packed)
tiles_base64.text = ArenaNext(scratch.arena, u8);
for (CR_Item *tile_item = top_item->first; tile_item; tile_item = tile_item->next)
{
tiles_base64.len += PushString(scratch.arena, tile_item->value).len;
if (tile_item->name.len == 0)
{
tiles_base64.len += PushString(scratch.arena, tile_item->value).len;
}
}
if (StringLenFromBase64Len(tiles_base64.len) == S_TilesCount)
{

View File

@ -902,6 +902,7 @@ void V_TickForever(WaveLaneCtx *lane)
frame->xf.world_to_ui = XformFromScale(VEC2(camera_scale, camera_scale));
frame->xf.world_to_ui = TranslateXform(frame->xf.world_to_ui, NegVec2(frame->camera_pos));
frame->xf.world_to_ui = WorldTranslateXform(frame->xf.world_to_ui, MulVec2(Vec2FromVec(frame->draw_dims), 0.5));
frame->xf.world_to_ui.og = RoundVec2(frame->xf.world_to_ui.og);
frame->xf.ui_to_world = InvertXform(frame->xf.world_to_ui);
}
}
@ -2816,7 +2817,7 @@ void V_TickForever(WaveLaneCtx *lane)
// if (0)
if (0)
{
for (S_Ent *bullet = S_FirstEnt(world); bullet->valid; bullet = S_NextEnt(bullet))
{

View File

@ -83,8 +83,13 @@ ComputeShader2D(V_BackdropCS, 8, 8)
{
Vec4 result = Vec4(0.025, 0.025, 0.025, 1);
Vec2 world_pos = mul(params.xf.ui_to_world, Vec3(ui_pos, 1));
Vec2I32 tile_pos = S_TilePosFromWorldPos(world_pos);
Vec2I32 tile_pos_right = tile_pos;
tile_pos_right.x += 1;
S_TileKind tile = tiles.Load(Vec3I32(tile_pos, 0));
S_TileKind tile_right = tiles.Load(Vec3I32(tile_pos_right, 0));
f32 half_thickness = 1;
f32 half_bounds_size = S_WorldPitch * 0.5;
@ -124,19 +129,19 @@ ComputeShader2D(V_BackdropCS, 8, 8)
result = colors[color_idx];
}
// Grid outline
{
Vec2 grid_screen_p0 = mul(params.xf.world_to_ui, Vec3(floor(world_pos), 1));
Vec2 grid_screen_p1 = mul(params.xf.world_to_ui, Vec3(ceil(world_pos), 1));
f32 grid_dist = 100000;
grid_dist = min(grid_dist, abs(ui_pos.x - grid_screen_p0.x));
grid_dist = min(grid_dist, abs(ui_pos.x - grid_screen_p1.x));
grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p0.y));
grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p1.y));
if (grid_dist <= half_thickness)
{
result = grid_color;
}
}
// {
// Vec2 grid_screen_p0 = mul(params.xf.world_to_ui, Vec3(floor(world_pos), 1));
// Vec2 grid_screen_p1 = mul(params.xf.world_to_ui, Vec3(ceil(world_pos), 1));
// f32 grid_dist = 100000;
// grid_dist = min(grid_dist, abs(ui_pos.x - grid_screen_p0.x));
// grid_dist = min(grid_dist, abs(ui_pos.x - grid_screen_p1.x));
// grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p0.y));
// grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p1.y));
// if (grid_dist <= half_thickness)
// {
// result = grid_color;
// }
// }
// Axis
{
Vec2 zero_screen = mul(params.xf.world_to_ui, Vec3(0, 0, 1));
@ -181,7 +186,18 @@ ComputeShader2D(V_BackdropCS, 8, 8)
}
else if (tile == S_TileKind_Wall)
{
// Distance to edge of wall in cells
f32 wall_dist = 0;
result = Color_Black;
// result.rgb *= wall_dist;
if (wall_dist > 1)
{
result = Color_White;
}
}

View File

@ -1,4 +1,4 @@
#define V_CellsPerMeter 40.0
#define V_CellsPerMeter 32.0
#define V_CellsPerSqMeter (V_CellsPerMeter * V_CellsPerMeter)
// #define V_MaxParticles Kibi(128)