Everything is now working, except the animation after choosing.

This commit is contained in:
mibi88 2023-07-18 21:08:12 +02:00
parent acb859eaa8
commit ea66f50f44
3 changed files with 33 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 956 B

View file

@ -2,7 +2,6 @@
#include <gint/keyboard.h> #include <gint/keyboard.h>
#include <gint/cpu.h> #include <gint/cpu.h>
#include <gint/image.h>
#include <string.h> #include <string.h>
@ -65,6 +64,9 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
(BOX_HEIGHT-7)*PXSIZE, DIMAGE_NONE); (BOX_HEIGHT-7)*PXSIZE, DIMAGE_NONE);
dupdate(); dupdate();
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 /* We should start to drawing the text on the x axis at BOX_HEIGHT to avoid
* drawing on the face. */ * drawing on the face. */
@ -179,14 +181,17 @@ int _choices_amount, _default_choice;
* int y) are needed in the animations of the interaction dialog. */ * int y) are needed in the animations of the interaction dialog. */
#ifdef FXCG50 #ifdef FXCG50
#include <gint/image.h>
image_t vram_part_reference;
image_t vram_part; image_t vram_part;
#else #else
// Really need to code this! // Really need to code this!
#endif #endif
void store_vram_part(int x1, int y1, int x2, int y2) { void store_vram_part(int x, int y, int w, int h) {
#ifdef FXCG50 #ifdef FXCG50
image_sub(image_create_vram(), x1, y1, x2-x1, y2-y1, &vram_part); image_sub(image_create_vram(), x, y, w, h, &vram_part_reference);
image_copy(&vram_part_reference, &vram_part, true);
#else #else
// Really need to code this! // Really need to code this!
#endif #endif
@ -203,25 +208,23 @@ int _choice_call_before_end(Game *game) {
int i, key; int i, key;
/* Make a little animation because we looove little animations ;) */ /* Make a little animation because we looove little animations ;) */
store_vram_part(0, (BOX_HEIGHT+1)*PXSIZE, store_vram_part(0, (BOX_HEIGHT+1)*PXSIZE,
DWIDTH, (BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE); DWIDTH, (CHOICE_BOX_HEIGHT+1)*PXSIZE);
for(i=0;i<DWIDTH/8+1;i++){ for(i=0;i<DWIDTH/8+1;i++){
drect(0, BOX_HEIGHT*PXSIZE, i*(DWIDTH/8), drect(0, BOX_HEIGHT*PXSIZE, i*(DWIDTH/8),
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE); (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE, drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_BLACK); (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_BLACK);
drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, i*(DWIDTH/8), drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE+1, i*(DWIDTH/8),
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK); (BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
blit(); blit();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();
game->frame_duration = 0; game->frame_duration = 0;
} }
const int choice_size = DWIDTH/_choices_amount; const int choice_size = DWIDTH/_choices_amount;
int arrow_width, selected = _default_choice, pos = 0; int arrow_width, arrow_height, selected = _default_choice, pos = 0;
dsize(">", &FONT_USED, &arrow_width, NULL); dsize(">", &FONT_USED, &arrow_width, &arrow_height);
arrow_width += FONT_USED.char_spacing;
do{ do{
/* Clear the box. */
drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, DWIDTH,
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE-1, C_WHITE);
/* Display the diffrent choices. */ /* Display the diffrent choices. */
for(i=0;i<_choices_amount;i++){ for(i=0;i<_choices_amount;i++){
if(i == selected) dtext(i*choice_size+PXSIZE, if(i == selected) dtext(i*choice_size+PXSIZE,
@ -234,17 +237,33 @@ int _choice_call_before_end(Game *game) {
} }
blit(); blit();
key = getkey().key; key = getkey().key;
if(key == KEY_LEFT && selected > 0) selected--; if(key == KEY_LEFT && selected > 0){
else if(key == KEY_RIGHT && selected < _choices_amount) selected++; /* Remove the old arrow. */
drect(selected*choice_size+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
selected*choice_size+PXSIZE+arrow_width,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
C_WHITE);
selected--;
}
else if(key == KEY_RIGHT && selected < _choices_amount){
/* Remove the old arrow. */
drect(selected*choice_size+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
selected*choice_size+PXSIZE+arrow_width,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
C_WHITE);
selected++;
}
}while(key != KEY_EXE); }while(key != KEY_EXE);
/* Make a little animation because we looove little animations ;) */ /* Make a little animation because we looove little animations ;) */
for(i=DWIDTH/8+1;i>0;i--){ for(i=DWIDTH/8+1;i>0;i--){
restore_vram_part(0, BOX_HEIGHT*PXSIZE); restore_vram_part(0, (BOX_HEIGHT+1)*PXSIZE+40);
drect(0, BOX_HEIGHT*PXSIZE, i*(DWIDTH/8), drect(0, BOX_HEIGHT*PXSIZE, i*(DWIDTH/8),
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE); (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE, drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_BLACK); (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_BLACK);
drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, i*(DWIDTH/8), drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE+1, i*(DWIDTH/8),
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK); (BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
blit(); blit();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();