minor change on tileset + new inside

This commit is contained in:
bgiraudr 2021-12-23 18:37:48 +01:00
parent fce8404053
commit fbfdca746b
12 changed files with 139 additions and 40 deletions

View File

@ -15,18 +15,18 @@ add_custom_command(
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/testCarte.json"
"${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/inside/1.json"
"${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/inside/2.json"
"${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/inside/3.json"
COMMENT "Convert tmx map to json"
COMMAND tiled --export-tileset json tileset.tsx tileset.json
COMMAND tiled --export-map json testCarte.tmx testCarte.json
COMMAND tiled --export-map json inside/1.tmx inside/1.json
COMMAND tiled --export-map json inside/2.tmx inside/2.json
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/
DEPENDS assets-cg/maps/testCarte.tmx
assets-cg/tileset.png
assets-cg/maps/tileset.tsx
assets-cg/converters.py
assets-cg/maps/inside/1.tmx
assets-cg/maps/inside/2.tmx)
assets-cg/maps/inside/2.tmx
assets-cg/maps/inside/3.tmx)
set(SOURCES
src/main.c
@ -46,6 +46,7 @@ set(ASSETS_cg
assets-cg/maps/testCarte.json
assets-cg/maps/inside/1.json
assets-cg/maps/inside/2.json
assets-cg/maps/inside/3.json
assets-cg/spritesheet.png
)
@ -57,6 +58,6 @@ target_link_libraries(myaddin Gint::Gint)
target_link_options(myaddin PRIVATE -Wl,-Map=map)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "MyAddin.g3a"
NAME "MyAddin" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
generate_g3a(TARGET myaddin OUTPUT "Adoranda.g3a"
NAME "Adoranda" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

View File

@ -79,6 +79,7 @@ def convert_map(input, output, params, target):
structMap += fxconv.ref(f"img_{nameTilesetFree}")
dialogs = fxconv.Structure()
# print(indexObjectlayer)
if indexObjectlayer != None:
#generate all of the dialog
for i in data["layers"][indexObjectlayer]["objects"]:
@ -86,9 +87,14 @@ def convert_map(input, output, params, target):
#Tiled seem to start at the bottom y of the object
#So if tile is 16 px wide, you would start at line y = 1
dialogs += fxconv.u32(int(i["y"]/i["width"])-1)
for j in i["properties"]:
if(j["value"] == ""): j["value"] = " "
dialogs += fxconv.string(j["value"])
try:
for j in i["properties"]:
if(j["value"] == ""): j["value"] = " "
dialogs += fxconv.string(j["value"])
except KeyError:
dialogs += fxconv.string("default name")
dialogs += fxconv.string("default text")
structMap += fxconv.ptr(dialogs)

View File

@ -15,7 +15,7 @@
617,617,617,617,617,617,617,617,617,736,736,736,
617,617,617,617,617,617,617,617,736,736,736,736,
617,617,617,617,617,617,617,617,736,736,736,736,
617,617,238,617,617,617,617,617,617,736,736,736
617,617,0,617,617,617,617,617,617,736,736,736
</data>
</layer>
<layer id="1" name="2" width="12" height="10">
@ -28,8 +28,8 @@
736,0,702,703,0,0,0,0,248,250,249,250,
736,0,731,732,0,0,0,0,277,704,705,736,
0,0,0,0,0,0,0,0,277,733,734,0,
614,615,615,615,616,0,0,0,0,735,735,678,
643,644,238,644,645,0,0,0,0,0,0,707
614,615,615,615,615,616,0,0,0,735,735,678,
643,644,728,729,644,645,0,0,0,0,0,707
</data>
</layer>
<objectgroup id="10" name="dialog">

View File

@ -12,10 +12,10 @@
617,617,617,617,617,617,617,617,617,617,617,617,617,617,617,
736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,
736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,
736,736,736,736,617,736,736,736,736,736,736,736,736,736,736,
617,617,736,736,617,736,736,736,736,736,736,736,736,736,736,
617,617,736,736,617,736,736,736,736,736,736,736,736,736,736,
736,736,736,736,617,736,736,736,736,736,736,736,736,736,736
736,736,736,736,617,655,736,736,736,736,736,736,736,736,736,
617,617,736,736,617,655,736,736,736,736,736,736,736,736,736,
617,617,736,736,617,655,736,736,736,736,736,736,736,736,736,
736,736,736,736,617,655,736,736,736,736,736,736,736,736,736
</data>
</layer>
<layer id="12" name="2" width="15" height="10">
@ -25,11 +25,11 @@
678,0,739,739,0,0,0,0,0,0,0,739,739,646,647,
707,0,0,0,0,0,0,0,0,0,0,0,0,675,676,
0,706,706,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,560,561,0,0,0,0,614,615,615,616,0,
708,709,0,0,589,590,0,0,0,0,643,644,644,645,0,
737,738,0,0,589,590,0,0,0,0,672,673,673,674,0,
0,0,0,0,589,590,614,615,616,0,0,0,0,0,0,
0,0,0,0,589,590,643,238,645,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,614,615,615,616,0,
708,709,0,0,0,654,0,0,0,0,643,644,644,645,0,
737,738,0,0,0,654,0,0,0,0,672,673,673,674,0,
0,0,0,0,0,654,614,615,615,616,0,0,0,0,0,
0,0,0,0,0,654,643,728,729,645,0,0,0,0,0
</data>
</layer>
<layer id="13" name="3" width="15" height="10">
@ -42,8 +42,8 @@
0,0,0,0,0,0,0,0,0,0,0,702,703,0,0,
0,0,0,0,0,0,0,0,0,0,0,731,732,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,678,0,678,0,0,0,0,0,0,
0,0,0,0,0,0,707,0,707,0,0,0,0,0,0
0,0,0,0,0,0,678,0,0,678,0,0,0,0,0,
0,0,0,0,0,0,707,0,0,707,0,0,0,0,0
</data>
</layer>
<objectgroup id="14" name="Calque d'Objets 1">

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="5">
<tileset firstgid="1" source="../tileset.tsx"/>
<layer id="1" name="1" width="20" height="15">
<data encoding="csv">
682,683,683,683,683,683,683,683,683,625,626,683,683,683,683,683,683,683,683,684,
711,0,0,712,712,712,712,712,712,654,655,712,0,0,712,712,0,0,712,713,
740,741,741,741,741,741,741,741,741,654,655,741,741,741,741,741,741,741,741,742,
617,617,617,617,617,617,617,617,617,0,0,617,617,617,617,617,617,617,617,617,
736,736,736,736,736,736,736,736,736,0,0,736,736,736,736,736,736,736,736,736,
736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,736,
736,736,736,643,644,644,645,736,736,736,736,736,736,736,736,736,736,736,736,736,
736,736,736,643,644,644,645,736,736,736,736,736,736,736,736,736,736,736,736,736,
0,0,0,0,0,0,0,736,736,736,736,736,736,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,736,736,736,736,736,736,0,0,0,0,0,0,0,
617,0,617,617,617,0,617,736,736,736,736,736,736,104,104,104,104,104,104,104,
736,736,736,736,736,736,736,736,736,736,736,736,736,191,191,191,191,191,191,191,
736,736,0,0,736,736,736,736,736,736,736,736,736,191,191,191,0,0,191,191,
736,736,736,736,736,736,736,736,736,736,736,736,736,191,191,191,191,191,191,191,
736,736,736,736,736,736,736,736,736,728,729,736,736,191,191,191,191,191,191,191
</data>
</layer>
<layer id="2" name="2" width="20" height="15">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,710,710,0,0,0,0,679,0,0,0,0,710,710,0,0,710,710,0,0,
0,739,739,0,704,705,0,20,21,0,0,0,739,739,0,0,739,739,0,0,
0,0,0,0,733,734,0,49,50,654,655,0,0,0,0,0,0,0,0,0,
0,0,0,0,706,706,0,0,0,654,655,591,0,0,0,0,0,0,0,0,
0,0,591,614,615,615,616,0,0,711,713,620,0,0,0,0,0,0,0,0,
0,0,620,0,0,0,0,0,0,740,742,649,0,0,0,0,0,0,0,0,
682,683,649,683,683,683,684,0,0,0,0,0,0,682,683,683,683,683,683,684,
711,712,0,712,712,712,713,0,0,0,0,0,0,711,712,712,712,712,712,713,
740,701,0,741,741,701,742,0,0,0,0,0,0,740,741,741,741,741,741,742,
0,730,0,0,0,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,702,703,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,731,732,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<layer id="3" name="3" width="20" height="15">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,708,709,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,737,738,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,708,709,708,709,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,737,738,737,738,
0,0,683,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,712,0,679,0,0,0,0,0,0,0,0,0,0,0,680,681,0,0,
0,0,741,0,678,0,0,0,0,0,0,0,0,0,678,0,646,647,0,678,
0,0,0,0,707,0,0,0,0,0,0,0,0,0,707,0,675,676,0,707,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,735,702,703,706,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,706,731,732,735,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<objectgroup id="4" name="talk">
<object id="1" gid="267" x="64" y="64" width="16" height="16">
<properties>
<property name="name" value="Télévision"/>
<property name="text" value="&quot;Bonjour à tous !&quot;"/>
</properties>
</object>
<object id="2" gid="267" x="80" y="64" width="16" height="16"/>
</objectgroup>
</map>

View File

@ -63,7 +63,7 @@
<tile id="234" type="solid"/>
<tile id="235" type="solid"/>
<tile id="236" type="solid"/>
<tile id="237" type="door_out"/>
<tile id="237" type="air"/>
<tile id="239" type="solid"/>
<tile id="240" type="solid"/>
<tile id="241" type="solid"/>
@ -156,18 +156,25 @@
<tile id="380" type="solid"/>
<tile id="381" type="solid"/>
<tile id="382" type="solid"/>
<tile id="559" type="solid"/>
<tile id="560" type="solid"/>
<tile id="588" type="solid"/>
<tile id="589" type="solid"/>
<tile id="617" type="solid"/>
<tile id="618" type="solid"/>
<tile id="559" type="air"/>
<tile id="560" type="air"/>
<tile id="561" type="solid"/>
<tile id="588" type="air"/>
<tile id="589" type="air"/>
<tile id="590" type="solid"/>
<tile id="617" type="air"/>
<tile id="618" type="air"/>
<tile id="619" type="solid"/>
<tile id="624" type="solid"/>
<tile id="625" type="solid"/>
<tile id="634" type="solid"/>
<tile id="635" type="solid"/>
<tile id="636" type="solid"/>
<tile id="637" type="solid"/>
<tile id="645" type="solid"/>
<tile id="646" type="solid"/>
<tile id="653" type="solid"/>
<tile id="654" type="solid"/>
<tile id="655" type="solid"/>
<tile id="656" type="solid"/>
<tile id="657" type="solid"/>
@ -183,6 +190,9 @@
<tile id="674" type="solid"/>
<tile id="675" type="solid"/>
<tile id="677" type="solid"/>
<tile id="681" type="solid"/>
<tile id="682" type="solid"/>
<tile id="683" type="solid"/>
<tile id="684" type="solid"/>
<tile id="685" type="solid"/>
<tile id="686" type="solid"/>
@ -203,6 +213,9 @@
<tile id="706" type="solid"/>
<tile id="707" type="solid"/>
<tile id="708" type="solid"/>
<tile id="710" type="solid"/>
<tile id="711" type="solid"/>
<tile id="712" type="solid"/>
<tile id="713" type="solid"/>
<tile id="714" type="solid"/>
<tile id="715" type="solid"/>
@ -215,6 +228,8 @@
<tile id="722" type="solid"/>
<tile id="723" type="solid"/>
<tile id="724" type="solid"/>
<tile id="727" type="door_out"/>
<tile id="728" type="door_out"/>
<tile id="729" type="solid"/>
<tile id="730" type="solid"/>
<tile id="731" type="solid"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -12,13 +12,14 @@ struct Game {
int background;
};
enum direction {
enum action {
DIR_DOWN = 0,
DIR_LEFT = 1,
DIR_UP = 2,
DIR_RIGHT = 3,
ACTION_SHIFT = 4,
ACTION_ALPHA = 5
ACTION_ALPHA = 5,
ACTION_F1 = 6
};
/*get the input with a timeout*/

View File

@ -12,6 +12,8 @@ struct Player {
int x_mid, y_mid;
/*the direction the player facing to*/
int direction;
/*if the player is sprinting*/
int sprint;
/*current frame of the animation*/
int frame;
/*where to draw the player on the screen*/

View File

@ -20,6 +20,7 @@ void engine_draw(struct Game const *game) {
drect(0,DHEIGHT-20,DWIDTH,DHEIGHT,C_BLACK);
dprint(1,1,C_WHITE,"%d:%d",game->player->pos.x, game->player->pos.y);
dprint(1,20,C_WHITE,"%d",game->player->sprint);
}
void engine_draw_map(struct Game const *game) {
@ -49,7 +50,6 @@ void engine_draw_map(struct Game const *game) {
}
}
}
}
/*draw the player*/
@ -115,6 +115,9 @@ void engine_action(struct Game const *game, int action) {
draw_dialog(get_dialog_xy(game->map, game->player->pos.x + dx, game->player->pos.y + dy));
}
}
if(action == ACTION_F1) {
game->player->sprint = game->player->sprint ? 0 : 1;
}
}
/*check the current position of the player. To perform action depends of his location*/
@ -126,16 +129,14 @@ void engine_check_position(struct Game *game) {
if(player_curr_tile == TILE_DOOR_IN) {
old_map = game->map;
old_pos = game->player->pos;
engine_set_background(game, C_BLACK);
generate_interior_map(game);
}
if(player_curr_tile == TILE_DOOR_OUT) {
game->map = old_map;
game->player->pos = old_pos;
game->player->direction = DIR_DOWN;
game->player->anim.dir = DIR_DOWN;
engine_center_camera(game);
engine_set_background(game, C_WHITE);
}
}

View File

@ -13,7 +13,7 @@ struct Game init_game(struct Player *player) {
.map = maps[0],
.player = player,
.camera = camera_new(&player->pos_visual),
.background = C_WHITE
.background = C_BLACK
};
return game;
}
@ -38,5 +38,6 @@ int get_inputs(void) {
/*action key*/
if(key == KEY_SHIFT) return ACTION_SHIFT;
if(key == KEY_ALPHA) return ACTION_ALPHA;
if(key == KEY_F1) return ACTION_F1;
}
}

View File

@ -25,14 +25,16 @@ int map_get_player_tile(struct Game const *game) {
/*generate the interior*/
void generate_interior_map(struct Game *game) {
const int NB_INTERIORS = 2;
const int NB_INTERIORS = 3;
extern struct Map in_1;
extern struct Map in_2;
extern struct Map in_3;
struct Map *interiors[] = {
&in_1,
&in_2
&in_2,
&in_3
};
srand(game->player->pos.x * game->player->pos.y);