diff --git a/CMakeLists.txt b/CMakeLists.txt index e3c55a3..e5745f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ set(ASSETS_cg set(ASSETS_cg_EGA64 assets-cg/ega64/tileset/tilesetEGA64_CG.png + assets-cg/ega64/tileset/tileset_inEGA64_CG.png ) set(ASSETS_fx @@ -86,6 +87,7 @@ set(ASSETS_fx set(ASSETS_fx_1b assets-fx/1b/tileset/tileset1b.png + assets-fx/1b/tileset/tileset_in1b.png assets-fx/1b/npc/char/npc_male.png assets-fx/1b/npc/char/npc_female.png assets-fx/1b/npc/char/npc_milkman.png @@ -100,6 +102,7 @@ set(ASSETS_fx_1b set(ASSETS_fx_2b assets-fx/2b/tileset/tileset2b.png + assets-fx/2b/tileset/tileset_in2b.png assets-fx/2b/npc/char/npc_male.png assets-fx/2b/npc/char/npc_female.png assets-fx/2b/npc/char/npc_milkman.png diff --git a/assets-cg/1b/tileset/fxconv-metadata.txt b/assets-cg/1b/tileset/fxconv-metadata.txt deleted file mode 100644 index fad2b40..0000000 --- a/assets-cg/1b/tileset/fxconv-metadata.txt +++ /dev/null @@ -1,4 +0,0 @@ -tileset1b_CG.png: - type: bopti-image - name: img_tilesetnpp - profile: p8 diff --git a/assets-cg/1b/tileset/tileset1b_CG.png b/assets-cg/1b/tileset/tileset1b_CG.png deleted file mode 100644 index 089c983..0000000 Binary files a/assets-cg/1b/tileset/tileset1b_CG.png and /dev/null differ diff --git a/assets-cg/2b/sprites/SpriteTestCG2b.png b/assets-cg/2b/sprites/SpriteTestCG2b.png deleted file mode 100644 index e709b04..0000000 Binary files a/assets-cg/2b/sprites/SpriteTestCG2b.png and /dev/null differ diff --git a/assets-cg/2b/tileset/fxconv-metadata.txt b/assets-cg/2b/tileset/fxconv-metadata.txt deleted file mode 100644 index 203e19f..0000000 --- a/assets-cg/2b/tileset/fxconv-metadata.txt +++ /dev/null @@ -1,5 +0,0 @@ -tileset2b_CG.png: - type: bopti-image - name: img_tilesetnpp - profile: p8 - \ No newline at end of file diff --git a/assets-cg/2b/tileset/tileset2b_CG.png b/assets-cg/2b/tileset/tileset2b_CG.png deleted file mode 100644 index aa53e42..0000000 Binary files a/assets-cg/2b/tileset/tileset2b_CG.png and /dev/null differ diff --git a/assets-cg/ega64/tileset/fxconv-metadata.txt b/assets-cg/ega64/tileset/fxconv-metadata.txt index 15d8aeb..e8cdf0d 100644 --- a/assets-cg/ega64/tileset/fxconv-metadata.txt +++ b/assets-cg/ega64/tileset/fxconv-metadata.txt @@ -2,4 +2,8 @@ tilesetEGA64_CG.png: type: bopti-image name: img_tilesetnpp profile: p8 - \ No newline at end of file + +tileset_inEGA64_CG.png: + type: bopti-image + name: img_indoor + profile: p8 diff --git a/assets-fx/1b/tileset/fxconv-metadata.txt b/assets-fx/1b/tileset/fxconv-metadata.txt index d5e87d6..9d175fc 100644 --- a/assets-fx/1b/tileset/fxconv-metadata.txt +++ b/assets-fx/1b/tileset/fxconv-metadata.txt @@ -2,3 +2,6 @@ tileset1b.png: type: bopti-image name: img_tilesetnpp +tileset_in1b.png: + type: bopti-image + name: img_indoor diff --git a/assets-fx/2b/tileset/fxconv-metadata.txt b/assets-fx/2b/tileset/fxconv-metadata.txt index 2548038..4f2ab9a 100644 --- a/assets-fx/2b/tileset/fxconv-metadata.txt +++ b/assets-fx/2b/tileset/fxconv-metadata.txt @@ -1,3 +1,7 @@ tileset2b.png: type: bopti-image name: img_tilesetnpp + +tileset_in2b.png: + type: bopti-image + name: img_indoor diff --git a/assets/converters.py b/assets/converters.py index 63d6de5..28d224b 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -70,6 +70,8 @@ def convert_map(input: str, output: str, params: dict, target): npcs = {} signs = {} portals = {} + + indoor = 0 name = os.path.splitext(os.path.basename(input))[0] @@ -115,7 +117,7 @@ def convert_map(input: str, output: str, params: dict, target): # Get the outdoor tileset try: if VERBOSE: print("INFO: Getting the outdoor tileset") - outdoor_tileset = input_map.get_tileset_by_firstgid(1) + outdoor_tileset = input_map.get_tileset_by_name("tilesetnpp") except Exception as e: # Show a simple error message on failure. sys.stderr.write(f"ERROR: Failed to get the outdoor tileset.\n" @@ -125,12 +127,32 @@ def convert_map(input: str, output: str, params: dict, target): # Get the walkable tileset try: if VERBOSE: print("INFO: Getting the walkable tileset") - walkable_tileset = input_map.get_tileset_by_firstgid(409) + walkable_tileset = input_map.get_tileset_by_name("Walkable") except Exception as e: # Show a simple error message on failure. sys.stderr.write(f"ERROR: Failed to get the walkable tileset.\n" + f" Error message: {e}\n") sys.exit(1) + + # Check if this is an indoor map + try: + if VERBOSE: print("INFO: Checking if it is an indoor map") + indoor = int(input_map.get_property("indoor")) + except Exception as e: + # Show a warning + print(f"WARNING: Indoor property not found.\n") + + if indoor: + # Get the indoor tileset + try: + if VERBOSE: print("INFO: Getting the indoor tileset (it is an\n" + + " indoor map)") + indoor_tileset = input_map.get_tileset_by_name("indoor") + except Exception as e: + # Show a simple error message on failure. + sys.stderr.write(f"ERROR: Failed to get the indoor tileset.\n" + + f" Error message: {e}\n") + sys.exit(1) # Get the background try: @@ -141,7 +163,10 @@ def convert_map(input: str, output: str, params: dict, target): height = bg_layer.get_height() if VERBOSE: print(f"INFO: Map size: ({width}, {height}).") # Get the layer data himself - background_layer = bg_layer.get_data_with_tileset(outdoor_tileset) + if indoor: + background_layer = bg_layer.get_data_with_tileset(indoor_tileset) + else: + background_layer = bg_layer.get_data_with_tileset(outdoor_tileset) # Check if the size of the layer data is correct. if len(background_layer) != width*height: raise Exception("Bad layer size!") @@ -157,7 +182,10 @@ def convert_map(input: str, output: str, params: dict, target): if VERBOSE: print("INFO: Getting the foreground layer") fg_layer = input_map.get_layer_by_name("Foreground") # Get the layer data himself - foreground_layer = fg_layer.get_data_with_tileset(outdoor_tileset) + if indoor: + foreground_layer = fg_layer.get_data_with_tileset(indoor_tileset) + else: + foreground_layer = fg_layer.get_data_with_tileset(outdoor_tileset) # Check if the size of the layer data is correct. if len(foreground_layer) != width*height: raise Exception("Bad layer size!") @@ -252,8 +280,14 @@ def convert_map(input: str, output: str, params: dict, target): map_struct += fxconv.u32(width) map_struct += fxconv.u32(height) map_struct += fxconv.u32(3) - map_struct += fxconv.u32(outdoor_tileset.columns) - tileset_name = os.path.splitext(os.path.basename(outdoor_tileset.source))[0] + if indoor: map_struct += fxconv.u32(indoor_tileset.columns) + else: map_struct += fxconv.u32(outdoor_tileset.columns) + if indoor: + tileset_name = os.path.splitext( + os.path.basename(indoor_tileset.source))[0] + else: + tileset_name = os.path.splitext( + os.path.basename(outdoor_tileset.source))[0] map_struct += fxconv.ref(f"img_{tileset_name}") # Store the walkable layer @@ -335,6 +369,7 @@ def convert_map(input: str, output: str, params: dict, target): # separately. dialog_name = os.path.splitext(os.path.basename(dialog_file))[0] map_struct += fxconv.ref(f"_{dialog_name}") + map_struct += fxconv.u32(indoor) # Store the background layer background_data = bytes() diff --git a/assets/indoor.png b/assets/indoor.png new file mode 120000 index 0000000..578ed8f --- /dev/null +++ b/assets/indoor.png @@ -0,0 +1 @@ +../assets-fx/2b/tileset/tileset_in2b.png \ No newline at end of file diff --git a/assets/indoor.tsx b/assets/indoor.tsx new file mode 100644 index 0000000..c5bbf05 --- /dev/null +++ b/assets/indoor.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/assets/interior1_0.tmx b/assets/interior1_0.tmx index cca09fa..7299f5f 100644 --- a/assets/interior1_0.tmx +++ b/assets/interior1_0.tmx @@ -1,50 +1,76 @@ - + - - + + + - + + -86,90,91,89,90,91,89,90,91,89,90,92, -110,114,115,113,114,115,113,114,115,113,114,116, -86,93,94,1,1,1,1,1,9,10,1,92, -110,117,118,1,1,1,1,1,33,34,1,116, -86,1,1,1,1,1,1,1,1,1,1,92, -110,1,1,1,1,133,2,1,1,1,1,116, -110,1,1,1,1,2,2,1,1,1,1,92, -110,114,114,114,114,114,114,114,114,114,114,116 +425,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,427, +447,617,624,625,626,628,582,583,584,627,628,618,619,620,621,622,622,622,580,581,622,622,623,449, +447,639,646,647,648,650,604,605,606,649,650,640,641,642,643,644,644,644,602,603,644,644,645,449, +447,661,668,669,670,672,668,669,670,672,672,662,663,664,665,671,672,671,671,671,672,666,667,449, +447,691,692,693,694,691,692,693,694,691,692,691,692,693,694,630,631,630,631,630,631,630,631,449, +447,413,414,414,414,414,414,414,414,414,414,414,415,416,678,652,653,652,653,652,653,652,653,449, +447,435,436,436,436,436,436,436,436,436,436,436,437,438,678,678,678,678,678,678,678,678,678,449, +447,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,553,554,555,678,553,554,555,449, +447,678,613,614,678,613,614,678,613,614,678,678,678,678,678,678,575,576,577,678,575,576,577,449, +447,678,635,636,678,635,636,678,635,636,678,678,678,678,678,678,597,598,599,678,597,598,599,449, +447,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,449, +447,678,553,554,555,678,678,553,554,555,678,678,678,678,678,678,553,554,555,678,553,554,555,449, +447,678,575,576,577,678,678,575,576,577,611,612,678,678,611,612,575,576,577,678,575,576,577,449, +447,678,597,598,599,678,678,597,598,599,633,634,675,675,633,634,597,598,599,678,597,598,599,449, +447,678,678,678,678,678,678,678,678,678,655,656,675,675,655,656,678,678,678,678,678,678,678,449, +469,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,471 - + -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - + -410,410,410,410,410,410,410,410,410,410,410,410, -410,410,410,410,410,410,410,410,410,410,410,410, -410,410,410,0,0,0,0,0,410,0,0,410, -410,410,410,0,0,0,0,0,410,0,0,410, -410,0,0,0,0,0,0,0,0,0,0,410, -410,0,0,0,0,0,0,0,0,0,0,410, -410,0,0,0,0,0,0,0,0,0,0,410, -410,410,410,410,410,410,410,410,410,410,410,410 +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +410,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,0,0,0,0,0,0,0,410, +410,409,409,409,409,409,409,409,409,409,409,410,410,410,410,409,0,0,0,0,0,0,0,410, +410,410,410,410,410,410,410,410,410,410,410,410,409,409,410,410,410,410,410,410,410,410,410,410, +410,409,409,409,409,409,409,409,409,409,409,409,409,409,409,410,410,410,410,410,410,410,410,410, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,409,410,410,410,410,410,410,410,410,410, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,409,409,0,0,0,0,0,0,0,410, +410,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,410,410,410,0,410,410,410,410, +410,409,410,410,409,410,410,409,410,410,409,409,409,409,409,409,410,410,410,0,410,410,410,410, +410,409,410,410,409,410,410,409,410,410,409,409,409,409,409,409,410,410,410,0,410,410,410,410, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410, +410,0,410,410,410,0,0,410,410,410,0,0,0,0,0,0,410,410,410,0,410,410,410,410, +410,0,410,410,410,0,0,410,410,410,410,410,0,0,410,410,410,410,410,0,410,410,410,410, +410,0,410,410,410,0,0,410,410,410,410,410,0,0,410,410,410,410,410,0,410,410,410,410, +410,0,0,0,0,0,0,0,0,0,410,410,0,0,410,410,0,0,0,0,0,0,0,410, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410 - + diff --git a/src/game.h b/src/game.h index c1ef0a9..6179735 100644 --- a/src/game.h +++ b/src/game.h @@ -143,10 +143,11 @@ typedef struct { /* structure that contains all the dialogs for that part of the map */ uint32_t nbdialogsdata; Dialog *dialogs; + + uint32_t indoor; /* list of all the tiles to draw the background and the foreground layers */ uint16_t *layers[]; - } Map; /* This struct will contain all the data of the game. It will make it possible diff --git a/src/map.c b/src/map.c index 0314811..c4279e1 100644 --- a/src/map.c +++ b/src/map.c @@ -121,25 +121,25 @@ void map_render_by_layer(Game *game, int layer) { /* for all Layer (2 in the current configuration: Background is layer 0 and * foreground is layer 1 ) */ /* x and y will contain the position in the loop. */ - unsigned char x, y; + int x, y; /* The positions where we start drawing the tiles will be in tx and * ty. */ - unsigned short int tx, ty; + int tx, ty; /* mx and my will contain how many pixels will be hidden on x and on * y. */ - unsigned char mx, my; + int mx, my; /* dw and dh contain the amount of tiles that will be drawn on x and on * y. */ - unsigned char dw = DWIDTH / T_WIDTH + 2, dh = DHEIGHT / T_HEIGHT + 1; + int dw = DWIDTH / T_WIDTH + 2, dh = DHEIGHT / T_HEIGHT + 1; /* mw and mh will contain the height and the width of the map. */ - unsigned short int mw = map_level->w * T_WIDTH, - mh = map_level->h * T_HEIGHT; + int mw = map_level->w * T_WIDTH, + mh = map_level->h * T_HEIGHT; /* tile contains the tile to draw. */ - short int tile; + unsigned short int tile; /* The position where I start drawing */ - unsigned short int sx, sy; + int sx, sy; /* The position of the tile in the tileset. */ - unsigned short int xtile, ytile; + int xtile, ytile; /* Fix sx. */ if(player->x < DWIDTH / 2) { /* If I can't center the player because I'm near the left border of diff --git a/src/player.c b/src/player.c index 6751d15..1fea57c 100644 --- a/src/player.c +++ b/src/player.c @@ -88,25 +88,28 @@ void player_move(Game *game, Direction direction) { } /* Check if we should change map */ - Map *target = map_get_for_tile(game, - game->map_level->x + player->x / T_WIDTH + - one_px_mov[direction * 2], - game->map_level->y + player->y / T_HEIGHT + - one_px_mov[direction * 2 + 1]); - if(target != game->map_level) { - if(target->x > game->map_level->x) { - player->x = 0; + /* Disable map change for indoor maps */ + if(!game->map_level->indoor){ + Map *target = map_get_for_tile(game, + game->map_level->x + player->x / T_WIDTH + + one_px_mov[direction * 2], + game->map_level->y + player->y / T_HEIGHT + + one_px_mov[direction * 2 + 1]); + if(target != game->map_level) { + if(target->x > game->map_level->x) { + player->x = 0; + } + if(target->x < game->map_level->x) { + player->x = target->w * T_WIDTH; + } + if(target->y > game->map_level->y) { + player->y = 0; + } + if(target->y < game->map_level->y) { + player->y = target->h * T_HEIGHT; + } + game->map_level = target; } - if(target->x < game->map_level->x) { - player->x = target->w * T_WIDTH; - } - if(target->y > game->map_level->y) { - player->y = 0; - } - if(target->y < game->map_level->y) { - player->y = target->h * T_HEIGHT; - } - game->map_level = target; } }