Started adding comments. Still have this weird bug on the mono calculator

This commit is contained in:
mibi88 2023-07-19 23:11:00 +02:00
parent c82a9fc5da
commit d1e32de9c5
2 changed files with 24 additions and 9 deletions

View file

@ -39,7 +39,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
bool start_anim,
bool end_anim,
void for_each_screen(Game *game, unsigned int i),
int line_duration, bool line_anim, unsigned int start_i,
int line_duration, bool update_screen, unsigned int start_i,
bool wait_continue) {
dfont(&FONT_USED);
unsigned int i, n, y = PXSIZE, l = 0;
@ -50,10 +50,17 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
if(start_anim){
/* Run a little fancy animation. */
for(i=0;i<=BOX_HEIGHT;i++){
/* Redrawing the entire screen, because maybe there was no dialog
displayed before. */
draw(game);
/* Fill the dialog box with white */
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
/* Draw a thick black line on the bottom of the dialog. */
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
/* Draw the part of the face of the player that can fit correctly in
* the dialog drawn. */
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
DIMAGE_NONE);
@ -63,15 +70,19 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
game->frame_duration = 0;
}
}else{
/* Here I'm drawing the same as if start_anim is true, but whitout
* making an animation. */
draw(game);
drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
drect(0, BOX_HEIGHT*PXSIZE, DWIDTH, (BOX_HEIGHT+1)*PXSIZE, C_BLACK);
dimage(4*PXSIZE, 2*PXSIZE, face);
if(line_anim) blit();
if(update_screen){
blit();
while(game->frame_duration < 20) sleep();
game->frame_duration = 0;
while(game->frame_duration < 20) sleep();
game->frame_duration = 0;
}
}
/* We should start to drawing the text on the x axis at BOX_HEIGHT to avoid
* drawing on the face. */
@ -111,15 +122,17 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
/* We drew one entire screen, reset everything to draw the next one.
*/
/* Make a little animation :). */
if(line_anim) blit();
if(update_screen) blit();
while(game->frame_duration < line_duration) sleep();
game->frame_duration = 0;
/* Ask the user to press EXE to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
}
/* Make a little animation :). */
if(line_anim) blit();
if(update_screen) blit();
if(l>=max_lines_amount-1){
/* If we drew one entire screen. */
/* Wait that the EXE key is pressed if we should. */
if(wait_continue) while(getkey().key != KEY_EXE) sleep();
/* Clear the text area. */
drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2,
@ -129,6 +142,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
l = 0;
}
else{
/* Else, wait a bit for the animation. */
while(game->frame_duration < line_duration) sleep();
game->frame_duration = 0;
}
@ -136,12 +150,13 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
if(l<max_lines_amount-1){
/* If we have not filled everthing with text at the end. */
/* Make a little animation :). */
if(line_anim) blit();
if(update_screen) blit();
while(game->frame_duration < line_duration) sleep();
game->frame_duration = 0;
/* Ask the user to press EXE to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
if(line_anim) blit();
/* Update the screen and wait for EXE being pressed, if needed. */
if(update_screen) blit();
if(wait_continue) while(getkey().key != KEY_EXE) sleep();
}
if(call_before_end) return_int = call_before_end(game, i);

View file

@ -14,7 +14,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
bool start_anim,
bool end_anim,
void for_each_screen(Game *game, unsigned int i),
int line_duration, bool line_anim, unsigned int start_i,
int line_duration, bool update_screen, unsigned int start_i,
bool wait_continue);
void showtext_dialog(Game *game, bopti_image_t *face, char *text,