diff --git a/CMakeLists.txt b/CMakeLists.txt index b641aaf..d8c8bba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,8 @@ find_package(Gint 2.9 REQUIRED) find_package(LibProf 2.4 REQUIRED) #set the color mode either to 1b or 2b -set(COLORMODE_fx 2b) -#set the color mode either to 2b or EGA64 +set(COLORMODE_fx 1b) +#set the color mode either to 1b, 2b or EGA64 set(COLORMODE_cg EGA64) fxconv_declare_converters(assets/converters.py) @@ -35,10 +35,19 @@ set(ASSETS set(ASSETS_cg assets-cg/demo_player.png + assets-cg/demo_PNJ.png + assets-cg/SignAction.png + assets-cg/NPC_Icon.png + assets-cg/SGN_Icon.png + assets-cg/INFO_Icon.png assets-cg/player_face.png assets-cg/font.png ) +set(ASSETS_cg_1b + assets-cg/levels/tileset1b_CG.png +) + set(ASSETS_cg_2b assets-cg/levels/tileset2b_CG.png ) @@ -49,6 +58,11 @@ set(ASSETS_cg_EGA64 set(ASSETS_fx assets-fx/demo_player.png + assets-fx/demo_PNJ.png + assets-fx/SignAction.png + assets-fx/NPC_Icon.png + assets-fx/SGN_Icon.png + assets-fx/INFO_Icon.png assets-fx/player_face.png assets-fx/font.png # ... @@ -64,7 +78,7 @@ set(ASSETS_fx_2b # ... ) -fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} ${ASSETS_fx_1b} ${ASSETS_fx_2b} ${ASSETS_cg_2b} ${ASSETS_cg_EGA64} WITH_METADATA) +fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} ${ASSETS_fx_1b} ${ASSETS_fx_2b} ${ASSETS_cg_1b} ${ASSETS_cg_2b} ${ASSETS_cg_EGA64} WITH_METADATA) if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_fx}} ) @@ -83,11 +97,14 @@ if("${COLORMODE_fx}" STREQUAL 2b) endif() # cg colormode +if("${COLORMODE_cg}" STREQUAL 1b) + target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR1BIT) +endif() + if("${COLORMODE_cg}" STREQUAL 2b) target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR2BIT) endif() - if("${COLORMODE_cg}" STREQUAL EGA64) target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOREGA) endif() @@ -111,6 +128,11 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) + if("${COLORMODE_cg}" STREQUAL 1b) + generate_g3a(TARGET myaddin OUTPUT "PrjPC1b.g3a" + NAME "Col RPG 1bit" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png) + endif() + if("${COLORMODE_cg}" STREQUAL 2b) generate_g3a(TARGET myaddin OUTPUT "PrjPC2b.g3a" NAME "Col RPG Grey" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png) diff --git a/README.md b/README.md index 76bbeeb..f4df062 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,20 @@ Plus d'infos sur ce projet ici : [Le projet Collaboratif de PC](https://www.plan ## Avencement du projet - A ce stade, on a déjà implémenté : - [x] Screenshots, etc. par USB -- [x] Affichage de la map selon la position du joueur +- [x] Affichage de la map courante selon la position du joueur - [x] Gestion des touches - [x] Gestion des collisions +- [x] Multiple cartes avec importation automatique des fichiers `world` issus de Tiled - [x] Carte Multilayer (Background, Foreground + accessibilité / Dommages) avec transparence du calque Foreground - [x] Personnage - [x] Dialogues (sauts de lignes et mots plus grands que l'écran pas supportés) - [ ] Fontes de caractères - [ ] Interaction - [ ] NPC -- [ ] Changement de map +- [x] Changement de map durant le jeu ## Crédits @@ -27,5 +27,5 @@ Les tiles sont issues de Game Boy Top-down RPG Fantasy Tileset (FREE) Converties en niveau de gris avec Gimp -Une version 1-bit (N&B) à été réalisée par Shadow15510 -Et une version couleur CG à été réalisée par Fcalva +Une version 1-bit (N&B) à été réalisée par Shadow15510 +Et une version couleur CG (palette EGA64) à été réalisée par Fcalva diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..46d445e --- /dev/null +++ b/TODO.txt @@ -0,0 +1,6 @@ +[OK] - Jeu de tuile 1bit pour CG pour avoir la version 1bit vérifiable en fonctionnement dans l'émulateur de Heath +[OK] - corriger les tuiles 1bit pour les rivières (tiles 1 2 3 et 4) avec niveaux de diphering pour tiles 1 et 3 (gris 33% et 66%) +[OK] - ajouter face pour dialogue pour PNJ +[OK] - ajouter indicateur visuel pour action joueur quand on est proche d'un PNJ ou d'un panneau + +- faire des fonts lisibles avec le set `print` disponible intégralement \ No newline at end of file diff --git a/assets-cg/INFO_Icon.png b/assets-cg/INFO_Icon.png new file mode 100644 index 0000000..f07aa4e Binary files /dev/null and b/assets-cg/INFO_Icon.png differ diff --git a/assets-cg/NPC_Icon.png b/assets-cg/NPC_Icon.png new file mode 100644 index 0000000..60597e5 Binary files /dev/null and b/assets-cg/NPC_Icon.png differ diff --git a/assets-cg/SGN_Icon.png b/assets-cg/SGN_Icon.png new file mode 100644 index 0000000..2659532 Binary files /dev/null and b/assets-cg/SGN_Icon.png differ diff --git a/assets-cg/SignAction.png b/assets-cg/SignAction.png new file mode 100644 index 0000000..891b824 Binary files /dev/null and b/assets-cg/SignAction.png differ diff --git a/assets-cg/demo_PNJ.png b/assets-cg/demo_PNJ.png new file mode 100644 index 0000000..f776fdc Binary files /dev/null and b/assets-cg/demo_PNJ.png differ diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt index 2d52907..9b21fe9 100644 --- a/assets-cg/fxconv-metadata.txt +++ b/assets-cg/fxconv-metadata.txt @@ -2,10 +2,30 @@ demo_player.png: type: bopti-image name: demo_player_img +demo_PNJ.png: + type: bopti-image + name: demo_PNJ_img + player_face.png: type: bopti-image name: player_face_img +SignAction.png: + type: bopti-image + name: SignAction_img + +INFO_Icon.png: + type: bopti-image + name: INFO_Icon_img + +NPC_Icon.png: + type: bopti-image + name: NPC_Icon_img + +SGN_Icon.png: + type: bopti-image + name: SGN_Icon_img + font.png: name: fontRPG type: font diff --git a/assets-cg/levels/fxconv-metadata.txt b/assets-cg/levels/fxconv-metadata.txt index 5caafd2..de727b0 100644 --- a/assets-cg/levels/fxconv-metadata.txt +++ b/assets-cg/levels/fxconv-metadata.txt @@ -1,3 +1,7 @@ +tileset1b_CG.png: + type: bopti-image + name: img_tilesetnpp + tileset2b_CG.png: type: bopti-image name: img_tilesetnpp diff --git a/assets-cg/levels/tileset1b_CG.png b/assets-cg/levels/tileset1b_CG.png new file mode 100644 index 0000000..089c983 Binary files /dev/null and b/assets-cg/levels/tileset1b_CG.png differ diff --git a/assets-fx/INFO_Icon.png b/assets-fx/INFO_Icon.png new file mode 100644 index 0000000..b204c4b Binary files /dev/null and b/assets-fx/INFO_Icon.png differ diff --git a/assets-fx/NPC_Icon.png b/assets-fx/NPC_Icon.png new file mode 100644 index 0000000..dd61d33 Binary files /dev/null and b/assets-fx/NPC_Icon.png differ diff --git a/assets-fx/SGN_Icon.png b/assets-fx/SGN_Icon.png new file mode 100644 index 0000000..dc041e3 Binary files /dev/null and b/assets-fx/SGN_Icon.png differ diff --git a/assets-fx/SignAction.png b/assets-fx/SignAction.png new file mode 100644 index 0000000..ced6850 Binary files /dev/null and b/assets-fx/SignAction.png differ diff --git a/assets-fx/demo_PNJ.png b/assets-fx/demo_PNJ.png new file mode 100644 index 0000000..8198c59 Binary files /dev/null and b/assets-fx/demo_PNJ.png differ diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt index 0bfccdd..499f659 100644 --- a/assets-fx/fxconv-metadata.txt +++ b/assets-fx/fxconv-metadata.txt @@ -2,10 +2,29 @@ demo_player.png: type: bopti-image name: demo_player_img +demo_PNJ.png: + type: bopti-image + name: demo_PNJ_img + player_face.png: type: bopti-image name: player_face_img +SignAction.png: + type: bopti-image + name: SignAction_img + +INFO_Icon.png: + type: bopti-image + name: INFO_Icon_img + +NPC_Icon.png: + type: bopti-image + name: NPC_Icon_img + +SGN_Icon.png: + type: bopti-image + name: SGN_Icon_img font.png: name: fontRPG diff --git a/assets-fx/levels/backup/tileset1b.png b/assets-fx/levels/backup/tileset1b.png new file mode 100644 index 0000000..63f9c7b Binary files /dev/null and b/assets-fx/levels/backup/tileset1b.png differ diff --git a/assets/converters.py b/assets/converters.py index ce4c33d..cd3b933 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -27,15 +27,14 @@ def convert_world(input, output, params, target): print( "So let's go ... ") structWorld = fxconv.Structure() - - for i in range(nbMaps): + #structExtra = fxconv.Structure() + for i in range(nbMaps): nameMap = data["maps"][i]["fileName"].replace(".tmx","") nameMapFree = nameMap.split("/")[-1] #count the number of "back" (cd ..) to locate the map on the computer nbRetour = nameMap.count("..")+1 #create the map absolute path - nameTMX = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".tmx" nameJSON = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json" @@ -43,7 +42,6 @@ def convert_world(input, output, params, target): commandline = 'tiled --export-map json ' + nameTMX + ' ' + nameJSON print( "TILED COMMAND LINE FOR MAPS : ", commandline ) os.system( commandline ) - mapPath = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json" print("Map ", i , " name : ", mapPath ) @@ -60,19 +58,29 @@ def convert_world(input, output, params, target): ymax = data["maps"][i]["y"] + data["maps"][i]["height"] print( "ymax = ", ymax ) - map = convert_map( mapPath, output, params, target, xmin, ymin, xmax, ymax) + map = get_tile_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax) print( "Map = ", map ) structWorld += fxconv.ptr( map ) + #ext = get_extra_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax ) + #print( "Data = ", ext ) + #if (ext!=fxconv.u32(0)): structExtra += fxconv.ptr( ext ) + structWorld += fxconv.u32(0) + #structExtra += fxconv.u32(0) + """ + #and all the extra data (PNJ, SGN, ...) + fxconv.elf_multi( + [("_" + params["varMapData"], structWorld), + ("_" + params["varExtraData"], structExtra)], + output, **target) + """ #generate ! fxconv.elf(structWorld, output, "_" + params["name"], **target) - - -def convert_map(input, output, params, target, xmin, ymin, xmax, ymax): +def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax): print( "WE ARE COMPUTING THE MAP : ", input ) data = json.load(open(input, "r")) @@ -131,7 +139,7 @@ def convert_map(input, output, params, target, xmin, ymin, xmax, ymax): print( "Walkable Tile Data in layer : ", layer_walkable) break elif i==nbTilelayer: - printf( "ERROR : No Walkable layer data !!!" ) + print( "ERROR : No Walkable layer data !!!" ) walk_data = bytes() layer = data["layers"][layer_walkable] @@ -142,6 +150,18 @@ def convert_map(input, output, params, target, xmin, ymin, xmax, ymax): structMap += fxconv.ptr(walk_data) + nbextra = 0 + extradata = fxconv.Structure() + + nbextra, extradata = get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax) + + if (nbextra==0): + structMap += fxconv.u32( 0 ) + structMap += fxconv.u32( 0 ) + else: + structMap += fxconv.u32( int(nbextra) ) + structMap += fxconv.ptr( extradata ) + #extraction of the data contained in the layer "Background" and "Foreground" of the map @@ -154,7 +174,7 @@ def convert_map(input, output, params, target, xmin, ymin, xmax, ymax): print( "Background Tile Data in layer : ", layer_background) break elif i==nbTilelayer: - printf( "ERROR : No Background layer data !!!" ) + print( "ERROR : No Background layer data !!!" ) layer_data = bytes() layer = data["layers"][layer_background] @@ -180,8 +200,54 @@ def convert_map(input, output, params, target, xmin, ymin, xmax, ymax): layer_data += fxconv.u16(tile-1) structMap += fxconv.ptr(layer_data) - #generate ! - #fxconv.elf(structMap, output, "_" + params["name"], **target) return structMap + + +def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax): + print( "WE ARE COMPUTING THE EXTRA DATA OF THE MAP : ", input ) + data = json.load(open(input, "r")) + + + nblayer = ["id" in i for i in data["layers"]].count(True) - 1 + print( "I found ", nblayer, " of extradata") + + #index of the various layers (may change from one map to another) + layer_extradata = 0 + + #import the foreground layer of the map + for i in range(nblayer+1): + datavalid = data["layers"][i] + if datavalid["name"]=="ExtraData": + layer_extradata = i + print( "Extra Data in layer : ", layer_extradata) + break + elif i==nblayer: + print( "ERROR : No ExtraData layer data !!!" ) + return 0, fxconv.u32(0) + + #create the structure of the map + structData = fxconv.Structure() + + + nbExtraData = 0 + layer = data["layers"][layer_extradata] + for i in layer["objects"]: + nbExtraData = nbExtraData + 1 + x = i["x"] + xmin + y = i["y"] + ymin + nme = i["name"] + tpe = i["type"] + for j in i["properties"]: + stg = j[ "value" ] + print( "OBJECT X= ", x, " Y= ", y, "STR= ", stg ) + print( " Type= ", tpe, " Name= ", nme ) + + structData += fxconv.u16( int(x) ) + structData += fxconv.u16( int(y) ) + structData += fxconv.string( nme ) + structData += fxconv.string( tpe ) + structData += fxconv.string( stg ) + + return nbExtraData, structData diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt index 77b9eb0..d38d6f6 100644 --- a/assets/fxconv-metadata.txt +++ b/assets/fxconv-metadata.txt @@ -3,6 +3,9 @@ # name_regex: (.*)\.json map_\1 -*.world: +WorldRPG.world: custom-type: world + #name: xxx #unused but mandatory (Do not touch) + #varMapData: worldRPG + #varExtraData: extraRPG name: worldRPG diff --git a/assets/level0.tmx b/assets/level0.tmx index 0fd416f..e6fd8eb 100644 --- a/assets/level0.tmx +++ b/assets/level0.tmx @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@ 301,2,2,2,2,2,385,2,2,2,2,2,2,2,2,2,301,2,386,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,49,9,10,134,135,52,393,394,395,396,337,338,2, 325,149,150,151,152,2,2,327,374,375,327,2,2,185,374,375,325,387,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,73,33,34,74,219,76,2,2,2,2,361,362,2, 257,2,2,385,2,2,385,2,265,266,2,2,208,209,352,353,257,2,2,2,2,2,2,297,298,299,300,2,2,2,2,25,26,27,27,97,98,99,98,99,100,26,26,27,28,131,2,2, -281,176,2,2,2,2,2,385,289,290,2,2,232,233,376,377,281,2,326,2,154,153,190,2,2,2,2,2,2,2,2,49,2,2,2,121,59,60,60,61,124,2,2,2,52,132,2,2, +281,176,2,2,2,2,176,385,289,290,2,2,232,233,376,377,281,2,326,2,154,153,190,2,2,2,2,2,2,2,2,49,2,2,2,121,59,60,60,61,124,2,2,2,52,132,2,2, 2,2,2,2,2,385,2,2,265,266,2,385,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,73,2,2,2,145,83,84,84,85,148,2,2,2,76,132,2,2, 2,2,2,2,326,2,385,2,265,266,2,2,2,2,2,2,2,2,2,2,2,2,190,2,2,2,2,2,2,385,2,49,404,405,2,169,107,108,108,109,172,2,402,403,76,132,2,2, 2,2,2,2,2,2,2,2,289,290,2,258,259,260,238,239,260,260,261,262,262,263,264,2,2,2,2,2,2,2,385,49,134,135,2,2,2,2,2,2,2,2,134,135,52,132,297,298, @@ -90,10 +90,40 @@ - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/level1.tmx b/assets/level1.tmx index 9fd42bb..20e3824 100644 --- a/assets/level1.tmx +++ b/assets/level1.tmx @@ -1,7 +1,7 @@ - + - + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, @@ -16,16 +16,16 @@ 2,293,1,1,1,1,1,1,1,1,1,1,1,1,272,2,2,2,2,270,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,267,268,269,1,1,1,1,1,1,1,1,1,1, 2,2,269,1,1,1,1,1,1,319,319,269,1,1,1,316,271,316,271,317,1,1,1,1,319,319,319,268,268,319,319,319,268,319,320,2,2,318,319,320,268,269,1,1,1,1,1,1, 2,2,2,269,1,1,1,1,320,2,2,2,269,1,1,1,1,1,1,1,1,1,267,2,2,2,2,2,2,2,2,2,2,2,2,2,2,219,2,2,2,318,319,320,269,1,1,1, -2,2,2,2,319,268,319,320,2,2,2,2,318,319,269,1,1,1,1,1,1,267,2,2,2,2,313,265,242,266,241,219,314,313,242,241,289,314,219,2,2,2,2,2,2,269,1,1, -27,26,27,26,27,28,2,2,2,2,2,2,2,2,318,319,319,268,268,319,319,320,2,2,2,219,2,2,2,2,266,241,289,290,266,265,290,313,266,297,298,299,300,2,2,318,319,320, +2,2,2,2,319,268,319,320,2,2,2,2,318,319,269,1,1,1,1,1,1,267,2,2,2,2,313,265,242,266,241,219,314,313,242,241,2,2,219,2,2,2,2,2,2,269,1,1, +27,26,27,26,27,28,2,2,2,2,2,2,2,2,318,319,319,268,268,319,319,320,2,2,2,219,2,2,2,2,266,241,289,290,266,265,2,2,2,297,298,299,300,2,2,318,319,320, 2,50,51,51,99,100,132,2,2,2,2,2,2,2,2,2,2,2,2,314,265,2,2,2,2,313,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,74,75,76,16,17,133,2,2,2,2,2,2,2,2,2,2,2,241,219,290,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 98,98,99,100,40,41,290,314,297,298,299,300,2,2,2,2,2,219,219,289,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,2, -121,122,123,124,64,65,265,289,313,289,241,265,219,2,2,2,2,290,314,2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, -145,146,147,148,132,2,2,2,2,2,2,314,314,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2, +121,122,123,124,64,65,265,289,313,289,241,265,219,2,2,2,2,290,314,2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,402,403,2,374,375,2,404,405,2,2,2,2,2,2, +145,146,147,148,132,2,2,2,2,2,2,314,314,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 169,170,171,172,133,2,2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,385,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,385,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,345,346,347,348,2,2,2,2,2,2,2,2,2, -2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,385,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,369,370,371,372,297,298,299,300,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,385,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,369,370,371,372,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,385,2,2,2,2,2,2,2,2,2,2,2,2,2,393,394,395,396,2,2,2,2,2,297,298,299,300, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,2,2 @@ -46,13 +46,13 @@ 251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,0, 275,276,0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,201,202,203,204,0, 0,0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,225,226,227,228,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,0, -0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,249,250,251,252,0,225,226,227,228,0,0,0,0,0,201,202,203,204,0,0,0,0,249,250,251,252,0, -0,0,0,0,0,0,0,0,273,274,275,276,0,201,202,203,204,0,0,0,0,273,274,275,276,0,249,250,251,252,201,202,203,204,0,225,226,227,228,0,0,0,0,273,274,275,276,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,273,274,275,276,225,226,227,228,0,249,250,251,252,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,201,202,203,204,0,0,0,0,0,249,250,251,252,0,273,274,275,276,201,202,203,204,0,0,0,0,0, -0,0,0,0,0,0,0,201,202,203,204,0,0,273,274,275,276,0,0,0,0,225,226,227,228,0,0,0,0,0,273,274,275,276,0,0,0,0,0,225,226,227,228,0,201,202,203,204, -0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,201,202,203,204,201,202,203,204,0,0,0,0,0,249,250,251,252,0,225,226,227,228, -204,0,0,201,202,203,204,249,250,251,252,201,202,203,204,0,0,0,0,0,0,273,274,275,276,0,225,226,227,228,225,226,227,228,0,0,0,0,0,273,274,275,276,0,249,250,251,252, +0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,249,250,251,252,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0, +0,0,0,0,0,0,0,0,273,274,275,276,0,201,202,203,204,0,0,0,0,273,274,275,276,0,249,250,251,252,201,202,203,204,354,355,0,0,0,0,356,357,0,273,274,275,276,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,273,274,275,276,225,226,227,228,378,379,0,350,351,0,380,381,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,201,202,203,204,0,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,201,202,203,204,0,0,273,274,275,276,0,0,0,0,225,226,227,228,0,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,201,202,203,204, +0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,201,202,203,204,201,202,203,204,0,0,0,0,0,0,0,0,0,0,225,226,227,228, +204,0,0,201,202,203,204,249,250,251,252,201,202,203,204,0,0,0,0,0,0,273,274,275,276,0,225,226,227,228,225,226,227,228,0,0,0,0,0,0,0,0,0,0,249,250,251,252, 228,0,0,225,226,227,228,273,274,275,276,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,249,250,251,252,0,0,0,0,0,0,0,0,0,0,273,274,275,276, 252,0,0,249,250,251,252,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 276,0,0,273,274,275,276,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @@ -64,26 +64,34 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,414,414,414,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0, -0,0,0,414,414,414,414,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,414,414,414,414,414,414,414,414,0,0,0,0,414,414, -0,0,414,414,414,414,414,414,414,414,414,414,414,414,0,0,0,0,0,0,0,0,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, -412,414,414,414,414,414,414,414,414,414,414,414,414,414,0,0,412,412,0,0,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, -0,414,414,414,414,414,414,414,414,414,414,414,414,414,414,0,0,0,0,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, -0,0,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,0,0,414,414,414,414,414,414,414,414,414,414,414, -0,0,0,414,414,414,414,414,414,0,0,0,414,414,414,414,414,414,414,414,414,414,414,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,414,414,414,414,414,414,414, -0,0,0,0,414,414,414,414,0,0,0,0,414,414,414,414,414,414,414,414,414,414,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,414,414,414, -412,412,412,412,412,412,0,0,0,0,0,0,0,0,414,414,414,414,414,414,414,414,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,414,414,414, -0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0, +0,0,0,412,412,412,412,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,412,412,412,412,412,412,412,412,0,0,0,0,412,412, +0,0,412,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412, +410,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,410,410,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412, +0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412, +0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,412,412,412,412,412,412,412,412,412,412,412, +0,0,0,412,412,412,412,412,412,0,0,0,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412, +0,0,0,0,412,412,412,412,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412, +410,410,410,410,410,410,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,412,412,412, +0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0, -412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0, -412,412,412,412,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,412,412,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,0,0,0,0,0,412,412,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,412,412,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,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,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,0,0,0,0,410,410,0,410,410,0,410,410,0,0,0,0,0,0, +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,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,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,410,410,0,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,0,0,0,0,0,0,410,410,0, +0,0,0,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,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + diff --git a/assets/level2.tmx b/assets/level2.tmx index 0d65f1f..6d1fb52 100644 --- a/assets/level2.tmx +++ b/assets/level2.tmx @@ -1,7 +1,7 @@ - + - + 2,2,2,2,386,2,2,2,2,2,2,325,2,290,265,2,349,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299, @@ -12,13 +12,13 @@ 2,2,2,2,2,2,2,2,2,2,2,2,2,290,266,2,2,2,385,2,297,298,299,300,2,2,2,2,2,2,2,9,10,2,2,283,283,3,115,111,112,113,3,312,312,131,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,386,266,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,33,34,385,2,283,283,3,114,114,115,114,3,312,312,132,385,2, 2,386,2,2,2,2,2,2,2,2,2,2,2,313,290,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,282,283,3,3,3,3,3,3,312,288,132,2,2, -2,2,2,297,298,299,300,2,345,346,347,348,2,265,266,2,2,149,150,151,152,149,150,151,152,149,150,151,152,149,150,151,152,2,2,282,283,3,3,3,3,3,3,287,288,132,2,2, -2,2,2,2,2,2,2,386,369,370,371,372,2,266,290,2,2,2,2,2,2,385,2,2,2,2,385,2,2,2,2,2,2,2,2,282,283,3,3,3,3,3,3,312,312,132,2,2, -2,2,2,2,2,2,386,2,393,394,395,396,2,290,266,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,282,283,3,3,3,3,3,3,312,288,132,2,2, -2,2,2,2,2,385,2,2,2,2,2,2,2,386,313,2,2,149,149,150,151,149,150,151,152,149,150,151,152,149,150,151,152,2,2,282,330,308,308,308,308,308,308,311,312,132,2,2, +2,2,2,297,298,299,300,2,345,346,347,348,2,265,266,2,2,374,375,151,152,149,150,151,152,149,150,374,375,149,150,151,152,2,2,282,283,3,3,3,3,3,3,287,288,132,2,2, +2,2,2,2,2,2,2,386,369,370,371,372,2,266,290,208,209,352,353,2,2,385,2,2,2,2,385,2,2,2,2,2,2,2,2,282,283,3,3,3,3,3,3,312,312,132,2,2, +2,2,2,2,2,2,386,2,393,394,395,396,2,290,266,232,233,376,377,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,282,283,3,3,3,3,3,3,312,288,132,2,2, +2,2,2,2,2,385,2,2,2,2,2,2,2,386,313,2,2,149,149,374,375,149,150,151,152,374,375,151,152,149,150,151,152,2,2,282,330,308,308,308,308,308,308,311,312,132,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,266,290,2,2,2,2,2,2,2,2,2,2,385,2,2,385,2,2,2,2,2,2,330,331,331,331,331,331,331,331,331,336,132,2,2, 2,297,298,299,300,2,2,2,2,2,2,2,2,265,266,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,90,91,92,162,163,164,165,90,91,92,132,2,2, -2,2,2,2,2,2,2,2,2,2,2,2,2,266,290,2,2,149,150,151,152,149,150,151,152,149,150,151,152,149,150,151,152,2,2,114,115,116,186,187,188,189,114,115,116,132,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,266,290,2,2,149,150,151,152,149,150,154,154,149,150,151,152,149,150,151,152,2,2,114,115,116,186,187,188,189,114,115,116,132,2,2, 2,385,386,386,2,2,2,2,2,2,2,2,2,313,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,110,113,110,210,211,212,213,113,110,113,133,2,2, 2,385,2,2,2,2,2,2,2,2,2,2,2,290,265,2,2,2,2,2,2,2,2,386,2,2,2,2,385,2,2,2,2,2,2,2,2,2,234,290,265,237,2,2,2,2,385,2, 2,2,2,2,2,2,297,298,299,300,2,2,2,386,266,2,2,2,2,2,2,2,2,386,386,2,2,2,2,2,2,2,2,2,2,2,160,161,386,386,266,2,2,2,2,385,385,2, @@ -39,13 +39,13 @@ 0,0,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,125,126,127,128,125,126,127,128,125,126,127,128,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,350,351,127,128,125,126,127,128,125,126,350,351,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,125,125,126,127,125,126,127,128,125,126,127,128,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,125,125,350,351,125,126,127,128,350,351,127,128,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,125,126,127,128,125,126,127,128,125,126,127,128,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,125,126,173,128,125,126,130,174,125,126,127,128,125,126,127,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,137,0,0,0,0,0,0,0,0,0,0, @@ -60,30 +60,50 @@ -0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412, -0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0, -412,412,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,412,412,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,412,412,0,0,412,412,412,412,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,412,412,412,412,412,412,412,412,412,412,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,0,412,412,412,412,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,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,0,0,0,0, +410,410,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,410,410,410,410,410,410,410,410,410,410,410,410,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,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,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,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,410,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,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,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,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,0,0,0, +0,0,0,0,410,410,0,0,410,410,410,410,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0,410,410,410,410,410,410,410,410,410,410,0,0,0, +0,0,0,0,0,0,0,0,410,410,410,410,0,0,0,410,411,411,411,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,0,0,0, +0,0,0,0,0,0,0,0,410,410,410,410,0,0,0,411,411,411,411,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,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,0,0,410,410,410,410,410,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,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,0,0,0, +0,0,410,410,0,0,0,0,0,0,0,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,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,0,0,410,410,410,410,410,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,410,410,0,0,0,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,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + diff --git a/assets/level3.tmx b/assets/level3.tmx index f260e15..d756a70 100644 --- a/assets/level3.tmx +++ b/assets/level3.tmx @@ -1,7 +1,7 @@ - + - + 300,2,2,297,298,299,300,2,2,2,2,297,298,299,300,2,2,2,2,2,2,339,340,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, @@ -60,30 +60,62 @@ -0,0,0,0,412,412,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,0,412,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,0,412,412, -412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,412,412, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,0, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,412,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,0, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,412,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,0, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,412,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,412,0,0,412,412,412,412,0,0,412,0,0,0, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,412,0,0,0,0,0,0,0,0,0,412,0,0,0,412,412,0,0,0,412,412,412,412,0,0,412,412,412,412,0,0,0, -412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,412,412,412,412,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,412,412,412,412,412,412,412,412,0,412,412,412,412,0,412,412,412,412,0,0,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,0,0,412, -0,0,412,0,0,0,0,0,0,412,0,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,412,0,0,0,0,0,0,412,0,412,412,412,412,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,0,0,0,0,0,0,0,0, -0,0,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0, -0,0,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0, -0,0,412,0,0,412,412,412,412,412,0,0,0,0,0,0,412,412,412,412,412,412,412,412,412,412,412,412,0,0,0,0,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0, -0,0,412,412,412,412,0,0,412,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,0,0,0,0,412,0,0,0,0,412,412,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,0,0,412,412,412,412,412,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,412,412,412,412,0,0,412,412,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,0,0,0,0,0,0,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,412,412,0,412,412,412,412,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,412,412,412,412,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,412,412,0,0,0,0,0,412,412,412,412,0,0, -0,0,412,412,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,0,412,412,412,412,0,412,412,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,412,412,412,412,0,0,0,0,0,0,0,412,0,0,0,0,0,0 +0,0,0,0,410,410,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,410,0,0,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,0,410,410, +410,410,410,410,410,410,410,410,410,410,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,410,0,0,0,0,0,0,0,0,410,0,410,410, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,410,410,410,410,410,410,410,410,410,410,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,0,0,410,410,410,410,0,0,410,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,0,0,0,0,0,0,0,0,0,410,0,0,0,410,410,0,0,0,410,410,410,410,0,0,410,410,410,410,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,410,410,410,410,0,0,0,410,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,0,410,410,410,410,0,410,410,410,410,0,0,410,410,410,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,410, +0,0,410,0,0,0,0,0,0,410,0,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,0,0,0,0,0,0,0,0,0,0,0, +0,0,410,0,0,0,0,0,0,410,0,410,410,410,410,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,410,410,410,410,410,410,410,410,0,0,0,0,0,0,0,0, +0,0,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0, +0,0,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0, +0,0,410,0,0,410,410,410,410,410,0,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,410,410,0,0,0,0,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0, +0,0,410,410,410,410,0,0,410,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,0,0,0,0,0,410,0,0,0,0,410,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,0,410,410,410,410,410,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,410,410,410,0,0,410,410,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,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,410,410,410,410,410,0,0,0,0,0,0,0,0,0,0,0,410,410,0,410,410,410,410,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,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,410,410,0,0,0,0,0,410,410,410,410,0,0, +0,0,410,410,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,410,410,410,410,0,410,410,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,410,410,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,0,0,0,0,0,0,0,410,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clean b/clean index 6cf836c..db7550f 100755 --- a/clean +++ b/clean @@ -1,7 +1,9 @@ cd assets rm -f *.json +rm -r __pycache__ cd .. rm -r build-cg +rm -r build-cg-push rm -r build-fx rm *.g1a rm *.g3a diff --git a/src/game.c b/src/game.c index 64d3765..e8e3c98 100644 --- a/src/game.c +++ b/src/game.c @@ -6,16 +6,61 @@ #include #include +#include + +#include "stdlib.h" + +extern bopti_image_t SignAction_img; + + +#define MAX_INTERACTION_DISTANCE 16 + void game_logic(Game *game) { - // to be done + + /* we check if interactions are possible close to the player */ + for( int i=0; imap_level->nbextradata; i++ ) + { + /* simple distance check along X and Y axis */ + /* Be careful to use world coordinates, not local (i.e.map) ones */ + if ( (abs((int) game->player.wx - + (int) game->map_level->extradata[i].x*PXSIZE ) + < MAX_INTERACTION_DISTANCE*PXSIZE) + && (abs((int) game->player.wy - + (int) game->map_level->extradata[i].y*PXSIZE ) + < MAX_INTERACTION_DISTANCE*PXSIZE) ) + { + /* the player can do something */ + game->player.canDoSomething = true; + /* we mark the action for futur treatment in player_action() */ + game->player.whichAction = i; + return; + } + } + /* else nothing to be done here */ + game->player.canDoSomething = false; + game->player.whichAction = -1; + return; } + +void render_indicator(Game *game) +{ + /* nothing to do for the player so we quit */ + if (game->player.canDoSomething==false) + return; + + /* else we draw a small indicator on the screen */ + dimage(5, 5, &SignAction_img); +} + + void draw(Game *game) { /* Draw everything. */ render_map_by_layer(game, BACKGROUND); player_draw(game); render_map_by_layer(game, FOREGROUND); + render_indicator( game ); } /* Key management */ @@ -47,6 +92,9 @@ void get_inputs(Game *game) { if(keydown(KEY_F2)) { game->debug_player = !game->debug_player; } + if(keydown(KEY_F3)) { + game->debug_extra = !game->debug_extra; + } #endif diff --git a/src/game.h b/src/game.h index e13f3d4..d6237e6 100644 --- a/src/game.h +++ b/src/game.h @@ -1,7 +1,9 @@ #ifndef GAME_H #define GAME_H + #include +#include @@ -23,21 +25,46 @@ typedef enum { /* Struct that define player parameters */ typedef struct { - int x, y; /* The position of the player */ - unsigned int px, py; /* The position of the player on screen */ - unsigned short int life; /* How many lives the player still has between 0 - * and 100. */ - char speed; /* The speed of the movement of the player. */ + int16_t x, y; /* The position of the player int the current map */ + uint16_t px, py; /* The position of the player on screen */ + int16_t wx, wy; /* position of the player in the world */ + int8_t life; /* How many lives the player still has between 0 and 100. */ + int8_t speed; /* The speed of the movement of the player. */ + + + /* set to true if a action can be done in the current position of the map */ + bool canDoSomething; + /* indicates which data are relevant to the current action in the */ + /* extradata layer of the map */ + int32_t whichAction; + /* the player is doing something */ + bool isDoingAction; } Player; +typedef struct { + /* position of the item */ + uint16_t x; + uint16_t y; + /* its name */ + char *name; + /* its class (NPC, SGN, INFO, ... )*/ + char *type; + /* data to be shown in the dialog*/ + char *dialog; + /* ... this can be extended as per needs ... */ +} ExtraData; + typedef struct { /* width, height and the number of layer of the map */ - uint16_t w, h; + uint16_t w; + uint16_t h; uint16_t nblayers; uint16_t tileset_size; + /* world coordinates of the upper left and bootom right*/ + /* corners of the current map to be multiplied in game by PXSIZE */ uint16_t xmin; uint16_t ymin; uint16_t xmax; @@ -48,10 +75,15 @@ typedef struct { /* contain the properties of the tiles */ /* this is given by the layer Walkable of the map in Tiled */ - uint8_t *walkable; - /* list of all the tiles */ + /* structure that contains all the items on the map to interract with */ + /* each portion of the map has its own list to avoid scrutinizing too much */ + /* data when lloking for proximity of items */ + uint32_t nbextradata; + ExtraData *extradata; + + /* list of all the tiles to draw the background and the foreground layers */ uint16_t *layers[]; } Map; @@ -74,8 +106,9 @@ typedef struct { long int frame_duration; /* variables used for debuging */ - bool debug_player; bool debug_map; + bool debug_player; + bool debug_extra; } Game; /* (Mibi88) TODO: Describe what this function is doing. */ @@ -84,6 +117,10 @@ void game_logic(Game *game); /* Draws everything on screen. */ void draw(Game *game); +/* This render a small sign on the upper lecft corner of the screen */ +/* if the player can do an action */ +void render_indicator(Game *game); + /* Handle key presses. */ void get_inputs(Game *game); diff --git a/src/main.c b/src/main.c index 69509da..f7893c9 100644 --- a/src/main.c +++ b/src/main.c @@ -26,17 +26,17 @@ extern bopti_image_t player_face_img; -extern Map *worldRPG[]; +extern Map *worldRPG[]; /* Game data (defined in "game.h")*/ Game game = { NULL, - {10*PXSIZE, 48*PXSIZE, 0, 0, 100, SPEED}, + {12*PXSIZE, 36*PXSIZE, 0, 0, 10*PXSIZE, 48*PXSIZE, 100, SPEED, false, 0, false}, false, false, false, 0 /* debug variables*/ - , true, true + , false, false, false }; /* screen capture management code */ @@ -108,13 +108,13 @@ int main(void) { dgray(DGRAY_ON); #endif - +/* showtext_dialog(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, true); int in = showtext_dialog_ask(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, false, "Lorem\0Ipsum\0Dolor", 3, 0); if(in==2) showtext_dialog(&game, &player_face_img, "You choosed Dolor", false, true); else if(in==1) showtext_dialog(&game, &player_face_img, "You choosed Ipsum", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true); - +*/ do{ /* clear screen */ @@ -137,7 +137,13 @@ int main(void) { { dfont( NULL ); drect( 5, 55,390, 75, C_WHITE ); - dprint( 10, 60, C_BLUE, "X= %d - Y= %d", game.player.x, game.player.y ); + dprint( 10, 60, C_BLUE, "X= %d - Y= %d / Wx= %d - Wy= %d", game.player.x, game.player.y, game.player.wx, game.player.wy ); + } + if (game.debug_extra) + { + dfont( NULL ); + for (int i=0; inbextradata; i++ ) + dprint( 10, 90+i*15, C_RED, "X= %d - Y= %d - T: %s", game.map_level->extradata[i].x, game.map_level->extradata[i].y, game.map_level->extradata[i].dialog ); } #endif diff --git a/src/map.c b/src/map.c index 7ea491d..5670485 100644 --- a/src/map.c +++ b/src/map.c @@ -4,6 +4,10 @@ #include +extern Map *worldRPG[]; +extern ExtraData *extraRPG[]; + + void render_map(Game *game) { Map *map_level = game->map_level; @@ -193,9 +197,10 @@ void render_map_by_layer(Game *game, int layer) { short int get_tile(Game *game, int x, int y, int l) { Map *map_level = game->map_level; + /* Get the tile at (x, y) on layer l. Returns the tile ID or MAP_OUTSIDE if * she's not found. */ - return x>=0 && x < map_level->w && y>=0 && y < map_level->h ? + return (x>=0 && x < map_level->w && y>=0 && y < map_level->h) ? map_level->layers[l][y * map_level->w + x] : MAP_OUTSIDE; } @@ -204,7 +209,31 @@ short int get_walkable(Game *game, int x, int y) { Map *map_level = game->map_level; /* Get the tile at (x, y). Returns the tile ID or MAP_OUTSIDE if she's not * found. */ - return x>=0 && x < map_level->w && y>=0 && y < map_level->h ? + return (x>=0 && x < map_level->w && y>=0 && y < map_level->h) ? map_level->walkable[y * map_level->w + x] : MAP_OUTSIDE; } +/* return the pointer to the map containing the given position */ +Map *get_map_for_coordinates( Game *game, int x, int y ) +{ + /* check if the current map contains the point */ + if (x>=game->map_level->xmin && xmap_level->xmax && + y>=game->map_level->ymin && ymap_level->ymax) + return game->map_level; + + /* else we check in worldRPG if there is a mal containing that point */ + int i = 0; + Map *current = worldRPG[i]; + do + { + if (x>=current->xmin && xxmax && + y>=current->ymin && yymax) + return current; + i++; + current = worldRPG[i]; + } + while (current!=NULL); + + /* else we return NULL cause the point is a not within a map */ + return NULL; +} \ No newline at end of file diff --git a/src/map.h b/src/map.h index e255291..1586186 100644 --- a/src/map.h +++ b/src/map.h @@ -33,4 +33,7 @@ short int get_tile(Game *game, int x, int y, int l); /* Returns what is in the walkable layer at (x, y). */ short int get_walkable(Game *game, int x, int y); +/* return the pointer to the map containing the given position */ +Map* get_map_for_coordinates(Game *game, int x, int y ); + #endif diff --git a/src/player.c b/src/player.c index 07a347e..ed7067f 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,5 @@ #include "player.h" +#include "dialogs.h" #include "map.h" #include "config.h" #include @@ -25,6 +26,9 @@ const char damage_taken_walkable[WALKABLE_TILE_MAX] = { }; extern bopti_image_t demo_player_img; +extern bopti_image_t NPC_Icon_img; +extern bopti_image_t SGN_Icon_img; +extern bopti_image_t INFO_Icon_img; void player_draw(Game *game) { @@ -35,19 +39,25 @@ void player_draw(Game *game) { void player_move(Game *game, Direction direction) { Player *player = &game->player; + /* How this player movement will modify the player x and y. */ char dx, dy; + /* If the player will collide with a hard tile or if the will go outside of * the map. */ + if(player_collision(game, direction, P_CENTER)){ + /* If the will collide with the center of the player. */ dx = one_px_mov[direction*2]*player->speed; dy = one_px_mov[direction*2+1]*player->speed; + player_fix_position(game, dx, dy); } else{ if(player_collision(game, direction, P_RIGHTDOWN) || player_collision(game, direction, P_LEFTUP)){ + /* If the will collide with the edges of the player. */ /* I fix his position so he won't be partially in the tile. */ /* I invert dx and dy to fix the axis where he is not moving on. */ @@ -55,18 +65,49 @@ void player_move(Game *game, Direction direction) { */ dx = one_px_mov[direction*2]*player->speed; dy = one_px_mov[direction*2+1]*player->speed; + player_fix_position(game, dx==0, dy==0); } + /* If he won't collide with the center, so I just move him normally */ dx = one_px_mov[direction*2]*player->speed; dy = one_px_mov[direction*2+1]*player->speed; + player->x += dx; player->y += dy; } + + player->wx = game->map_level->xmin * PXSIZE + player->x; + player->wy = game->map_level->ymin * PXSIZE + player->y; } + void player_action(Game *game) { - /* TODO */ + if( game->player.isDoingAction ) return; /* alreday doing something */ + + if( game->player.canDoSomething ) /* we can do something */ + { + /* we indicate that the player is occupied */ + game->player.isDoingAction = true; + + /* we collect the information */ + char *text = game->map_level->extradata[game->player.whichAction].dialog; + /* we use the correct image as per the class of the item */ + bopti_image_t *face; + if (strcmp("INFO", game->map_level->extradata[game->player.whichAction].type)==0) + face = &INFO_Icon_img; + else if (strcmp("NPC", game->map_level->extradata[game->player.whichAction].type)==0) + face = &NPC_Icon_img; + else if (strcmp("SGN", game->map_level->extradata[game->player.whichAction].type)==0) + face = &SGN_Icon_img; + else face = &demo_player_img; + + /* we treat the action - i.e. we show a dialog */ + showtext_dialog( game, face, text, true, true ); + + /* when done we release the occupied status of the player */ + game->player.isDoingAction = false; + } } bool player_collision(Game *game, Direction direction, @@ -77,38 +118,99 @@ bool player_collision(Game *game, Direction direction, /* Where is the tile where he will go to from his position. */ char dx = one_px_mov[direction*2]; char dy = one_px_mov[direction*2+1]; + if(!dx){ dx += nomov_axis_check; }else if(!dy){ dy += nomov_axis_check; } + dx = dx*(P_WIDTH/2+1); dy = dy*(P_HEIGHT/2+1); + /* The tile he will go to. */ int player_tile_x = player->x+dx; int player_tile_y = player->y+dy; - /* Handle a negative position diffrently than a positive one. */ + + /* check where the player is expected to go on the next move */ + /* if outside the map, we check if there is a map on the other */ + /* side of the current map*/ + if (get_walkable(game, player_tile_x, player_tile_y) == MAP_OUTSIDE) + { + // we compute the expected world coordinates accordingly + // while taking care of the scaling between fx and cg models (PXSIZE) + int worldX = (player->wx+dx) / PXSIZE; + int worldY = (player->wy+dy) / PXSIZE; + Map *map = get_map_for_coordinates(game, worldX, worldY ); + if (map!=NULL && map!=game->map_level) + { + Map *backupmap = game->map_level; + int backupx = player->x; + int backupy = player->y; + int backupwx = player->wx; + int backupwy = player->wy; + + game->map_level = map; + + player->wx = worldX * PXSIZE; + player->wy = worldY * PXSIZE; + + player->x = (worldX - map->xmin ) * PXSIZE; + player->y = (worldY - map->ymin ) * PXSIZE; + + int on_walkable = get_walkable(game, player->x/T_WIDTH, + player->y/T_HEIGHT); + + int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX) ? + walkable_speed[on_walkable] : 0; + + /* if he's on a hard tile and we need to revert the changes as */ + /* tile on the next side of the border is not walkable */ + + if(!speed){ + game->map_level = backupmap; + player->x = backupx; + player->y = backupy; + player->wx = backupwx; + player->wy = backupwy; + return true; /* He will collide with it. */ + } + + return false; + } + } + + + /* Handle a negative position differently than a positive one. */ if(player_tile_x < 0) player_tile_x = player_tile_x/T_WIDTH-1; else player_tile_x = player_tile_x/T_WIDTH; + if(player_tile_y < 0) player_tile_y = player_tile_y/T_HEIGHT-1; else player_tile_y = player_tile_y/T_HEIGHT; + int on_walkable = get_walkable(game, player_tile_x, player_tile_y); - int speed = on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX ? + + int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX) ? walkable_speed[on_walkable] : 0; + /* if he's on a hard tile */ if(!speed){ return true; /* He will collide with it. */ } + player->speed = speed; + return false; /* He won't collide with a hard tile. */ } void player_fix_position(Game *game, bool fix_x, bool fix_y) { Player *player = &game->player; + /* I fix his poition on x or/and on y if y need to, so that he won't be over * the hard tile that he collided with. */ if(fix_x) player->x = player->x/T_WIDTH*T_WIDTH+P_WIDTH/2; + if(fix_y) player->y = player->y/T_HEIGHT*T_HEIGHT+P_HEIGHT/2; }