tile experimenting
This commit is contained in:
parent
86b12bf909
commit
574f591666
@ -177,9 +177,9 @@
|
|||||||
|
|
||||||
//- Zero initialization
|
//- Zero initialization
|
||||||
#if IsLanguageC
|
#if IsLanguageC
|
||||||
#define Zi { 0 }
|
#define Zi {0}
|
||||||
#else
|
#else
|
||||||
#define Zi { }
|
#define Zi {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- Inline
|
//- Inline
|
||||||
|
|||||||
BIN
src/pp/pp_res/sprite/tiles.ase
(Stored with Git LFS)
BIN
src/pp/pp_res/sprite/tiles.ase
(Stored with Git LFS)
Binary file not shown.
@ -25,6 +25,9 @@ String S_PackWorld(Arena *arena, S_World *src_world)
|
|||||||
result.len += PushString(arena, Lit("\nentities:\n")).len;
|
result.len += PushString(arena, Lit("\nentities:\n")).len;
|
||||||
result.len += PushString(arena, Lit("{\n")).len;
|
result.len += PushString(arena, Lit("{\n")).len;
|
||||||
for (S_Ent *ent = S_FirstEnt(src_world); ent->valid; ent = S_NextEnt(ent))
|
for (S_Ent *ent = S_FirstEnt(src_world); ent->valid; ent = S_NextEnt(ent))
|
||||||
|
{
|
||||||
|
// TODO: Pack bullets
|
||||||
|
if (!ent->is_bullet)
|
||||||
{
|
{
|
||||||
result.len += StringF(arena, " 0x%F:\n", FmtHex(ent->key.v)).len;
|
result.len += StringF(arena, " 0x%F:\n", FmtHex(ent->key.v)).len;
|
||||||
result.len += PushString(arena, Lit(" {\n")).len;
|
result.len += PushString(arena, Lit(" {\n")).len;
|
||||||
@ -49,6 +52,7 @@ String S_PackWorld(Arena *arena, S_World *src_world)
|
|||||||
}
|
}
|
||||||
result.len += PushString(arena, Lit(" }\n")).len;
|
result.len += PushString(arena, Lit(" }\n")).len;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result.len += PushString(arena, Lit("}\n")).len;
|
result.len += PushString(arena, Lit("}\n")).len;
|
||||||
|
|
||||||
// Pack tiles
|
// Pack tiles
|
||||||
@ -165,9 +169,12 @@ S_UnpackedWorld S_UnpackWorld(Arena *arena, String packed)
|
|||||||
String tiles_base64 = Zi;
|
String tiles_base64 = Zi;
|
||||||
tiles_base64.text = ArenaNext(scratch.arena, u8);
|
tiles_base64.text = ArenaNext(scratch.arena, u8);
|
||||||
for (CR_Item *tile_item = top_item->first; tile_item; tile_item = tile_item->next)
|
for (CR_Item *tile_item = top_item->first; tile_item; tile_item = tile_item->next)
|
||||||
|
{
|
||||||
|
if (tile_item->name.len == 0)
|
||||||
{
|
{
|
||||||
tiles_base64.len += PushString(scratch.arena, tile_item->value).len;
|
tiles_base64.len += PushString(scratch.arena, tile_item->value).len;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (StringLenFromBase64Len(tiles_base64.len) == S_TilesCount)
|
if (StringLenFromBase64Len(tiles_base64.len) == S_TilesCount)
|
||||||
{
|
{
|
||||||
result.tiles = StringFromBase64(arena, tiles_base64).text;
|
result.tiles = StringFromBase64(arena, tiles_base64).text;
|
||||||
|
|||||||
@ -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 = 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 = 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 = 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);
|
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))
|
for (S_Ent *bullet = S_FirstEnt(world); bullet->valid; bullet = S_NextEnt(bullet))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -83,8 +83,13 @@ ComputeShader2D(V_BackdropCS, 8, 8)
|
|||||||
{
|
{
|
||||||
Vec4 result = Vec4(0.025, 0.025, 0.025, 1);
|
Vec4 result = Vec4(0.025, 0.025, 0.025, 1);
|
||||||
Vec2 world_pos = mul(params.xf.ui_to_world, Vec3(ui_pos, 1));
|
Vec2 world_pos = mul(params.xf.ui_to_world, Vec3(ui_pos, 1));
|
||||||
|
|
||||||
Vec2I32 tile_pos = S_TilePosFromWorldPos(world_pos);
|
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 = tiles.Load(Vec3I32(tile_pos, 0));
|
||||||
|
S_TileKind tile_right = tiles.Load(Vec3I32(tile_pos_right, 0));
|
||||||
|
|
||||||
f32 half_thickness = 1;
|
f32 half_thickness = 1;
|
||||||
f32 half_bounds_size = S_WorldPitch * 0.5;
|
f32 half_bounds_size = S_WorldPitch * 0.5;
|
||||||
@ -124,19 +129,19 @@ ComputeShader2D(V_BackdropCS, 8, 8)
|
|||||||
result = colors[color_idx];
|
result = colors[color_idx];
|
||||||
}
|
}
|
||||||
// Grid outline
|
// Grid outline
|
||||||
{
|
// {
|
||||||
Vec2 grid_screen_p0 = mul(params.xf.world_to_ui, Vec3(floor(world_pos), 1));
|
// 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));
|
// Vec2 grid_screen_p1 = mul(params.xf.world_to_ui, Vec3(ceil(world_pos), 1));
|
||||||
f32 grid_dist = 100000;
|
// 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_p0.x));
|
||||||
grid_dist = min(grid_dist, abs(ui_pos.x - grid_screen_p1.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_p0.y));
|
||||||
grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p1.y));
|
// grid_dist = min(grid_dist, abs(ui_pos.y - grid_screen_p1.y));
|
||||||
if (grid_dist <= half_thickness)
|
// if (grid_dist <= half_thickness)
|
||||||
{
|
// {
|
||||||
result = grid_color;
|
// result = grid_color;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// Axis
|
// Axis
|
||||||
{
|
{
|
||||||
Vec2 zero_screen = mul(params.xf.world_to_ui, Vec3(0, 0, 1));
|
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)
|
else if (tile == S_TileKind_Wall)
|
||||||
{
|
{
|
||||||
|
// Distance to edge of wall in cells
|
||||||
|
f32 wall_dist = 0;
|
||||||
result = Color_Black;
|
result = Color_Black;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// result.rgb *= wall_dist;
|
||||||
|
if (wall_dist > 1)
|
||||||
|
{
|
||||||
|
result = Color_White;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#define V_CellsPerMeter 40.0
|
#define V_CellsPerMeter 32.0
|
||||||
#define V_CellsPerSqMeter (V_CellsPerMeter * V_CellsPerMeter)
|
#define V_CellsPerSqMeter (V_CellsPerMeter * V_CellsPerMeter)
|
||||||
|
|
||||||
// #define V_MaxParticles Kibi(128)
|
// #define V_MaxParticles Kibi(128)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user