fix rendering order + clean up old files

This commit is contained in:
Lephenixnoir 2021-12-28 20:28:17 +01:00
parent 0a759b3541
commit ce0959f3f6
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
13 changed files with 65 additions and 25 deletions

View File

@ -35,10 +35,6 @@ set(SOURCES
)
set(ASSETS
# Tilesets
assets-cg/tileset_base.png
assets-cg/tileset_decor.png
assets-cg/tileset_base_2.png
assets-cg/tileset_decor_2.png
assets-cg/tilesets/cavern.tsx
assets-cg/tilesets/lab.tsx
# Levels

View File

@ -432,12 +432,20 @@ def convert_tiled_map(input, output, params):
p = dict()
for prop in tile.find("properties").findall("property"):
name = prop.attrib["name"]
type = prop.attrib["type"]
type = prop.attrib.get("type", "string")
value = prop.attrib["value"]
if type == "bool":
value = (value == "true")
else:
elif type == "float":
value = float(value)
elif type == "file":
pass
elif type == "int":
value = int(value)
elif type == "string":
pass
else: # including "color" and "object"
raise Exception(f"unknown tile property type {type}")
p[name] = value
tileprops[tile_id] = p
@ -453,9 +461,12 @@ def convert_tiled_map(input, output, params):
t2 = 0 if t2 < tileset_base else t2 - tileset_base
solid = 0
if t1 in tileprops and tileprops[t1].get("solid", False):
solid = 1
tiles += bytes([solid, t1, t2])
plane = "FLOOR"
if t1 in tileprops:
solid = (tileprops[t1].get("solid", False) == True)
plane = tileprops[t1].get("plane", "FLOOR")
plane = ["WALL", "FLOOR", "CEILING"].index(plane)
tiles += bytes([solid, plane, t1, t2])
o = fxconv.Structure()
o += fxconv.u16(width)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

View File

@ -3,12 +3,24 @@
<image source="cavern.png" width="128" height="32"/>
<tile id="1">
<properties>
<property name="plane" value="CEILING"/>
<property name="solid" type="bool" value="true"/>
</properties>
</tile>
<tile id="6">
<properties>
<property name="plane" value="WALL"/>
<property name="solid" type="bool" value="true"/>
</properties>
</tile>
<tile id="8">
<properties>
<property name="plane" value="WALL"/>
</properties>
</tile>
<tile id="9">
<properties>
<property name="plane" value="WALL"/>
</properties>
</tile>
</tileset>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 979 B

View File

@ -1,4 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.5" tiledversion="1.7.2" name="lab" tilewidth="16" tileheight="16" tilecount="32" columns="16">
<image source="lab.png" width="256" height="32"/>
<tileset version="1.5" tiledversion="1.7.2" name="lab" tilewidth="16" tileheight="16" tilecount="16" columns="8">
<image source="lab.png" width="128" height="32"/>
<tile id="1">
<properties>
<property name="plane" value="CEILING"/>
</properties>
</tile>
<tile id="6">
<properties>
<property name="plane" value="WALL"/>
<property name="solid" type="bool" value="true"/>
</properties>
</tile>
<tile id="8">
<properties>
<property name="plane" value="WALL"/>
</properties>
</tile>
<tile id="9">
<properties>
<property name="plane" value="WALL"/>
</properties>
</tile>
</tileset>

View File

@ -27,6 +27,8 @@ typedef struct
/* TODO: Layers of objects, stuff, dynamic elements, etc? */
/* TODO: Allow any collision shape for the tile! */
bool solid;
/* Rendering plane for that tile */
uint8_t plane;
/* Base layer: floor/wall pattern */
uint8_t base;
/* Decoration layer */

View File

@ -127,16 +127,17 @@ static void render_map_layer(map_t const *m, camera_t const *c, int layer)
vec2 tile_pos = { fix(col), fix(row) };
ivec2 p = camera_map2screen(c, tile_pos);
if(!t) {
if(!t && layer == CEILING) {
drect(p.x, p.y, p.x+15, p.y+15, C_BLACK);
continue;
}
if(t->plane != layer)
continue;
if(layer == 0) dsubimage(p.x, p.y, m->tileset,
dsubimage(p.x, p.y, m->tileset,
TILE_WIDTH * (t->base % 8), TILE_HEIGHT * (t->base / 8),
TILE_WIDTH, TILE_HEIGHT, DIMAGE_NOCLIP);
/* Decoration layer */
if(layer == 1 && t->decor) dsubimage(p.x, p.y, m->tileset,
if(t->decor) dsubimage(p.x, p.y, m->tileset,
TILE_WIDTH * (t->decor % 8), TILE_HEIGHT * (t->decor / 8),
TILE_WIDTH, TILE_HEIGHT, DIMAGE_NOCLIP);
}
@ -264,20 +265,17 @@ void render_game(game_t const *g, bool show_hitboxes)
{
camera_t const *camera = &g->camera;
/* Render map floor */
render_map_layer(g->map, camera, 0);
/* Render floor entities */
/* Render map floor and floor entities */
render_map_layer(g->map, camera, HORIZONTAL);
render_entities(g, camera, floor_depth_measure, show_hitboxes);
/* Render map walls */
render_map_layer(g->map, camera, 1);
/* Render wall entities
TODO ECS: Sort walls along wall entities! */
/* Render map walls and vertical entities
TODO ECS: Sort walls and wall entities together for proper ordering!*/
render_map_layer(g->map, camera, VERTICAL);
render_entities(g, camera, wall_depth_measure, show_hitboxes);
/* Render ceiling entities */
/* Render ceiling tiles (including out of bounds) and ceiling entities */
render_map_layer(g->map, camera, CEILING);
render_entities(g, camera, ceiling_depth_measure, show_hitboxes);
extern font_t font_rogue;