Add parsing for urchins
parent
ab2928fab9
commit
613d5642cc
|
@ -39,12 +39,9 @@ ENUMIDS_TILETYPE_MAPPING = {
|
||||||
'Player': 22,
|
'Player': 22,
|
||||||
'Chest': 23,
|
'Chest': 23,
|
||||||
'Exit': 24,
|
'Exit': 24,
|
||||||
|
'Urchin': 25,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ENTID_MAPPING = {
|
|
||||||
# 'Player': 1
|
|
||||||
#}
|
|
||||||
|
|
||||||
# First go to tilesets and find Simple_tiles identifier, then find enumTags to identifier which tile type is what tileid
|
# First go to tilesets and find Simple_tiles identifier, then find enumTags to identifier which tile type is what tileid
|
||||||
ids_tiletype_map = {}
|
ids_tiletype_map = {}
|
||||||
tileset_defs = level_pack_data["defs"]["tilesets"]
|
tileset_defs = level_pack_data["defs"]["tilesets"]
|
||||||
|
@ -137,6 +134,15 @@ with open(converted_filename, 'wb+') as out_file:
|
||||||
for ent in entity_layout["entityInstances"]:
|
for ent in entity_layout["entityInstances"]:
|
||||||
x,y = ent["__grid"]
|
x,y = ent["__grid"]
|
||||||
tiles_info[y*width + x][0] = ENUMIDS_TILETYPE_MAPPING[ent["__identifier"]]
|
tiles_info[y*width + x][0] = ENUMIDS_TILETYPE_MAPPING[ent["__identifier"]]
|
||||||
|
if ent["__identifier"] == "Urchin":
|
||||||
|
spd_encoding = 0
|
||||||
|
for urchin_data in ent['fieldInstances']:
|
||||||
|
if urchin_data["__identifier"] == "Direction":
|
||||||
|
spd_encoding |= urchin_data["__value"] << 2
|
||||||
|
elif urchin_data["__identifier"] == "SpeedLevel":
|
||||||
|
spd_encoding |= urchin_data["__value"]
|
||||||
|
|
||||||
|
tiles_info[y*width + x][0] += spd_encoding
|
||||||
|
|
||||||
out_file.write(struct.pack("<32s4H", level_name.encode('utf-8'), width, height, n_chests, level_tileset))
|
out_file.write(struct.pack("<32s4H", level_name.encode('utf-8'), width, height, n_chests, level_tileset))
|
||||||
for tile in tiles_info:
|
for tile in tiles_info:
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "ent_impl.h"
|
#include "ent_impl.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
|
#include "raymath.h"
|
||||||
|
|
||||||
void init_level_scene_data(LevelSceneData_t* data, uint32_t max_tiles, Tile_t* tiles, Rectangle view_zone)
|
void init_level_scene_data(LevelSceneData_t* data, uint32_t max_tiles, Tile_t* tiles, Rectangle view_zone)
|
||||||
{
|
{
|
||||||
data->game_rec = view_zone;
|
data->game_rec = view_zone;
|
||||||
|
@ -213,9 +215,31 @@ bool load_level_tilemap(LevelScene_t* scene, unsigned int level_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lvl_map.tiles[i].tile_type >= 25)
|
||||||
|
{
|
||||||
|
Entity_t* ent = create_urchin(&scene->scene.ent_manager);
|
||||||
|
if (ent != NULL)
|
||||||
|
{
|
||||||
|
CBBox_t* p_bbox = get_component(ent, CBBOX_COMP_T);
|
||||||
|
ent->position.x = (i % scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.x;
|
||||||
|
|
||||||
|
ent->position.y = (i / scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.y;
|
||||||
|
|
||||||
|
uint8_t spd_encoding = lvl_map.tiles[i].tile_type - 25;
|
||||||
|
float angle = 45.0f / 180.0f * PI * ((spd_encoding >> 2) & 7);
|
||||||
|
float mag = 100 * (spd_encoding & 3);
|
||||||
|
|
||||||
|
CTransform_t* p_ct = get_component(ent, CTRANSFORM_COMP_T);
|
||||||
|
p_ct->velocity = Vector2Scale(
|
||||||
|
(Vector2){cosf(angle), sinf(angle)}, mag
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue