Merge pull request 'Dialogs with Sly's fixes for the grey engine.' (#23) from mibi88/Collab_RPG-affichage-dialogues:master into master

Reviewed-on: https://gitea.planet-casio.com/Slyvtt/Collab_RPG/pulls/23
This commit is contained in:
mibi88 2023-07-13 23:52:10 +02:00
commit 44e966039c
6 changed files with 70 additions and 43 deletions

View file

@ -12,7 +12,7 @@ find_package(Gint 2.9 REQUIRED)
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
set(COLORMODE_fx 1b) set(COLORMODE_fx 2b)
#set the color mode either to 2b or EGA64 #set the color mode either to 2b or EGA64
set(COLORMODE_cg EGA64) set(COLORMODE_cg EGA64)

View file

@ -15,7 +15,7 @@ A ce stade, on a déjà implémenté :
- [x] Personnage - [x] Personnage
- [ ] Dialogues - [ ] Dialogues
- [ ] Fontes de caractères - [ ] Fontes de caractères
- [ ] Interraction - [ ] Interaction
- [ ] NPC - [ ] NPC
- [ ] Changement de map - [ ] Changement de map

View file

@ -34,12 +34,11 @@ void blit()
} }
void showtext(Game *game, bopti_image_t *face, char *text) { int showtext_opt(Game *game, bopti_image_t *face, char *text,
int call_before_end(void), bool start_anim, bool end_anim) {
dfont(&FONT_USED); dfont(&FONT_USED);
unsigned int i, n, y = PXSIZE, l = 0; unsigned int i, n, y = PXSIZE, l = 0;
int line_max_chars; int line_max_chars, return_int = 0;
unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/ unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
(FONT_USED.line_height+PXSIZE); (FONT_USED.line_height+PXSIZE);
const char *c; const char *c;
@ -52,7 +51,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
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,
DIMAGE_NONE); DIMAGE_NONE);
blit(); dupdate();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();
game->frame_duration = 0; game->frame_duration = 0;
@ -87,7 +86,6 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
*/ */
/* Make a little animation :). */ /* Make a little animation :). */
blit(); blit();
while(game->frame_duration < 1000) sleep(); while(game->frame_duration < 1000) sleep();
game->frame_duration = 0; game->frame_duration = 0;
/* Ask the user to press EXE to continue. */ /* Ask the user to press EXE to continue. */
@ -95,7 +93,6 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
} }
/* Make a little animation :). */ /* Make a little animation :). */
blit(); blit();
if(l>=max_lines_amount-1){ if(l>=max_lines_amount-1){
while(getkey().key != KEY_EXE) sleep(); while(getkey().key != KEY_EXE) sleep();
/* Clear the screen. */ /* Clear the screen. */
@ -114,13 +111,14 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
/* If we have not filled everthing with text at the end. */ /* If we have not filled everthing with text at the end. */
/* Make a little animation :). */ /* Make a little animation :). */
blit(); blit();
while(game->frame_duration < 1000) sleep(); while(game->frame_duration < 1000) sleep();
game->frame_duration = 0; game->frame_duration = 0;
/* Ask the user to press EXE to continue. */ /* Ask the user to press EXE to continue. */
dtext(1, y, C_BLACK, "[EXE] To continue ..."); dtext(1, y, C_BLACK, "[EXE] To continue ...");
blit();
while(getkey().key != KEY_EXE) sleep(); while(getkey().key != KEY_EXE) sleep();
} }
if(call_before_end) return_int = call_before_end();
/* Run another little fancy animation. */ /* Run another little fancy animation. */
for(i=40;i>0;i--){ for(i=40;i>0;i--){
draw(game); draw(game);
@ -129,9 +127,32 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
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,
DIMAGE_NONE); DIMAGE_NONE);
blit(); dupdate();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();
game->frame_duration = 0; game->frame_duration = 0;
} }
return return_int;
}
void showtext(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, true, true);
}
void showtext_dialog_start(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, true, false);
}
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, false, false);
}
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, false, true);
}
char **choices;
void _choice_call_before_end(void) {
//
} }

View file

