Merge branch 'dev' of git.planet-casio.com:Slyvtt/Collab_RPG into npc
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
/build-fx
|
/build-fx
|
||||||
/build-cg
|
/build-cg
|
||||||
/build-cg-push
|
/build-cg-push
|
||||||
|
/build-fxg3a
|
||||||
/*.g1a
|
/*.g1a
|
||||||
/*.g3a
|
/*.g3a
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@ include(GenerateG1A)
|
||||||
include(GenerateG3A)
|
include(GenerateG3A)
|
||||||
|
|
||||||
include(Fxconv)
|
include(Fxconv)
|
||||||
find_package(Gint 2.9 REQUIRED)
|
find_package(Gint 2.11 REQUIRED)
|
||||||
|
# Gint 2.11 is required, because we're using the new macros like GINT_RENDER_RGB
|
||||||
find_package(LibProf 2.4 REQUIRED)
|
find_package(LibProf 2.4 REQUIRED)
|
||||||
|
|
||||||
#set the color mode either to 1b or 2b
|
#set the color mode either to 1b or 2b
|
||||||
|
@ -37,9 +38,12 @@ set(ASSETS
|
||||||
|
|
||||||
set(ASSETS_cg
|
set(ASSETS_cg
|
||||||
assets-cg/demo_player.png
|
assets-cg/demo_player.png
|
||||||
assets-cg/demo_PNJ.png
|
assets-cg/npc/char/npc_male.png
|
||||||
assets-cg/SignAction.png
|
assets-cg/SignAction.png
|
||||||
assets-cg/NPC_Icon.png
|
assets-cg/npc/face/npc_male.png
|
||||||
|
assets-cg/npc/face/npc_female.png
|
||||||
|
assets-cg/npc/face/npc_milkman.png
|
||||||
|
assets-cg/npc/face/npc_police.png
|
||||||
assets-cg/SGN_Icon.png
|
assets-cg/SGN_Icon.png
|
||||||
assets-cg/INFO_Icon.png
|
assets-cg/INFO_Icon.png
|
||||||
assets-cg/player_face.png
|
assets-cg/player_face.png
|
||||||
|
@ -60,9 +64,12 @@ set(ASSETS_cg_EGA64
|
||||||
|
|
||||||
set(ASSETS_fx
|
set(ASSETS_fx
|
||||||
assets-fx/demo_player.png
|
assets-fx/demo_player.png
|
||||||
assets-fx/demo_PNJ.png
|
assets-fx/npc/char/npc_male.png
|
||||||
assets-fx/SignAction.png
|
assets-fx/SignAction.png
|
||||||
assets-fx/NPC_Icon.png
|
assets-fx/npc/face/npc_male.png
|
||||||
|
assets-fx/npc/face/npc_female.png
|
||||||
|
assets-fx/npc/face/npc_milkman.png
|
||||||
|
assets-fx/npc/face/npc_police.png
|
||||||
assets-fx/SGN_Icon.png
|
assets-fx/SGN_Icon.png
|
||||||
assets-fx/INFO_Icon.png
|
assets-fx/INFO_Icon.png
|
||||||
assets-fx/player_face.png
|
assets-fx/player_face.png
|
||||||
|
@ -86,29 +93,8 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||||
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_fx}} )
|
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_fx}} )
|
||||||
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
||||||
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_cg}} )
|
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_cg}} )
|
||||||
endif()
|
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_G3A)
|
||||||
|
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE_fx}} )
|
||||||
# fx colormode
|
|
||||||
if("${COLORMODE_fx}" STREQUAL 1b)
|
|
||||||
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR1BIT)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if("${COLORMODE_fx}" STREQUAL 2b)
|
|
||||||
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR2BIT)
|
|
||||||
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()
|
endif()
|
||||||
|
|
||||||
target_link_options(myaddin PRIVATE -Wl,-Map=Build_Addin.map -Wl,--print-memory-usage)
|
target_link_options(myaddin PRIVATE -Wl,-Map=Build_Addin.map -Wl,--print-memory-usage)
|
||||||
|
@ -116,6 +102,14 @@ target_link_libraries(myaddin LibProf::LibProf Gint::Gint)
|
||||||
|
|
||||||
|
|
||||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||||
|
# fx colormode
|
||||||
|
if("${COLORMODE_fx}" STREQUAL 1b)
|
||||||
|
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR1BIT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${COLORMODE_fx}" STREQUAL 2b)
|
||||||
|
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR2BIT)
|
||||||
|
endif()
|
||||||
|
|
||||||
if("${COLORMODE_fx}" STREQUAL 1b)
|
if("${COLORMODE_fx}" STREQUAL 1b)
|
||||||
generate_g1a(TARGET myaddin OUTPUT "RPG_1b.g1a"
|
generate_g1a(TARGET myaddin OUTPUT "RPG_1b.g1a"
|
||||||
|
@ -128,7 +122,20 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
||||||
|
# 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()
|
||||||
|
|
||||||
if("${COLORMODE_cg}" STREQUAL 1b)
|
if("${COLORMODE_cg}" STREQUAL 1b)
|
||||||
generate_g3a(TARGET myaddin OUTPUT "RPG_1b.g3a"
|
generate_g3a(TARGET myaddin OUTPUT "RPG_1b.g3a"
|
||||||
|
@ -145,4 +152,19 @@ elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
||||||
NAME "RPG PC EGA" ICONS assets-cg/ega64/icon-uns-ega64.png assets-cg/ega64/icon-sel-ega64.png)
|
NAME "RPG PC EGA" ICONS assets-cg/ega64/icon-uns-ega64.png assets-cg/ega64/icon-sel-ega64.png)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_G3A)
|
||||||
|
|
||||||
|
if("${COLORMODE_fx}" STREQUAL 1b)
|
||||||
|
generate_g3a(TARGET myaddin OUTPUT "RPG_1bfx.g3a"
|
||||||
|
NAME "RPG PC 1b fx" ICONS assets-cg/1b/icon-uns-1b.png assets-cg/1b/icon-sel-1b.png)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${COLORMODE_fx}" STREQUAL 2b)
|
||||||
|
generate_g3a(TARGET myaddin OUTPUT "RPG_2bfx.g3a"
|
||||||
|
NAME "RPG PC 2b fx" ICONS assets-cg/2b/icon-uns-2b.png assets-cg/2b/icon-sel-2b.png)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
26
PROJECT_STRUCTURE.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Project structure
|
||||||
|
|
||||||
|
* `assets` contains the tiled maps, and the tiled map converters.
|
||||||
|
* `assets-cg` contains the assets for cg calculators like the cg-50.
|
||||||
|
* `assets-fx` contains the assets for monochrome calculators.
|
||||||
|
* `captures` contains screenshots.
|
||||||
|
* `src` This folder contains the source code.
|
||||||
|
* `config.h` This header file contains defines for the size of various
|
||||||
|
things on screen, like the size of a tile in the tilemap, the size of the
|
||||||
|
dialog box, etc.
|
||||||
|
* `dialogs.c` and `dialogs.h` contain various functions to display dialogs
|
||||||
|
and also let the user respond.
|
||||||
|
* `events.c` and `events.h` parse tags in the messages that are displayed
|
||||||
|
using the dialogs procedures to modify variables (and soon, call
|
||||||
|
procedures).
|
||||||
|
* `game.c` and `game.h` handles the rendering, the input, etc.
|
||||||
|
* `main.c` handles the USB connection and the gint gray rendering, for 2bpp
|
||||||
|
rendering on monochrome calculators. Contains the mainloop. Also contains
|
||||||
|
code to display debug informations.
|
||||||
|
* `map.c` and `map.h` contain code to render, get a tile in the map, see if
|
||||||
|
the tile is walkable, etc.
|
||||||
|
* `mapdata.h` contains the available maps.
|
||||||
|
* `memory.c` and `memory.h` procedures to handle arrays (currently: search
|
||||||
|
in an array of short ints).
|
||||||
|
* `npc.c` and `npc.h` npc rendering and movement (and soon pathfinding).
|
||||||
|
* `player.c` and `player.h` handle the player movement, collision, etc.
|
10
README.md
|
@ -2,7 +2,12 @@
|
||||||
|
|
||||||
Plus d'infos sur ce projet ici : [Le projet Collaboratif de PC](https://www.planet-casio.com/Fr/forums/topic17343-last-projet-collaboratif-avec-toute-la-commu.html)
|
Plus d'infos sur ce projet ici : [Le projet Collaboratif de PC](https://www.planet-casio.com/Fr/forums/topic17343-last-projet-collaboratif-avec-toute-la-commu.html)
|
||||||
|
|
||||||
## Avencement du projet
|
## Contribuer!
|
||||||
|
Style du code [STYLE.md](STYLE.md).
|
||||||
|
|
||||||
|
Structure du projet [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md).
|
||||||
|
|
||||||
|
## Avancement du projet
|
||||||
|
|
||||||
A ce stade, on a déjà implémenté :
|
A ce stade, on a déjà implémenté :
|
||||||
|
|
||||||
|
@ -13,12 +18,13 @@ A ce stade, on a déjà implémenté :
|
||||||
- [x] Multiple cartes avec importation automatique des fichiers `world` issus de Tiled
|
- [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] Carte Multilayer (Background, Foreground + accessibilité / Dommages) avec transparence du calque Foreground
|
||||||
- [x] Personnage
|
- [x] Personnage
|
||||||
- [x] Dialogues avec fichiers externes `json` et séquenceage possible de ceux-ci via un arbre d'histoire (sauts de lignes et mots plus grands que l'écran pas supportés)
|
- [x] Dialogues avec fichiers externes `json` et séquenceage possible de ceux-ci via un arbre d'histoire (sauts de lignes et mots plus grands que l'écran pas supportés + limite d'un kibibyte)
|
||||||
- [x] Fontes de caractères
|
- [x] Fontes de caractères
|
||||||
- [x] Interaction
|
- [x] Interaction
|
||||||
- [ ] NPC
|
- [ ] NPC
|
||||||
- [x] Changement de map durant le jeu
|
- [x] Changement de map durant le jeu
|
||||||
- [ ] Système d'événements
|
- [ ] Système d'événements
|
||||||
|
- [ ] Pathfinding
|
||||||
|
|
||||||
|
|
||||||
## Crédits
|
## Crédits
|
||||||
|
|
44
README_en.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# Planet Casio Collaborative Project
|
||||||
|
|
||||||
|
(maybe I should've used google translate)
|
||||||
|
|
||||||
|
More informations can be found here (in french):
|
||||||
|
[Le projet Collaboratif de PC](https://www.planet-casio.com/Fr/forums/topic17343-last-projet-collaboratif-avec-toute-la-commu.html)
|
||||||
|
|
||||||
|
## Contribute!
|
||||||
|
Style guidelines [STYLE.md](STYLE.md).
|
||||||
|
|
||||||
|
Project structure [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md).
|
||||||
|
|
||||||
|
## Current state
|
||||||
|
|
||||||
|
What we've implemented so far:
|
||||||
|
|
||||||
|
- [x] Screenshots via USB
|
||||||
|
- [x] Displaying the current map at the players position
|
||||||
|
- [x] Handling keyboard inputs
|
||||||
|
- [x] Handling collisions.
|
||||||
|
- [x] Multiple maps with automatic `world` files import (made with Tiled)
|
||||||
|
- [x] Multilayer map (Background, Foreground + accessibility / damage) with
|
||||||
|
foreground layer transparency.
|
||||||
|
- [x] Player character.
|
||||||
|
- [x] Dialogs from external `json` files (line jumps and words bigger than the
|
||||||
|
screen are unsupported + 1 kibibyte per message limit)
|
||||||
|
- [x] Font
|
||||||
|
- [x] Interaction
|
||||||
|
- [ ] NPC
|
||||||
|
- [x] Changing map in game.
|
||||||
|
- [ ] Event system
|
||||||
|
- [ ] Pathfinding
|
||||||
|
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
The tiles are from Game Boy Top-down RPG Fantasy Tileset (FREE)
|
||||||
|
"Background Assets by Gumpy Function (gumpyfunction.itch.io)"
|
||||||
|
[Tiles Background Assets by Gumpy Function](https://gumpyfunction.itch.io/game-boy-rpg-fantasy-tileset-free)
|
||||||
|
|
||||||
|
Converted to greyscale with gimp.
|
||||||
|
|
||||||
|
1-bit (black and white) version by Shadow15510
|
||||||
|
CG (palette EGA64) color version by Fcalva
|
33
STYLE.md
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Style guidelines in Collab RPG
|
||||||
|
|
||||||
|
(Mibi88) Fcalva, SlyVTT: What do you think of this?
|
||||||
|
|
||||||
|
Wrap the code on 80 columns. Align the wrapped code with the last parantheses,
|
||||||
|
etc.
|
||||||
|
|
||||||
|
Use curly braces with if, else, while and for statements if they can't hold on a
|
||||||
|
single line.
|
||||||
|
|
||||||
|
Put the curly braces after if, else, while or for statements and declarations of
|
||||||
|
procedures on the same line.
|
||||||
|
|
||||||
|
No spaces around parantheses, one space after a comma.
|
||||||
|
|
||||||
|
Variables names in sneak_case.
|
||||||
|
|
||||||
|
(Mibi88) SlyVTT, Fcalva, should be use a doc generation thing or do we describe
|
||||||
|
the procedures as I did so far?
|
||||||
|
|
||||||
|
Document your procedures as following:
|
||||||
|
|
||||||
|
```C
|
||||||
|
/* procedure_name()
|
||||||
|
*
|
||||||
|
* Describe what this procedure does.
|
||||||
|
* arg1: Describe this argument. If the text is too long, wrap it to the
|
||||||
|
* next line like this.
|
||||||
|
* long_name: Describe this argument, and so on.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Have I forgotten something?
|
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 11 KiB |
3
assets-cg/npc/char/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
npc_male.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: demo_PNJ_img
|
BIN
assets-cg/npc/char/npc_male.png
Normal file
After Width: | Height: | Size: 167 B |
12
assets-cg/npc/face/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
npc_male.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_male
|
||||||
|
npc_female.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_female
|
||||||
|
npc_milkman.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_milkman
|
||||||
|
npc_police.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_police
|
BIN
assets-cg/npc/face/npc_female.png
Normal file
After Width: | Height: | Size: 510 B |
BIN
assets-cg/npc/face/npc_male.png
Normal file
After Width: | Height: | Size: 494 B |
BIN
assets-cg/npc/face/npc_milkman.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
assets-cg/npc/face/npc_police.png
Normal file
After Width: | Height: | Size: 555 B |
BIN
assets-fx/2bpp_palette.png
Normal file
After Width: | Height: | Size: 77 B |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 107 B |
|
@ -2,10 +2,6 @@ demo_player.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: demo_player_img
|
name: demo_player_img
|
||||||
|
|
||||||
demo_PNJ.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: demo_PNJ_img
|
|
||||||
|
|
||||||
player_face.png:
|
player_face.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: player_face_img
|
name: player_face_img
|
||||||
|
@ -18,10 +14,6 @@ INFO_Icon.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: INFO_Icon_img
|
name: INFO_Icon_img
|
||||||
|
|
||||||
NPC_Icon.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: NPC_Icon_img
|
|
||||||
|
|
||||||
SGN_Icon.png:
|
SGN_Icon.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: SGN_Icon_img
|
name: SGN_Icon_img
|
||||||
|
|
3
assets-fx/npc/char/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
npc_male.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: demo_PNJ_img
|
BIN
assets-fx/npc/char/npc_male.png
Normal file
After Width: | Height: | Size: 118 B |
12
assets-fx/npc/face/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
npc_male.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_male
|
||||||
|
npc_female.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_female
|
||||||
|
npc_milkman.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_milkman
|
||||||
|
npc_police.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: npc_police
|
BIN
assets-fx/npc/face/npc_female.png
Normal file
After Width: | Height: | Size: 327 B |
BIN
assets-fx/npc/face/npc_male.png
Normal file
After Width: | Height: | Size: 306 B |
BIN
assets-fx/npc/face/npc_milkman.png
Normal file
After Width: | Height: | Size: 326 B |
BIN
assets-fx/npc/face/npc_police.png
Normal file
After Width: | Height: | Size: 354 B |
|
@ -6,6 +6,7 @@ import pathlib
|
||||||
import csv
|
import csv
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
DEBUG = 0
|
||||||
|
|
||||||
def convert(input, output, params, target):
|
def convert(input, output, params, target):
|
||||||
if params["custom-type"] == "map":
|
if params["custom-type"] == "map":
|
||||||
|
@ -34,8 +35,8 @@ def convert_world(input, output, params, target):
|
||||||
|
|
||||||
data = json.load(open(input, "r"))
|
data = json.load(open(input, "r"))
|
||||||
nbMaps = ["fileName" in i for i in data["maps"]].count(True)
|
nbMaps = ["fileName" in i for i in data["maps"]].count(True)
|
||||||
print( "We have to treat ", nbMaps, " maps")
|
if DEBUG: print( "We have to treat ", nbMaps, " maps")
|
||||||
print( "So let's go ... ")
|
if DEBUG: print( "So let's go ... ")
|
||||||
|
|
||||||
structWorld = fxconv.Structure()
|
structWorld = fxconv.Structure()
|
||||||
#structExtra = fxconv.Structure()
|
#structExtra = fxconv.Structure()
|
||||||
|
@ -51,26 +52,26 @@ def convert_world(input, output, params, target):
|
||||||
nameJSON = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json"
|
nameJSON = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json"
|
||||||
|
|
||||||
commandline = 'tiled --export-map json ' + nameTMX + ' ' + nameJSON
|
commandline = 'tiled --export-map json ' + nameTMX + ' ' + nameJSON
|
||||||
print( "TILED COMMAND LINE FOR MAPS : ", commandline )
|
if DEBUG: print( "TILED COMMAND LINE FOR MAPS : ", commandline )
|
||||||
os.system( commandline )
|
os.system( commandline )
|
||||||
|
|
||||||
mapPath = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json"
|
mapPath = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json"
|
||||||
print("Map ", i , " name : ", mapPath )
|
if DEBUG: print("Map ", i , " name : ", mapPath )
|
||||||
|
|
||||||
xmin = data["maps"][i]["x"]
|
xmin = data["maps"][i]["x"]
|
||||||
print( "xmin = ", xmin )
|
if DEBUG: print( "xmin = ", xmin )
|
||||||
|
|
||||||
ymin = data["maps"][i]["y"]
|
ymin = data["maps"][i]["y"]
|
||||||
print( "ymin = ", ymin )
|
if DEBUG: print( "ymin = ", ymin )
|
||||||
|
|
||||||
xmax = data["maps"][i]["x"] + data["maps"][i]["width"]
|
xmax = data["maps"][i]["x"] + data["maps"][i]["width"]
|
||||||
print( "xmax = ", xmax )
|
if DEBUG: print( "xmax = ", xmax )
|
||||||
|
|
||||||
ymax = data["maps"][i]["y"] + data["maps"][i]["height"]
|
ymax = data["maps"][i]["y"] + data["maps"][i]["height"]
|
||||||
print( "ymax = ", ymax )
|
if DEBUG: print( "ymax = ", ymax )
|
||||||
|
|
||||||
map = get_tile_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax)
|
map = get_tile_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax)
|
||||||
print( "Map = ", map )
|
if DEBUG: print( "Map = ", map )
|
||||||
structWorld += fxconv.ptr( map )
|
structWorld += fxconv.ptr( map )
|
||||||
|
|
||||||
structWorld += fxconv.u32(0)
|
structWorld += fxconv.u32(0)
|
||||||
|
@ -85,7 +86,7 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
|
|
||||||
#find the tileset in use. it's a relative path (like ../tileset.tsx)
|
#find the tileset in use. it's a relative path (like ../tileset.tsx)
|
||||||
nameTileset = data["tilesets"][0]["source"].replace(".tsx","")
|
nameTileset = data["tilesets"][0]["source"].replace(".tsx","")
|
||||||
print(nameTileset)
|
if DEBUG: print(nameTileset)
|
||||||
#the name of the tileset without the .something
|
#the name of the tileset without the .something
|
||||||
nameTilesetFree = nameTileset.split("/")[-1]
|
nameTilesetFree = nameTileset.split("/")[-1]
|
||||||
#count the number of "back" (cd ..) to locate the tileset on the computer
|
#count the number of "back" (cd ..) to locate the tileset on the computer
|
||||||
|
@ -95,7 +96,7 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
tilesetJSON = "/".join(input.split("/")[:-nbRetour]) + "/" + nameTileset + ".json"
|
tilesetJSON = "/".join(input.split("/")[:-nbRetour]) + "/" + nameTileset + ".json"
|
||||||
|
|
||||||
commandline = 'tiled --export-tileset json ' + tilesetTSX + ' ' + tilesetJSON
|
commandline = 'tiled --export-tileset json ' + tilesetTSX + ' ' + tilesetJSON
|
||||||
print( "TILED COMMAND LINE FOR TILESET : ", commandline )
|
if DEBUG: print( "TILED COMMAND LINE FOR TILESET : ", commandline )
|
||||||
os.system( commandline )
|
os.system( commandline )
|
||||||
|
|
||||||
tileset = open(tilesetJSON, "r")
|
tileset = open(tilesetJSON, "r")
|
||||||
|
@ -105,14 +106,14 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
|
|
||||||
#find the ID of the first tile in the walkable tileset ()
|
#find the ID of the first tile in the walkable tileset ()
|
||||||
indexWalkable = data["tilesets"][1]["firstgid"]
|
indexWalkable = data["tilesets"][1]["firstgid"]
|
||||||
print(indexWalkable)
|
if DEBUG: print(indexWalkable)
|
||||||
|
|
||||||
#Extract from the json the width, height
|
#Extract from the json the width, height
|
||||||
w, h = data["width"], data["height"]
|
w, h = data["width"], data["height"]
|
||||||
|
|
||||||
#nbTileLayer is the number of "true" layers (without ObjectsLayer)
|
#nbTileLayer is the number of "true" layers (without ObjectsLayer)
|
||||||
nbTilelayer = ["data" in i for i in data["layers"]].count(True) - 1
|
nbTilelayer = ["data" in i for i in data["layers"]].count(True) - 1
|
||||||
print( nbTilelayer)
|
if DEBUG: print( nbTilelayer)
|
||||||
|
|
||||||
#index of the various layers (may change from one map to another)
|
#index of the various layers (may change from one map to another)
|
||||||
layer_walkable = 0
|
layer_walkable = 0
|
||||||
|
@ -135,7 +136,7 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
datavalid = data["layers"][i]
|
datavalid = data["layers"][i]
|
||||||
if datavalid["name"]=="Walkable":
|
if datavalid["name"]=="Walkable":
|
||||||
layer_walkable = i
|
layer_walkable = i
|
||||||
print( "Walkable Tile Data in layer : ", layer_walkable)
|
if DEBUG: print( "Walkable Tile Data in layer : ", layer_walkable)
|
||||||
break
|
break
|
||||||
elif i==nbTilelayer:
|
elif i==nbTilelayer:
|
||||||
print( "ERROR : No Walkable layer data !!!" )
|
print( "ERROR : No Walkable layer data !!!" )
|
||||||
|
@ -168,7 +169,7 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
|
|
||||||
nameDialog = data["properties"][0]["value"]
|
nameDialog = data["properties"][0]["value"]
|
||||||
dialogfile = "/".join(input.split("/")[:-nbRetour]) + "/" + nameDialog
|
dialogfile = "/".join(input.split("/")[:-nbRetour]) + "/" + nameDialog
|
||||||
print( "THE DIALOGS ARE CONTAINED IN THE FILE : ", dialogfile )
|
if DEBUG: print( "THE DIALOGS ARE CONTAINED IN THE FILE : ", dialogfile )
|
||||||
|
|
||||||
nbdiag = 0
|
nbdiag = 0
|
||||||
diagdata = fxconv.Structure()
|
diagdata = fxconv.Structure()
|
||||||
|
@ -192,7 +193,7 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
datavalid = data["layers"][i]
|
datavalid = data["layers"][i]
|
||||||
if datavalid["name"]=="Background":
|
if datavalid["name"]=="Background":
|
||||||
layer_background = i
|
layer_background = i
|
||||||
print( "Background Tile Data in layer : ", layer_background)
|
if DEBUG: print( "Background Tile Data in layer : ", layer_background)
|
||||||
break
|
break
|
||||||
elif i==nbTilelayer:
|
elif i==nbTilelayer:
|
||||||
print( "ERROR : No Background layer data !!!" )
|
print( "ERROR : No Background layer data !!!" )
|
||||||
|
@ -210,10 +211,10 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
datavalid = data["layers"][i]
|
datavalid = data["layers"][i]
|
||||||
if datavalid["name"]=="Foreground":
|
if datavalid["name"]=="Foreground":
|
||||||
layer_foreground = i
|
layer_foreground = i
|
||||||
print( "Foreground Tile Data in layer : ", layer_foreground)
|
if DEBUG: print( "Foreground Tile Data in layer : ", layer_foreground)
|
||||||
break
|
break
|
||||||
elif i==nbTilelayer:
|
elif i==nbTilelayer:
|
||||||
printf( "ERROR : No Foreground layer data !!!" )
|
print( "ERROR : No Foreground layer data !!!" )
|
||||||
|
|
||||||
layer_data = bytes()
|
layer_data = bytes()
|
||||||
layer = data["layers"][layer_foreground]
|
layer = data["layers"][layer_foreground]
|
||||||
|
@ -227,11 +228,11 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
|
|
||||||
|
|
||||||
def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
print( "WE ARE COMPUTING THE EXTRA DATA OF THE MAP : ", input )
|
if DEBUG: print( "WE ARE COMPUTING THE EXTRA DATA OF THE MAP : ", input )
|
||||||
data = json.load(open(input, "r"))
|
data = json.load(open(input, "r"))
|
||||||
|
|
||||||
nblayer = ["id" in i for i in data["layers"]].count(True) - 1
|
nblayer = ["id" in i for i in data["layers"]].count(True) - 1
|
||||||
print( "I found ", nblayer, " of extradata")
|
if DEBUG: print( "I found ", nblayer, " of extradata")
|
||||||
|
|
||||||
#index of the various layers (may change from one map to another)
|
#index of the various layers (may change from one map to another)
|
||||||
layer_extradata = 0
|
layer_extradata = 0
|
||||||
|
@ -241,7 +242,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
datavalid = data["layers"][i]
|
datavalid = data["layers"][i]
|
||||||
if datavalid["name"]=="ExtraData":
|
if datavalid["name"]=="ExtraData":
|
||||||
layer_extradata = i
|
layer_extradata = i
|
||||||
print( "Extra Data in layer : ", layer_extradata)
|
if DEBUG: print( "Extra Data in layer : ", layer_extradata)
|
||||||
break
|
break
|
||||||
elif i==nblayer:
|
elif i==nblayer:
|
||||||
print( "ERROR : No ExtraData layer data !!!" )
|
print( "ERROR : No ExtraData layer data !!!" )
|
||||||
|
@ -272,6 +273,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
path_length = 0
|
path_length = 0
|
||||||
xdata = None
|
xdata = None
|
||||||
ydata = None
|
ydata = None
|
||||||
|
face_type = "MALE"
|
||||||
|
|
||||||
#we now fill all the properties of this item
|
#we now fill all the properties of this item
|
||||||
for j in i["properties"]:
|
for j in i["properties"]:
|
||||||
|
@ -281,41 +283,44 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
elif j["name"]=="needAction": needAction = j[ "value" ]
|
elif j["name"]=="needAction": needAction = j[ "value" ]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#Extra properties for NPCs (path)
|
#Extra properties for NPCs (path and face)
|
||||||
if tpe=="NPC":
|
if tpe=="NPC":
|
||||||
if j["name"]=="hasPath":
|
if j["name"]=="face":
|
||||||
|
face_type = j["value"]
|
||||||
|
elif j["name"]=="hasPath":
|
||||||
pathID = None
|
pathID = None
|
||||||
path = j[ "value" ]
|
path = j[ "value" ]
|
||||||
if path==1:
|
if path==1:
|
||||||
print( "PNJ has path - NOW LOOKING FOR RELEVANT DATA" )
|
if DEBUG: print( "PNJ has path - NOW LOOKING FOR RELEVANT DATA" )
|
||||||
|
|
||||||
# we start looking for path data with first the ID of the path Object
|
# we start looking for path data with first the ID of the path Object
|
||||||
for u in i["properties"]:
|
for u in i["properties"]:
|
||||||
if u["name"]=="path":
|
if u["name"]=="path":
|
||||||
pathID = u[ "value" ]
|
pathID = u[ "value" ]
|
||||||
print( "path ID is identified : ID= ", pathID )
|
if DEBUG: print( "path ID is identified : ID= ", pathID )
|
||||||
|
|
||||||
for v in layer["objects"]:
|
for v in layer["objects"]:
|
||||||
if v[ "id" ] == pathID:
|
if v[ "id" ] == pathID:
|
||||||
print( "path data found : " )
|
if DEBUG: print( "path data found : " )
|
||||||
|
|
||||||
xdata = bytes()
|
xdata = bytes()
|
||||||
ydata = bytes()
|
ydata = bytes()
|
||||||
|
|
||||||
for w in v[ "polyline" ]:
|
for w in v[ "polyline" ]:
|
||||||
path_length = path_length + 1
|
path_length = path_length + 1
|
||||||
print( "X= ", w[ "x" ], " Y= ", w[ "y" ] )
|
if DEBUG: print( "X= ", w[ "x" ], " Y= ", w[ "y" ] )
|
||||||
xdata += fxconv.u16( int( w[ "x" ] ) )
|
xdata += fxconv.u16( int( w[ "x" ] ) )
|
||||||
ydata += fxconv.u16( int( w[ "y" ] ) )
|
ydata += fxconv.u16( int( w[ "y" ] ) )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print( "PNJ has no Path" )
|
if DEBUG: print( "PNJ has no Path" )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print( "UNIDENTIFIED PROPERTY : ", j["name"])
|
print( "UNIDENTIFIED PROPERTY : ", j["name"])
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialogID )
|
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialogID )
|
||||||
print( " Type= ", tpe, " Name= ", nme )
|
print( " Type= ", tpe, " Name= ", nme, "Face =", face_type)
|
||||||
print( " Action?= ", needAction )
|
print( " Action?= ", needAction )
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,6 +329,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
structData += fxconv.u32( int(y) )
|
structData += fxconv.u32( int(y) )
|
||||||
structData += fxconv.string( nme )
|
structData += fxconv.string( nme )
|
||||||
structData += fxconv.string( tpe )
|
structData += fxconv.string( tpe )
|
||||||
|
structData += fxconv.string(face_type)
|
||||||
structData += fxconv.u32( int(dialogID) )
|
structData += fxconv.u32( int(dialogID) )
|
||||||
structData += fxconv.u32( int(needAction) )
|
structData += fxconv.u32( int(needAction) )
|
||||||
|
|
||||||
|
@ -345,8 +351,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
|
|
||||||
#else we do nothing (yet)
|
#else we do nothing (yet)
|
||||||
else:
|
else:
|
||||||
print( "Skip this object" )
|
if DEBUG: print( "Skip this object" )
|
||||||
|
|
||||||
|
|
||||||
return nbExtraData, structData
|
return nbExtraData, structData
|
||||||
|
|
||||||
|
@ -372,16 +377,16 @@ def convert_font(input, output, params, target):
|
||||||
|
|
||||||
def convert_dialogs(input, output, params, target):
|
def convert_dialogs(input, output, params, target):
|
||||||
|
|
||||||
print( "WE ARE COMPUTING THE DIALOGS FROM : ", input )
|
if DEBUG: print( "WE ARE COMPUTING THE DIALOGS FROM : ", input )
|
||||||
data = json.load(open(input, "r"))
|
data = json.load(open(input, "r"))
|
||||||
|
|
||||||
structDialogs = fxconv.Structure()
|
structDialogs = fxconv.Structure()
|
||||||
nbdialogs = 0
|
nbdialogs = 0
|
||||||
|
|
||||||
for d in data["dialogs"]:
|
for d in data["dialogs"]:
|
||||||
print( int(d[ "ID" ]))
|
if DEBUG: print( int(d[ "ID" ]))
|
||||||
# print( d[ "dialog" ] )
|
# print( d[ "dialog" ] )
|
||||||
print( int(d[ "isQuestion" ]) )
|
if DEBUG: print( int(d[ "isQuestion" ]) )
|
||||||
# print( d[ "choice" ].replace('$', chr(0)) )
|
# print( d[ "choice" ].replace('$', chr(0)) )
|
||||||
# print( d[ "conclusion1" ] )
|
# print( d[ "conclusion1" ] )
|
||||||
# print( int(d[ "next1" ] ) )
|
# print( int(d[ "next1" ] ) )
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="14">
|
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="14">
|
||||||
<editorsettings>
|
<editorsettings>
|
||||||
<export target="level0.json" format="json"/>
|
<export target="level0.json" format="json"/>
|
||||||
</editorsettings>
|
</editorsettings>
|
||||||
|
@ -117,6 +117,7 @@
|
||||||
<object id="12" name="PNJ3" type="NPC" x="267.25" y="125.75">
|
<object id="12" name="PNJ3" type="NPC" x="267.25" y="125.75">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogID" type="int" value="12"/>
|
<property name="dialogID" type="int" value="12"/>
|
||||||
|
<property name="face" value="FEMALE"/>
|
||||||
<property name="hasPath" type="int" value="1"/>
|
<property name="hasPath" type="int" value="1"/>
|
||||||
<property name="needAction" type="int" value="1"/>
|
<property name="needAction" type="int" value="1"/>
|
||||||
<property name="path" type="object" value="13"/>
|
<property name="path" type="object" value="13"/>
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
<object id="2" name="PNJ2" type="NPC" x="164" y="132">
|
<object id="2" name="PNJ2" type="NPC" x="164" y="132">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogID" type="int" value="5"/>
|
<property name="dialogID" type="int" value="5"/>
|
||||||
|
<property name="face" value="MALE"/>
|
||||||
<property name="hasPath" type="int" value="0"/>
|
<property name="hasPath" type="int" value="0"/>
|
||||||
<property name="needAction" type="int" value="1"/>
|
<property name="needAction" type="int" value="1"/>
|
||||||
<property name="path" type="object" value="0"/>
|
<property name="path" type="object" value="0"/>
|
||||||
|
@ -135,6 +137,7 @@
|
||||||
<object id="10" name="PNJ1" type="NPC" x="252" y="164">
|
<object id="10" name="PNJ1" type="NPC" x="252" y="164">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogID" type="int" value="7"/>
|
<property name="dialogID" type="int" value="7"/>
|
||||||
|
<property name="face" value="MILKMAN"/>
|
||||||
<property name="hasPath" type="int" value="1"/>
|
<property name="hasPath" type="int" value="1"/>
|
||||||
<property name="needAction" type="int" value="1"/>
|
<property name="needAction" type="int" value="1"/>
|
||||||
<property name="path" type="object" value="9"/>
|
<property name="path" type="object" value="9"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4">
|
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogFile" type="file" value="DialogsLvl1.json"/>
|
<property name="dialogFile" type="file" value="DialogsLvl1.json"/>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -100,6 +100,7 @@
|
||||||
<object id="2" name="Gardien" type="NPC" x="303.636" y="117.273">
|
<object id="2" name="Gardien" type="NPC" x="303.636" y="117.273">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogID" type="int" value="1"/>
|
<property name="dialogID" type="int" value="1"/>
|
||||||
|
<property name="face" value="POLICE"/>
|
||||||
<property name="hasPath" type="int" value="1"/>
|
<property name="hasPath" type="int" value="1"/>
|
||||||
<property name="needAction" type="int" value="1"/>
|
<property name="needAction" type="int" value="1"/>
|
||||||
<property name="path" type="object" value="3"/>
|
<property name="path" type="object" value="3"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="5">
|
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="5">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="dialogFile" type="file" value="DialogsLvl2.json"/>
|
<property name="dialogFile" type="file" value="DialogsLvl2.json"/>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,297,298,299,300,0,0,0,225,226,227,228,225,226,227,228,0,0,0,0,0,273,274,275,276,0,0,0,
|
250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,297,298,299,300,0,0,0,225,226,227,228,225,226,227,228,0,0,0,0,0,273,274,275,276,0,0,0,
|
||||||
274,275,276,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,249,250,251,252,249,250,251,252,0,0,258,259,263,264,0,0,0,0,0,0,
|
274,275,276,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,249,250,251,252,249,250,251,252,0,0,258,259,263,264,0,0,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,273,274,275,276,273,274,275,276,0,0,282,3,3,288,0,0,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,273,274,275,276,273,274,275,276,0,0,282,307,311,288,0,0,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,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,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,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,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,
|
||||||
|
|
1
clean
|
@ -6,6 +6,7 @@ cd ..
|
||||||
rm -r build-cg
|
rm -r build-cg
|
||||||
rm -r build-cg-push
|
rm -r build-cg-push
|
||||||
rm -r build-fx
|
rm -r build-fx
|
||||||
|
rm -r build-fxg3a
|
||||||
rm *.g1a
|
rm *.g1a
|
||||||
rm *.g3a
|
rm *.g3a
|
||||||
|
|
||||||
|
|
46
src/config.h
|
@ -2,27 +2,55 @@
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
|
||||||
#if !defined(FXCG50) && defined(COLOR2BIT)
|
#define USB_FEATURE 0
|
||||||
|
#define DEBUGMODE 0
|
||||||
|
|
||||||
|
#include <gint/display.h>
|
||||||
|
|
||||||
|
/* Enable GrayMode on either FX and FX_G3A targets */
|
||||||
|
#if GINT_RENDER_MONO && defined(COLOR2BIT)
|
||||||
#define GRAYMODEOK 1
|
#define GRAYMODEOK 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_FEATURE 0
|
|
||||||
|
|
||||||
#define DEBUGMODE 0
|
|
||||||
|
|
||||||
#ifdef FXCG50
|
#if GINT_RENDER_RGB
|
||||||
|
/* The tile size */
|
||||||
#define T_HEIGHT 16
|
#define T_HEIGHT 16
|
||||||
#define T_WIDTH 16
|
#define T_WIDTH 16
|
||||||
|
/* The size of a pixel */
|
||||||
|
#define PXSIZE 2
|
||||||
|
#define PATH_COLOR C_RED
|
||||||
|
/* The size of the player */
|
||||||
|
#define P_WIDTH 16
|
||||||
|
#define P_HEIGHT 16
|
||||||
#else
|
#else
|
||||||
|
/* The tile size */
|
||||||
#define T_HEIGHT 8
|
#define T_HEIGHT 8
|
||||||
#define T_WIDTH 8
|
#define T_WIDTH 8
|
||||||
#endif
|
/* The pixel size */
|
||||||
|
|
||||||
#ifdef FXCG50
|
|
||||||
#define PXSIZE 2
|
|
||||||
#else
|
|
||||||
#define PXSIZE 1
|
#define PXSIZE 1
|
||||||
|
#define PATH_COLOR C_BLACK
|
||||||
|
/* The player size */
|
||||||
|
#define P_WIDTH 8
|
||||||
|
#define P_HEIGHT 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* SPEED should NOT be 8 or bigger: it may cause bugs when handling
|
||||||
|
* collisions! */
|
||||||
|
#define SPEED (PXSIZE*2)
|
||||||
|
|
||||||
|
/* The face size (in the dialogs) */
|
||||||
|
#define F_WIDTH (32*PXSIZE)
|
||||||
|
#define F_HEIGHT (32*PXSIZE)
|
||||||
|
|
||||||
|
/* the color of the text to go to the next dialog phase */
|
||||||
|
/* it improves readability to have something lighter */
|
||||||
|
#if GRAYMODEOK || (GINT_RENDER_RGB && !defined(COLOR1BIT))
|
||||||
|
#define NEXT_COLOR C_DARK
|
||||||
|
#else
|
||||||
|
#define NEXT_COLOR C_BLACK
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,20 +26,11 @@ extern font_t fontRPG;
|
||||||
uint32_t *lightVRAMcurrent, *darkVRAMcurrent;
|
uint32_t *lightVRAMcurrent, *darkVRAMcurrent;
|
||||||
#endif //GRAYMODEOK
|
#endif //GRAYMODEOK
|
||||||
|
|
||||||
/* the color of the text to go to the next dialog phase */
|
|
||||||
/* it improves readability to have somathing lighter */
|
|
||||||
#if GRAYMODEOK || (defined(FXCG50) && !defined(COLOR1BIT))
|
|
||||||
#define NEXT_COLOR C_DARK
|
|
||||||
#else
|
|
||||||
#define NEXT_COLOR C_BLACK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
void blit() {
|
||||||
void blit()
|
|
||||||
{
|
|
||||||
dupdate();
|
dupdate();
|
||||||
|
|
||||||
#if GRAYMODEOK
|
#if GRAYMODEOK && !GINT_HW_CG
|
||||||
dgray_getvram( &lightVRAMnext, &darkVRAMnext );
|
dgray_getvram( &lightVRAMnext, &darkVRAMnext );
|
||||||
dgray_getscreen( &lightVRAMcurrent, &darkVRAMcurrent );
|
dgray_getscreen( &lightVRAMcurrent, &darkVRAMcurrent );
|
||||||
|
|
||||||
|
@ -49,7 +40,7 @@ void blit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
int dialogs_text_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
int call_before_end(Game *game, unsigned int i),
|
int call_before_end(Game *game, unsigned int i),
|
||||||
bool start_anim,
|
bool start_anim,
|
||||||
bool end_anim,
|
bool end_anim,
|
||||||
|
@ -69,7 +60,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
/* Redrawing the entire screen, because maybe there was no dialog
|
/* Redrawing the entire screen, because maybe there was no dialog
|
||||||
displayed before. */
|
displayed before. */
|
||||||
update_npcs(game);
|
update_npcs(game);
|
||||||
draw(game);
|
game_draw(game);
|
||||||
|
|
||||||
/* Fill the dialog box with white */
|
/* Fill the dialog box with white */
|
||||||
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
||||||
|
@ -89,7 +80,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
}else{
|
}else{
|
||||||
/* Here I'm drawing the same as if start_anim is true, but whitout
|
/* Here I'm drawing the same as if start_anim is true, but whitout
|
||||||
* making an animation. */
|
* making an animation. */
|
||||||
draw(game);
|
game_draw(game);
|
||||||
drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
|
drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
|
||||||
drect(0, BOX_HEIGHT*PXSIZE, DWIDTH, (BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
drect(0, BOX_HEIGHT*PXSIZE, DWIDTH, (BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
dimage(4*PXSIZE, 2*PXSIZE, face);
|
dimage(4*PXSIZE, 2*PXSIZE, face);
|
||||||
|
@ -150,7 +141,12 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
if(l>=max_lines_amount-1){
|
if(l>=max_lines_amount-1){
|
||||||
/* If we drew one entire screen. */
|
/* If we drew one entire screen. */
|
||||||
/* Wait that the SHIFT key is pressed if we should. */
|
/* Wait that the SHIFT key is pressed if we should. */
|
||||||
if(wait_continue) while(getkey_opt(GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT) sleep();
|
if(wait_continue){
|
||||||
|
while(getkey_opt(GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT &
|
||||||
|
~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT){
|
||||||
|
sleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Clear the text area. */
|
/* Clear the text area. */
|
||||||
drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2,
|
drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2,
|
||||||
C_WHITE);
|
C_WHITE);
|
||||||
|
@ -174,7 +170,12 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
dtext(BOX_HEIGHT*PXSIZE, y, NEXT_COLOR, "[SHIFT] : suite...");
|
dtext(BOX_HEIGHT*PXSIZE, y, NEXT_COLOR, "[SHIFT] : suite...");
|
||||||
/* Update the screen and wait for SHIFT being pressed, if needed. */
|
/* Update the screen and wait for SHIFT being pressed, if needed. */
|
||||||
if(update_screen) blit();
|
if(update_screen) blit();
|
||||||
if(wait_continue) while(getkey_opt( GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT) sleep();
|
if(wait_continue){
|
||||||
|
while(getkey_opt(GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT &
|
||||||
|
~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT){
|
||||||
|
sleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(call_before_end) return_int = call_before_end(game, i);
|
if(call_before_end) return_int = call_before_end(game, i);
|
||||||
if(end_anim){
|
if(end_anim){
|
||||||
|
@ -182,7 +183,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
for(i=BOX_HEIGHT;i>0;i--){
|
for(i=BOX_HEIGHT;i>0;i--){
|
||||||
/* It is the same as the start animation. */
|
/* It is the same as the start animation. */
|
||||||
update_npcs(game);
|
update_npcs(game);
|
||||||
draw(game);
|
game_draw(game);
|
||||||
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
||||||
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
||||||
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
|
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
|
||||||
|
@ -197,11 +198,11 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
return return_int;
|
return return_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showtext_dialog(Game *game, bopti_image_t *face, char *text,
|
void dialogs_text(Game *game, bopti_image_t *face, char *text,
|
||||||
bool dialog_start, bool dialog_end) {
|
bool dialog_start, bool dialog_end) {
|
||||||
/* Run showtext_opt with some default values. It makes it easier to use in
|
/* Run showtext_opt with some default values. It makes it easier to use in
|
||||||
* simple dialogs. */
|
* simple dialogs. */
|
||||||
showtext_opt(game, face, text, NULL, dialog_start, dialog_end, NULL, 100,
|
dialogs_text_opt(game, face, text, NULL, dialog_start, dialog_end, NULL, 100,
|
||||||
true, 0, true);
|
true, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +304,8 @@ int _choice_call_before_end(Game *game, [[maybe_unused]] unsigned int org_i) {
|
||||||
for(i=DWIDTH/8+1;i>0;i--){
|
for(i=DWIDTH/8+1;i>0;i--){
|
||||||
/* I'm drawing the same box as on the start animation */
|
/* I'm drawing the same box as on the start animation */
|
||||||
update_npcs(game);
|
update_npcs(game);
|
||||||
draw(game);
|
game_draw(game);
|
||||||
showtext_opt(game, _face, _text, NULL, false, false, NULL, 0, false,
|
dialogs_text_opt(game, _face, _text, NULL, false, false, NULL, 0, false,
|
||||||
_i, false);
|
_i, false);
|
||||||
drect(0, (BOX_HEIGHT+1)*PXSIZE+1, i*(DWIDTH/8),
|
drect(0, (BOX_HEIGHT+1)*PXSIZE+1, i*(DWIDTH/8),
|
||||||
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
|
||||||
|
@ -321,7 +322,7 @@ int _choice_call_before_end(Game *game, [[maybe_unused]] unsigned int org_i) {
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
int dialogs_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
||||||
bool end, char *choices, int choices_amount,
|
bool end, char *choices, int choices_amount,
|
||||||
int default_choice) {
|
int default_choice) {
|
||||||
/* Put some arguments in global pointers and variables to make them
|
/* Put some arguments in global pointers and variables to make them
|
||||||
|
@ -333,16 +334,16 @@ int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
||||||
_text = text;
|
_text = text;
|
||||||
/* Run showtext_opt and return his return value (the return value of
|
/* Run showtext_opt and return his return value (the return value of
|
||||||
*_choice_call_before_end) */
|
*_choice_call_before_end) */
|
||||||
return showtext_opt(game, face, text, _choice_call_before_end, start, end,
|
return dialogs_text_opt(game, face, text, _choice_call_before_end, start,
|
||||||
_choice_screen_call, 100, true, 0, true);
|
end, _choice_screen_call, 100, true, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void initiate_dialog_sequence(Game *game, bopti_image_t *face, uint32_t dialogNumber )
|
void dialogs_initiate_sequence(Game *game, bopti_image_t *face,
|
||||||
{
|
uint32_t dialogNumber) {
|
||||||
Dialog *currentDiag = &game->map_level->dialogs[ dialogNumber ];
|
Dialog *currentDiag = &game->map_level->dialogs[dialogNumber];
|
||||||
|
|
||||||
/* we collect the information */
|
/* we collect the information */
|
||||||
char *text = currentDiag->dialog;
|
char *text = currentDiag->dialog;
|
||||||
|
@ -356,27 +357,23 @@ void initiate_dialog_sequence(Game *game, bopti_image_t *face, uint32_t dialogNu
|
||||||
int isQuestion = currentDiag->isQuestion;
|
int isQuestion = currentDiag->isQuestion;
|
||||||
|
|
||||||
/* we treat the action - i.e. we show a dialog */
|
/* we treat the action - i.e. we show a dialog */
|
||||||
if (isQuestion == 1) /* we have to manage a question */
|
if (isQuestion == 1){
|
||||||
{
|
/* we have to manage a question */
|
||||||
int answer = showtext_dialog_ask( game, face, text, true, true, choices, 2, 0 );
|
int answer = dialogs_ask(game, face, text, true, true,
|
||||||
|
choices, 2, 0);
|
||||||
|
|
||||||
/* TO DO we need to split the strings conclusion1 and conclusion2 */
|
/* TO DO we need to split the strings conclusion1 and conclusion2 */
|
||||||
/* to extract the "gift" part */
|
/* to extract the "gift" part */
|
||||||
|
|
||||||
if (answer==0)
|
if(answer==0){
|
||||||
{
|
dialogs_text(game, face, conclusion1, true, true);
|
||||||
showtext_dialog( game, face, conclusion1, true, true );
|
if (next1!=-1) dialogs_initiate_sequence(game, face, next1);
|
||||||
if (next1!=-1) initiate_dialog_sequence( game, face, next1 );
|
}else{
|
||||||
|
dialogs_text(game, face, conclusion2, true, true);
|
||||||
|
if (next2!=-1) dialogs_initiate_sequence(game, face, next2);
|
||||||
}
|
}
|
||||||
else
|
}else{
|
||||||
{
|
dialogs_text(game, face, text, true, true);
|
||||||
showtext_dialog( game, face, conclusion2, true, true );
|
if (nextOther!=-1) dialogs_initiate_sequence(game, face, nextOther);
|
||||||
if (next2!=-1) initiate_dialog_sequence( game, face, next2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
showtext_dialog( game, face, text, true, true );
|
|
||||||
if (nextOther!=-1) initiate_dialog_sequence( game, face, nextOther );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define F_WIDTH (32*PXSIZE)
|
/* dialogs_text_opt()
|
||||||
#define F_HEIGHT (32*PXSIZE)
|
|
||||||
|
|
||||||
/* showtext_opt()
|
|
||||||
*
|
*
|
||||||
* Show some text in a box with word wrap for dialogs.
|
* Show some text in a box with word wrap for dialogs.
|
||||||
*
|
*
|
||||||
|
@ -37,17 +35,17 @@
|
||||||
* wait_continue: If I should wait that EXE is pressed after drawing a page.
|
* wait_continue: If I should wait that EXE is pressed after drawing a page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
int dialogs_text_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
int call_before_end(Game *game, unsigned int i),
|
int call_before_end(Game *game, unsigned int i),
|
||||||
bool start_anim,
|
bool start_anim,
|
||||||
bool end_anim,
|
bool end_anim,
|
||||||
void for_each_screen(Game *game, unsigned int i),
|
void for_each_screen(Game *game, unsigned int i),
|
||||||
int line_duration, bool update_screen, unsigned int start_i,
|
int line_duration, bool update_screen,
|
||||||
bool wait_continue);
|
unsigned int start_i, bool wait_continue);
|
||||||
|
|
||||||
/* showtext_dialog()
|
/* dialogs_text()
|
||||||
*
|
*
|
||||||
* Calls showtext_opt with default parameters.
|
* Calls dialogs_text_opt with default parameters.
|
||||||
*
|
*
|
||||||
* game: The game struct of the current game.
|
* game: The game struct of the current game.
|
||||||
* face: A bopti_image_t of the face of the person who's saying this
|
* face: A bopti_image_t of the face of the person who's saying this
|
||||||
|
@ -60,12 +58,12 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
* shown at the end of showtext_opt.
|
* shown at the end of showtext_opt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void showtext_dialog(Game *game, bopti_image_t *face, char *text,
|
void dialogs_text(Game *game, bopti_image_t *face, char *text,
|
||||||
bool dialog_start, bool dialog_end);
|
bool dialog_start, bool dialog_end);
|
||||||
|
|
||||||
/* showtext_dialog_ask()
|
/* dialogs_ask()
|
||||||
*
|
*
|
||||||
* Like showtext_dialog, but lets the user choose between multiple possible
|
* Like dialogs_text, but lets the user choose between multiple possible
|
||||||
* choices after displaying the text.
|
* choices after displaying the text.
|
||||||
*
|
*
|
||||||
* game: The game struct of the current game.
|
* game: The game struct of the current game.
|
||||||
|
@ -85,10 +83,12 @@ void showtext_dialog(Game *game, bopti_image_t *face, char *text,
|
||||||
* default_choice: The choice choosen by default when the dialog just opened.
|
* default_choice: The choice choosen by default when the dialog just opened.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
int dialogs_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
||||||
bool end, char *choices, int choices_amount,
|
bool end, char *choices, int choices_amount,
|
||||||
int default_choice);
|
int default_choice);
|
||||||
|
|
||||||
void initiate_dialog_sequence(Game *game, bopti_image_t *face, uint32_t dialogNumber );
|
/* TODO: Doc. */
|
||||||
|
void dialogs_initiate_sequence(Game *game, bopti_image_t *face,
|
||||||
|
uint32_t dialogNumber);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
29
src/events.h
|
@ -1,8 +1,12 @@
|
||||||
#ifndef EVENTS_H
|
#ifndef EVENTS_H
|
||||||
#define EVENTS_H
|
#define EVENTS_H
|
||||||
|
|
||||||
|
/* The max amount of variables that can be bound. */
|
||||||
#define MAX_VARIABLES 32
|
#define MAX_VARIABLES 32
|
||||||
|
/* The max. size of the message buffer.
|
||||||
|
* WARNING: Bigger messages will be truncated! */
|
||||||
#define MESSAGE_BUFFER_SZ 1024
|
#define MESSAGE_BUFFER_SZ 1024
|
||||||
|
/* The maximal size of a token. Bigger tokens will be truncated. */
|
||||||
#define TOKEN_MAX_SZ 1024
|
#define TOKEN_MAX_SZ 1024
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -28,8 +32,33 @@ typedef enum {
|
||||||
OP_AMOUNT
|
OP_AMOUNT
|
||||||
} Operation;
|
} Operation;
|
||||||
|
|
||||||
|
/* events_init_handler()
|
||||||
|
*
|
||||||
|
* Initialize an event handler.
|
||||||
|
* handler: The Event handler to initialize.
|
||||||
|
*/
|
||||||
void events_init_handler(EventHandler *handler);
|
void events_init_handler(EventHandler *handler);
|
||||||
|
/* events_bind_variable()
|
||||||
|
*
|
||||||
|
* Bind a variable. Binding a variable allows it to be modified by messages
|
||||||
|
* passed to the event handler using tags written as following:
|
||||||
|
* `variable+number` (The backticks delimit the tag). Available operators:
|
||||||
|
* '=': Assign a value to the variable.
|
||||||
|
* '+': Addition.
|
||||||
|
* '-': Substraction.
|
||||||
|
* '*': Multiplication.
|
||||||
|
* '/': Division.
|
||||||
|
* '%': Modulo.
|
||||||
|
* handler: The event handler.
|
||||||
|
* var: A pointer to the variable to bind.
|
||||||
|
* name: The name of the variable. This is the name that will be used to
|
||||||
|
* refer to this variable in a tag.
|
||||||
|
*/
|
||||||
int events_bind_variable(EventHandler *handler, int *var, char *name);
|
int events_bind_variable(EventHandler *handler, int *var, char *name);
|
||||||
|
/* events_parse_string()
|
||||||
|
* handler: The event handler.
|
||||||
|
* message: The message to parse.
|
||||||
|
*/
|
||||||
char *events_parse_string(EventHandler *handler, char *message);
|
char *events_parse_string(EventHandler *handler, char *message);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
41
src/game.c
|
@ -27,18 +27,16 @@ void game_logic(Game *game) {
|
||||||
update_npcs( game );
|
update_npcs( game );
|
||||||
|
|
||||||
/* we check if interactions are possible close to the player */
|
/* we check if interactions are possible close to the player */
|
||||||
for( uint32_t i=0; i<game->map_level->nbextradata; i++ )
|
for( uint32_t i=0; i<game->map_level->nbextradata; i++ ){
|
||||||
{
|
|
||||||
/* simple distance check along X and Y axis */
|
/* simple distance check along X and Y axis */
|
||||||
/* Be careful to use world coordinates, not local (i.e.map) ones */
|
/* Be careful to use world coordinates, not local (i.e.map) ones */
|
||||||
if ( (abs((int) game->player.wx -
|
if ((abs((int) game->player.wx -
|
||||||
(int) game->map_level->extradata[i].x*PXSIZE )
|
(int) game->map_level->extradata[i].x*PXSIZE )
|
||||||
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
||||||
&& (abs((int) game->player.wy -
|
&& (abs((int) game->player.wy -
|
||||||
(int) game->map_level->extradata[i].y*PXSIZE )
|
(int) game->map_level->extradata[i].y*PXSIZE )
|
||||||
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
||||||
&& strcmp( game->map_level->extradata[i].type, "NPC") !=0 )
|
&& strcmp(game->map_level->extradata[i].type, "NPC") != 0){
|
||||||
{
|
|
||||||
/* the player can do something */
|
/* the player can do something */
|
||||||
game->player.canDoSomething = true;
|
game->player.canDoSomething = true;
|
||||||
/* we mark the action for futur treatment in player_action() */
|
/* we mark the action for futur treatment in player_action() */
|
||||||
|
@ -49,18 +47,16 @@ void game_logic(Game *game) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( uint32_t i=0; i<nbNPC; i++ )
|
for(uint32_t i=0; i<nbNPC; i++){
|
||||||
{
|
|
||||||
/* simple distance check along X and Y axis */
|
/* simple distance check along X and Y axis */
|
||||||
/* Be careful to use world coordinates, not local (i.e.map) ones */
|
/* Be careful to use world coordinates, not local (i.e.map) ones */
|
||||||
if ( (abs((int) game->player.wx -
|
if ((abs((int) game->player.wx -
|
||||||
(int) npcRPG[i].curx*PXSIZE )
|
(int) npcRPG[i].curx*PXSIZE )
|
||||||
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
||||||
&& (abs((int) game->player.wy -
|
&& (abs((int) game->player.wy -
|
||||||
(int) npcRPG[i].cury*PXSIZE )
|
(int) npcRPG[i].cury*PXSIZE )
|
||||||
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
< MAX_INTERACTION_DISTANCE*PXSIZE)
|
||||||
&& strcmp( game->map_level->extradata[i].type, "NPC") !=0 )
|
&& strcmp( game->map_level->extradata[i].type, "NPC") !=0){
|
||||||
{
|
|
||||||
/* the player can do something */
|
/* the player can do something */
|
||||||
game->player.canDoSomething = true;
|
game->player.canDoSomething = true;
|
||||||
/* we mark the action for futur treatment in player_action() */
|
/* we mark the action for futur treatment in player_action() */
|
||||||
|
@ -80,35 +76,31 @@ void game_logic(Game *game) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render_indicator(Game *game)
|
void game_render_indicator(Game *game) {
|
||||||
{
|
|
||||||
/* nothing to do for the player so we quit */
|
/* nothing to do for the player so we quit */
|
||||||
if (game->player.canDoSomething==false)
|
if(game->player.canDoSomething==false) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/* else we draw a small indicator on the screen */
|
/* else we draw a small indicator on the screen */
|
||||||
dimage(5, 5, &SignAction_img);
|
dimage(5, 5, &SignAction_img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw(Game *game) {
|
void game_draw(Game *game) {
|
||||||
/* Draw everything. */
|
/* Draw everything. */
|
||||||
render_map_by_layer(game, BACKGROUND);
|
dclear(C_WHITE);
|
||||||
npc_draw( game );
|
map_render_by_layer(game, BACKGROUND);
|
||||||
|
npc_draw(game);
|
||||||
player_draw(game);
|
player_draw(game);
|
||||||
render_map_by_layer(game, FOREGROUND);
|
map_render_by_layer(game, FOREGROUND);
|
||||||
render_indicator( game );
|
game_render_indicator(game);
|
||||||
dprint(8, 8, C_BLACK, "Lifes: %d", game->player.life);
|
dprint(8, 8, C_BLACK, "Lifes: %d", game->player.life);
|
||||||
dprint(8, 16, C_BLACK, "Mana: %d", game->mana);
|
dprint(8, 16, C_BLACK, "Mana: %d", game->mana);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Key management */
|
/* Key management */
|
||||||
|
|
||||||
void get_inputs(Game *game) {
|
void game_get_inputs(Game *game) {
|
||||||
key_event_t ev;
|
clearevents();
|
||||||
while((ev = pollevent()).type != KEYEV_NONE){
|
|
||||||
/**/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Key binding for the Player action */
|
/* Key binding for the Player action */
|
||||||
|
|
||||||
|
@ -145,4 +137,3 @@ void get_inputs(Game *game) {
|
||||||
|
|
||||||
#endif //USB_FEATURE
|
#endif //USB_FEATURE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
27
src/game.h
|
@ -72,6 +72,7 @@ typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
/* its class (NPC, SGN, INFO, ... )*/
|
/* its class (NPC, SGN, INFO, ... )*/
|
||||||
char *type;
|
char *type;
|
||||||
|
char *face;
|
||||||
|
|
||||||
/* the ID of the first element of the dialog */
|
/* the ID of the first element of the dialog */
|
||||||
/* (to be aligned with "dialogs.json" IDs)*/
|
/* (to be aligned with "dialogs.json" IDs)*/
|
||||||
|
@ -155,15 +156,27 @@ typedef struct {
|
||||||
/* (Mibi88) TODO: Describe what this function is doing. */
|
/* (Mibi88) TODO: Describe what this function is doing. */
|
||||||
void game_logic(Game *game);
|
void game_logic(Game *game);
|
||||||
|
|
||||||
/* Draws everything on screen. */
|
/* game_draw()
|
||||||
void draw(Game *game);
|
*
|
||||||
|
* Draws everything on screen.
|
||||||
|
* game: The game struct.
|
||||||
|
*/
|
||||||
|
void game_draw(Game *game);
|
||||||
|
|
||||||
/* This render a small sign on the upper lecft corner of the screen */
|
/* game_render_indicator()
|
||||||
/* if the player can do an action */
|
*
|
||||||
void render_indicator(Game *game);
|
* This render a small sign on the upper left corner of the screen
|
||||||
|
* if the player can do an action
|
||||||
|
* game: The game struct.
|
||||||
|
*/
|
||||||
|
void game_render_indicator(Game *game);
|
||||||
|
|
||||||
/* Handle key presses. */
|
/* game_get_inputs()
|
||||||
void get_inputs(Game *game);
|
*
|
||||||
|
* Handle key presses.
|
||||||
|
* game: The game struct.
|
||||||
|
*/
|
||||||
|
void game_get_inputs(Game *game);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ Game game = {
|
||||||
, false, false, false, 100
|
, false, false, false, 100
|
||||||
};
|
};
|
||||||
|
|
||||||
/* screen capture management code */
|
/* screen capture management code. TODO: Clean this up! */
|
||||||
|
|
||||||
#if USB_FEATURE
|
#if USB_FEATURE
|
||||||
|
|
||||||
|
@ -125,9 +125,9 @@ int main(void) {
|
||||||
dclear(C_WHITE);
|
dclear(C_WHITE);
|
||||||
|
|
||||||
/* render the map */
|
/* render the map */
|
||||||
draw(&game);
|
game_draw(&game);
|
||||||
|
|
||||||
#if DEBUGMODE && FXCG50
|
#if DEBUGMODE && GINT_RENDER_RGB
|
||||||
if (game.debug_map)
|
if (game.debug_map)
|
||||||
{
|
{
|
||||||
dfont( NULL );
|
dfont( NULL );
|
||||||
|
@ -178,7 +178,7 @@ int main(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Management of the inputs */
|
/* Management of the inputs */
|
||||||
get_inputs(&game);
|
game_get_inputs(&game);
|
||||||
/* Run the game at max. 50fps */
|
/* Run the game at max. 50fps */
|
||||||
while(game.frame_duration < 20) sleep();
|
while(game.frame_duration < 20) sleep();
|
||||||
/* Reset frame_duration for the next frame */
|
/* Reset frame_duration for the next frame */
|
||||||
|
|
19
src/map.c
|
@ -8,7 +8,7 @@ extern Map *worldRPG[];
|
||||||
//extern ExtraData *extraRPG[];
|
//extern ExtraData *extraRPG[];
|
||||||
|
|
||||||
|
|
||||||
void render_map(Game *game) {
|
void map_render(Game *game) {
|
||||||
|
|
||||||
Map *map_level = game->map_level;
|
Map *map_level = game->map_level;
|
||||||
Player *player = &game->player;
|
Player *player = &game->player;
|
||||||
|
@ -104,7 +104,7 @@ void render_map(Game *game) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_map_by_layer(Game *game, int layer) {
|
void map_render_by_layer(Game *game, int layer) {
|
||||||
|
|
||||||
Map *map_level = game->map_level;
|
Map *map_level = game->map_level;
|
||||||
Player *player = &game->player;
|
Player *player = &game->player;
|
||||||
|
@ -194,7 +194,7 @@ void render_map_by_layer(Game *game, int layer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short int get_tile(Game *game, int x, int y, int l) {
|
short int map_get_tile(Game *game, int x, int y, int l) {
|
||||||
|
|
||||||
Map *map_level = game->map_level;
|
Map *map_level = game->map_level;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ short int get_tile(Game *game, int x, int y, int l) {
|
||||||
map_level->layers[l][y * map_level->w + x] : MAP_OUTSIDE;
|
map_level->layers[l][y * map_level->w + x] : MAP_OUTSIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
short int get_walkable(Game *game, int x, int y) {
|
short int map_get_walkable(Game *game, int x, int y) {
|
||||||
|
|
||||||
Map *map_level = game->map_level;
|
Map *map_level = game->map_level;
|
||||||
/* Get the tile at (x, y). Returns the tile ID or MAP_OUTSIDE if she's not
|
/* Get the tile at (x, y). Returns the tile ID or MAP_OUTSIDE if she's not
|
||||||
|
@ -214,25 +214,24 @@ short int get_walkable(Game *game, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the pointer to the map containing the given position */
|
/* return the pointer to the map containing the given position */
|
||||||
Map *get_map_for_coordinates( Game *game, int x, int y )
|
Map *map_get_for_coordinates( Game *game, int x, int y )
|
||||||
{
|
{
|
||||||
/* check if the current map contains the point */
|
/* check if the current map contains the point */
|
||||||
if (x>= (int)game->map_level->xmin && x< (int)game->map_level->xmax &&
|
if (x>= (int)game->map_level->xmin && x< (int)game->map_level->xmax &&
|
||||||
y>= (int)game->map_level->ymin && y< (int)game->map_level->ymax)
|
y>= (int)game->map_level->ymin && y< (int)game->map_level->ymax){
|
||||||
return game->map_level;
|
return game->map_level;
|
||||||
|
}
|
||||||
|
|
||||||
/* else we check in worldRPG if there is a mal containing that point */
|
/* else we check in worldRPG if there is a mal containing that point */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Map *current = worldRPG[i];
|
Map *current = worldRPG[i];
|
||||||
do
|
do{
|
||||||
{
|
|
||||||
if (x>= (int)current->xmin && x< (int)current->xmax &&
|
if (x>= (int)current->xmin && x< (int)current->xmax &&
|
||||||
y>= (int)current->ymin && y< (int)current->ymax)
|
y>= (int)current->ymin && y< (int)current->ymax)
|
||||||
return current;
|
return current;
|
||||||
i++;
|
i++;
|
||||||
current = worldRPG[i];
|
current = worldRPG[i];
|
||||||
}
|
}while (current!=NULL);
|
||||||
while (current!=NULL);
|
|
||||||
|
|
||||||
/* else we return NULL cause the point is a not within a map */
|
/* else we return NULL cause the point is a not within a map */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
51
src/map.h
|
@ -19,21 +19,48 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Draws the map map on the entire screen to be viewed by the player player. */
|
/* map_render()
|
||||||
void render_map(Game *game);
|
*
|
||||||
|
* Draws the map map on the entire screen to be viewed by the player player.
|
||||||
/* Draws the map layer on the entire screen to be viewed by the player player.
|
* game: The game struct.
|
||||||
*/
|
*/
|
||||||
void render_map_by_layer(Game *game, int layer);
|
void map_render(Game *game);
|
||||||
|
|
||||||
/* Get the tile at (x, y) of the map map. If the tile is located outside of the
|
/* map_render_by_layer()
|
||||||
* screen, MAP_OUTSIDE is returned. */
|
*
|
||||||
short int get_tile(Game *game, int x, int y, int l);
|
* Draws the map layer on the entire screen to be viewed by the player player.
|
||||||
|
* game: The game struct.
|
||||||
|
* layer: The layer to render.
|
||||||
|
*/
|
||||||
|
void map_render_by_layer(Game *game, int layer);
|
||||||
|
|
||||||
/* Returns what is in the walkable layer at (x, y). */
|
/* map_get_tile()
|
||||||
short int get_walkable(Game *game, int x, int y);
|
*
|
||||||
|
* Get the tile at (x, y) of the map map. If the tile is located outside of the
|
||||||
|
* screen, MAP_OUTSIDE is returned.
|
||||||
|
* game: The game struct.
|
||||||
|
* x: The coordinates of the tile.
|
||||||
|
* y: The coordinates of the tile.
|
||||||
|
* l: The layer of the tile.
|
||||||
|
*/
|
||||||
|
short int map_get_tile(Game *game, int x, int y, int l);
|
||||||
|
|
||||||
/* return the pointer to the map containing the given position */
|
/* map_get_walkable()
|
||||||
Map* get_map_for_coordinates(Game *game, int x, int y );
|
*
|
||||||
|
* Returns what is in the walkable layer at (x, y).
|
||||||
|
* game: The game struct.
|
||||||
|
* x: The coordinates of the tile.
|
||||||
|
* y: The coordinates of the tile.
|
||||||
|
*/
|
||||||
|
short int map_get_walkable(Game *game, int x, int y);
|
||||||
|
|
||||||
|
/* map_get_for_coordinates()
|
||||||
|
*
|
||||||
|
* return the pointer to the map containing the given position.
|
||||||
|
* game: The game struct.
|
||||||
|
* x: The coordinates to look at.
|
||||||
|
* y: The coordinates to look at.
|
||||||
|
*/
|
||||||
|
Map* map_get_for_coordinates(Game *game, int x, int y );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
bool is_in(short int *array, short int array_length, short int item) {
|
bool memory_is_in(short int *array, short int array_length, short int item) {
|
||||||
short int i;
|
short int i;
|
||||||
for(i=0;i<array_length;i++){
|
for(i=0;i<array_length;i++){
|
||||||
if(array[i] == item){
|
if(array[i] == item){
|
||||||
|
|
10
src/memory.h
|
@ -2,8 +2,14 @@
|
||||||
#define MEMORY_H
|
#define MEMORY_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
/* memory_is_in()
|
||||||
bool is_in(short int *array, short int array_length, short int item);
|
*
|
||||||
|
* returns true if item is in array.
|
||||||
|
* array: The array to search in.
|
||||||
|
* array_length: The length of the array.
|
||||||
|
* item: The item to search for.
|
||||||
|
*/
|
||||||
|
bool memory_is_in(short int *array, short int array_length, short int item);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
10
src/npc.c
|
@ -14,15 +14,6 @@
|
||||||
extern bopti_image_t demo_PNJ_img;
|
extern bopti_image_t demo_PNJ_img;
|
||||||
|
|
||||||
|
|
||||||
/* the color of the text to go to the next dialog phase */
|
|
||||||
/* it improves readability to have something lighter */
|
|
||||||
#if defined(FXCG50)
|
|
||||||
#define PATH_COLOR C_RED
|
|
||||||
#else
|
|
||||||
#define PATH_COLOR C_BLACK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
NPC *npcRPG;
|
NPC *npcRPG;
|
||||||
uint32_t nbNPC = 0;
|
uint32_t nbNPC = 0;
|
||||||
|
|
||||||
|
@ -310,6 +301,7 @@ void reload_npc(Game *game)
|
||||||
npcRPG[currentNPC].xpath = Data->xpath;
|
npcRPG[currentNPC].xpath = Data->xpath;
|
||||||
npcRPG[currentNPC].ypath = Data->ypath;
|
npcRPG[currentNPC].ypath = Data->ypath;
|
||||||
npcRPG[currentNPC].paused = false;
|
npcRPG[currentNPC].paused = false;
|
||||||
|
npcRPG[currentNPC].face = Data->face;
|
||||||
currentNPC++;
|
currentNPC++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ typedef struct
|
||||||
/* is the current NPC in pause (during dialog) */
|
/* is the current NPC in pause (during dialog) */
|
||||||
bool paused;
|
bool paused;
|
||||||
|
|
||||||
|
char *face;
|
||||||
} NPC;
|
} NPC;
|
||||||
|
|
||||||
//Frees then malloc()s a new path to npc
|
//Frees then malloc()s a new path to npc
|
||||||
|
|
99
src/player.c
|
@ -6,6 +6,28 @@
|
||||||
#include "npc.h"
|
#include "npc.h"
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
|
|
||||||
|
#define FACES 4
|
||||||
|
|
||||||
|
struct Face {
|
||||||
|
const char *name;
|
||||||
|
bopti_image_t *face;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern bopti_image_t demo_player_img;
|
||||||
|
extern bopti_image_t npc_male;
|
||||||
|
extern bopti_image_t npc_female;
|
||||||
|
extern bopti_image_t npc_milkman;
|
||||||
|
extern bopti_image_t npc_police;
|
||||||
|
extern bopti_image_t SGN_Icon_img;
|
||||||
|
extern bopti_image_t INFO_Icon_img;
|
||||||
|
|
||||||
|
const struct Face faces[FACES] = {
|
||||||
|
{"MALE", &npc_male},
|
||||||
|
{"FEMALE", &npc_female},
|
||||||
|
{"MILKMAN", &npc_milkman},
|
||||||
|
{"POLICE", &npc_police}
|
||||||
|
};
|
||||||
|
|
||||||
const char one_px_mov[8] = {
|
const char one_px_mov[8] = {
|
||||||
0, -1, /* Up */
|
0, -1, /* Up */
|
||||||
0, 1, /* Down */
|
0, 1, /* Down */
|
||||||
|
@ -83,18 +105,13 @@ void player_move(Game *game, Direction direction) {
|
||||||
player->wy = game->map_level->ymin * PXSIZE + player->y;
|
player->wy = game->map_level->ymin * PXSIZE + player->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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_action(Game *game) {
|
void player_action(Game *game) {
|
||||||
if( game->player.isDoingAction ) return; /* alreday doing something (action IS NOT with an NPC ) */
|
register size_t i;
|
||||||
|
/* already doing something (action IS NOT with an NPC) */
|
||||||
|
if(game->player.isDoingAction) return;
|
||||||
|
|
||||||
if( game->player.canDoSomething && !game->player.isInteractingWithNPC ) /* we can do something */
|
if(game->player.canDoSomething && !game->player.isInteractingWithNPC){
|
||||||
{
|
/* we can do something */
|
||||||
/* we indicate that the player is occupied */
|
/* we indicate that the player is occupied */
|
||||||
game->player.isDoingAction = true;
|
game->player.isDoingAction = true;
|
||||||
|
|
||||||
|
@ -106,23 +123,33 @@ void player_action(Game *game) {
|
||||||
/* we use the correct image as per the class of the item */
|
/* we use the correct image as per the class of the item */
|
||||||
|
|
||||||
|
|
||||||
if (strcmp("INFO", currentData->type)==0)
|
if (strcmp("INFO", currentData->type)==0){
|
||||||
face = &INFO_Icon_img;
|
face = &INFO_Icon_img;
|
||||||
//else if (strcmp("NPC", currentData->type)==0)
|
}else if (strcmp("SGN", currentData->type)==0){
|
||||||
// face = &NPC_Icon_img;
|
|
||||||
else if (strcmp("SGN", currentData->type)==0)
|
|
||||||
face = &SGN_Icon_img;
|
face = &SGN_Icon_img;
|
||||||
else face = &demo_player_img;
|
}else{
|
||||||
|
/* It's a NPC */
|
||||||
|
/* (Mibi88) TODO: Use string hash + strcmp if the hashes match for
|
||||||
|
* fast string comparison. */
|
||||||
|
face = NULL;
|
||||||
|
for(i=0;i<FACES;i++){
|
||||||
|
struct Face current_face = faces[i];
|
||||||
|
if(!strcmp(current_face.name, currentData->face)){
|
||||||
|
face = current_face.face;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!face) face = &npc_male;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t dialogStart = currentData->dialogID;
|
uint32_t dialogStart = currentData->dialogID;
|
||||||
|
|
||||||
initiate_dialog_sequence( game, face, dialogStart );
|
dialogs_initiate_sequence(game, face, dialogStart);
|
||||||
|
|
||||||
/* when done we release the occupied status of the player */
|
/* when done we release the occupied status of the player */
|
||||||
game->player.isDoingAction = false;
|
game->player.isDoingAction = false;
|
||||||
}
|
}else if(game->player.canDoSomething && game->player.isInteractingWithNPC){
|
||||||
else if( game->player.canDoSomething && game->player.isInteractingWithNPC ) /* we can do something (action IS with an NPC ) */
|
/* we can do something (action IS with an NPC) */
|
||||||
{
|
|
||||||
/* we indicate that the player is occupied */
|
/* we indicate that the player is occupied */
|
||||||
game->player.isDoingAction = true;
|
game->player.isDoingAction = true;
|
||||||
|
|
||||||
|
@ -130,14 +157,28 @@ void player_action(Game *game) {
|
||||||
|
|
||||||
/* we use the correct image as per the class of the item */
|
/* we use the correct image as per the class of the item */
|
||||||
|
|
||||||
bopti_image_t *face = &NPC_Icon_img;
|
ExtraData *currentData = &game->map_level->extradata[game->player.whichAction];
|
||||||
|
bopti_image_t *face = &npc_male;
|
||||||
|
/* It's a NPC */
|
||||||
|
/* (Mibi88) TODO: Use string hash + strcmp if the hashes match for
|
||||||
|
* fast string comparison. */
|
||||||
|
face = NULL;
|
||||||
|
for(i=0;i<FACES;i++){
|
||||||
|
struct Face current_face = faces[i];
|
||||||
|
if(!strcmp(current_face.name, currentNPC->face)){
|
||||||
|
face = current_face.face;
|
||||||
|
}
|
||||||
|
if(!face) face = &npc_male;
|
||||||
|
}
|
||||||
|
dtext(2, 64, C_BLACK, currentData->type);
|
||||||
uint32_t dialogStart = currentNPC->dialogID;
|
uint32_t dialogStart = currentNPC->dialogID;
|
||||||
|
|
||||||
/* we setr this NPC to paused to avoid changing its position while talking (the rest of the NPCs pursue their action)*/
|
/* we set this NPC to paused to avoid changing its position while
|
||||||
|
* talking (the rest of the NPCs pursue their action) */
|
||||||
currentNPC->paused = true;
|
currentNPC->paused = true;
|
||||||
|
|
||||||
|
|
||||||
initiate_dialog_sequence( game, face, dialogStart );
|
dialogs_initiate_sequence(game, face, dialogStart);
|
||||||
|
|
||||||
/* when done we release the occupied status of the player */
|
/* when done we release the occupied status of the player */
|
||||||
game->player.isDoingAction = false;
|
game->player.isDoingAction = false;
|
||||||
|
@ -174,15 +215,13 @@ bool player_collision(Game *game, Direction direction,
|
||||||
/* check where the player is expected to go on the next move */
|
/* 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 */
|
/* if outside the map, we check if there is a map on the other */
|
||||||
/* side of the current map*/
|
/* side of the current map*/
|
||||||
if (get_walkable(game, player_tile_x, player_tile_y) == MAP_OUTSIDE)
|
if (map_get_walkable(game, player_tile_x, player_tile_y) == MAP_OUTSIDE){
|
||||||
{
|
|
||||||
// we compute the expected world coordinates accordingly
|
// we compute the expected world coordinates accordingly
|
||||||
// while taking care of the scaling between fx and cg models (PXSIZE)
|
// while taking care of the scaling between fx and cg models (PXSIZE)
|
||||||
int worldX = (player->wx+dx) / PXSIZE;
|
int worldX = (player->wx+dx) / PXSIZE;
|
||||||
int worldY = (player->wy+dy) / PXSIZE;
|
int worldY = (player->wy+dy) / PXSIZE;
|
||||||
Map *map = get_map_for_coordinates(game, worldX, worldY );
|
Map *map = map_get_for_coordinates(game, worldX, worldY);
|
||||||
if (map!=NULL && map!=game->map_level)
|
if (map!=NULL && map!=game->map_level){
|
||||||
{
|
|
||||||
Map *backupmap = game->map_level;
|
Map *backupmap = game->map_level;
|
||||||
int backupx = player->x;
|
int backupx = player->x;
|
||||||
int backupy = player->y;
|
int backupy = player->y;
|
||||||
|
@ -197,7 +236,7 @@ bool player_collision(Game *game, Direction direction,
|
||||||
player->x = (worldX - map->xmin ) * PXSIZE;
|
player->x = (worldX - map->xmin ) * PXSIZE;
|
||||||
player->y = (worldY - map->ymin ) * PXSIZE;
|
player->y = (worldY - map->ymin ) * PXSIZE;
|
||||||
|
|
||||||
int on_walkable = get_walkable(game, player->x/T_WIDTH,
|
int on_walkable = map_get_walkable(game, player->x/T_WIDTH,
|
||||||
player->y/T_HEIGHT);
|
player->y/T_HEIGHT);
|
||||||
|
|
||||||
int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX) ?
|
int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX) ?
|
||||||
|
@ -217,7 +256,7 @@ bool player_collision(Game *game, Direction direction,
|
||||||
|
|
||||||
/* we update the list of NPCs in the current map */
|
/* we update the list of NPCs in the current map */
|
||||||
/* to follow the trajectories */
|
/* to follow the trajectories */
|
||||||
reload_npc( game );
|
reload_npc(game);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +270,7 @@ bool player_collision(Game *game, Direction direction,
|
||||||
if(player_tile_y < 0) player_tile_y = player_tile_y/T_HEIGHT-1;
|
if(player_tile_y < 0) player_tile_y = player_tile_y/T_HEIGHT-1;
|
||||||
else player_tile_y = player_tile_y/T_HEIGHT;
|
else player_tile_y = player_tile_y/T_HEIGHT;
|
||||||
|
|
||||||
int on_walkable = get_walkable(game, player_tile_x, player_tile_y);
|
int on_walkable = map_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;
|
walkable_speed[on_walkable] : 0;
|
||||||
|
|
57
src/player.h
|
@ -1,21 +1,8 @@
|
||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
|
|
||||||
/* The size of the player. */
|
|
||||||
#ifdef FXCG50
|
|
||||||
#define P_WIDTH 16
|
|
||||||
#define P_HEIGHT 16
|
|
||||||
#else
|
|
||||||
#define P_WIDTH 8
|
|
||||||
#define P_HEIGHT 8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* SPEED should NOT be 8 or bigger: it may cause bugs when handling
|
|
||||||
* collisions! */
|
|
||||||
#define SPEED PXSIZE*2
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "config.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
@ -25,27 +12,53 @@
|
||||||
/* only methods propotypes are now in dedicated header files */
|
/* only methods propotypes are now in dedicated header files */
|
||||||
|
|
||||||
|
|
||||||
/* Draws the player player. This function should be called after drawing the
|
/* player_draw()
|
||||||
* map! */
|
*
|
||||||
|
* Draws the player. This function should be called after drawing the
|
||||||
|
* map!
|
||||||
|
* game: The game struct which contains the player struct used.
|
||||||
|
*/
|
||||||
void player_draw(Game *game);
|
void player_draw(Game *game);
|
||||||
|
|
||||||
/* Move the player player in the direction direction. */
|
/* player_move()
|
||||||
|
*
|
||||||
|
* Move the player in a direction.
|
||||||
|
* game: The game struct.
|
||||||
|
* direction: The direction to move the player in.
|
||||||
|
*/
|
||||||
void player_move(Game *game, Direction direction);
|
void player_move(Game *game, Direction direction);
|
||||||
|
|
||||||
/* (Mibi88) TODO: Describe this function please, I've no idea what she's for! */
|
/* (Mibi88) TODO: Describe this function please, I've no idea what she's for! */
|
||||||
void player_action(Game *game);
|
void player_action(Game *game);
|
||||||
|
|
||||||
/* Check if the player is in collision with the map or a NPC. Checkpos is used
|
/* player_collision()
|
||||||
* to check the axis where the player is not moving. */
|
*
|
||||||
|
* Check if the player is in collision with the map or a NPC. Checkpos is used
|
||||||
|
* to check the axis where the player is not moving.
|
||||||
|
* game: The game struct.
|
||||||
|
* direction: The direction the player is moving in.
|
||||||
|
* nomov_axis_check: The axis that isn't changed by this movement.
|
||||||
|
*/
|
||||||
bool player_collision(Game *game, Direction direction,
|
bool player_collision(Game *game, Direction direction,
|
||||||
Checkpos nomov_axis_check);
|
Checkpos nomov_axis_check);
|
||||||
|
|
||||||
/* Fix the position of the player so that he's not a bit inside of a hard block
|
/* player_fix_position()
|
||||||
* after a collision. */
|
*
|
||||||
|
* Fix the position of the player so that he's not a bit inside of a hard block
|
||||||
|
* after a collision.
|
||||||
|
* game: The game struct.
|
||||||
|
* fix_x: If we should fix the position on the X axis.
|
||||||
|
* fix_y: If we should fix the position on the Y axis.
|
||||||
|
*/
|
||||||
void player_fix_position(Game *game, bool fix_x, bool fix_y);
|
void player_fix_position(Game *game, bool fix_x, bool fix_y);
|
||||||
|
|
||||||
|
|
||||||
/* Apply damage to player */
|
/* player_damage()
|
||||||
|
*
|
||||||
|
* Apply damage to player
|
||||||
|
* game: The game struct.
|
||||||
|
* amount: The amount of damage to apply.
|
||||||
|
*/
|
||||||
void player_damage(Game *game, int amount);
|
void player_damage(Game *game, int amount);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|