@ -9,6 +9,15 @@
#define F_WIDTH (32*PXSIZE) #define F_WIDTH (32*PXSIZE)
#define F_HEIGHT (32*PXSIZE) #define F_HEIGHT (32*PXSIZE)
int showtext_opt(Game *game, bopti_image_t *face, char *text,
int call_before_end(void), bool start_anim, bool end_anim);
void showtext(Game *game, bopti_image_t *face, char *text); void showtext(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_start(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text);
#endif #endif

View file

@ -26,6 +26,8 @@ void render_map(Player *player, Map *map_level) {
unsigned short int xtile, ytile; unsigned short int xtile, ytile;
/* The layer we're drawing */ /* The layer we're drawing */
unsigned char l; unsigned char l;
/* The index of the current tile we're drawing in the layer. */
int current_index;
/* Fix sx. */ /* Fix sx. */
if(player->x<DWIDTH/2){ if(player->x<DWIDTH/2){
/* If I can't center the player because I'm near the left border of /* If I can't center the player because I'm near the left border of
@ -62,7 +64,6 @@ void render_map(Player *player, Map *map_level) {
ty = sy/T_HEIGHT; ty = sy/T_HEIGHT;
mx = sx-tx*T_WIDTH; mx = sx-tx*T_WIDTH;
my = sy-ty*T_HEIGHT; my = sy-ty*T_HEIGHT;
for (l = 0; l < map_level->nblayers-1; l++){ for (l = 0; l < map_level->nblayers-1; l++){
/* Draw a layer of the map on screen. */ /* Draw a layer of the map on screen. */
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
@ -72,10 +73,10 @@ void render_map(Player *player, Map *map_level) {
if(tx+x>=0 && tx+x < map_level->w && if(tx+x>=0 && tx+x < map_level->w &&
ty+y>=0 && ty+y < map_level->h){ ty+y>=0 && ty+y < map_level->h){
/* index of the current tile */ /* index of the current tile */
int currentIndex = (y+ty) * map_level->w + tx+x; current_index = (y+ty) * map_level->w + tx+x;
/* we get the ID of the tile in the current drawable layers /* we get the ID of the tile in the current drawable layers
*/ */
tile = map_level->layers[l][currentIndex]; tile = map_level->layers[l][current_index];
/* tile == -1 means nothing to be drawn */ /* tile == -1 means nothing to be drawn */
if(tile >= 0){ if(tile >= 0){
@ -115,8 +116,6 @@ void render_map_by_layer(Player *player, Map *map_level, int layer) {
unsigned short int sx, sy; unsigned short int sx, sy;
/* The position of the tile in the tileset. */ /* The position of the tile in the tileset. */
unsigned short int xtile, ytile; unsigned short int xtile, ytile;
/* The layer we're drawing */
unsigned char l;
/* Fix sx. */ /* Fix sx. */
if(player->x<DWIDTH/2){ if(player->x<DWIDTH/2){
/* If I can't center the player because I'm near the left border of /* If I can't center the player because I'm near the left border of
@ -153,8 +152,6 @@ void render_map_by_layer(Player *player, Map *map_level, int layer) {
ty = sy/T_HEIGHT; ty = sy/T_HEIGHT;
mx = sx-tx*T_WIDTH; mx = sx-tx*T_WIDTH;
my = sy-ty*T_HEIGHT; my = sy-ty*T_HEIGHT;
/* Draw a layer of the map on screen. */ /* Draw a layer of the map on screen. */
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){

View file

@ -28,7 +28,8 @@
/* Draws the map map on the entire screen to be viewed by the player player. */ /* Draws the map map on the entire screen to be viewed by the player player. */
void render_map(Player *player, Map *map_level); void render_map(Player *player, Map *map_level);
/* Draws the map layer 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.
*/
void render_map_by_layer(Player *player, Map *map_level, int layer); void render_map_by_layer(Player *player, Map *map_level, int layer);
/* Get the tile at (x, y) of the map map. If the tile is located outside of the /* Get the tile at (x, y) of the map map. If the tile is located outside of the
@ -39,4 +40,3 @@ short int get_tile(Map *map_level, int x, int y, int l);
short int get_walkable(Map *map_level, int x, int y); short int get_walkable(Map *map_level, int x, int y);
#endif #endif