UI battle
|
@ -48,6 +48,9 @@ set(SOURCES
|
|||
|
||||
set(ASSETS_cg
|
||||
assets-cg/tileset.png
|
||||
assets-cg/dialogue.png
|
||||
assets-cg/capacite.png
|
||||
assets-cg/battle_ui.png
|
||||
assets-cg/maps/inside/tileset_in.png
|
||||
assets-cg/maps/testCarte.json
|
||||
assets-cg/maps/1.json
|
||||
|
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 542 B |
|
@ -11,7 +11,21 @@ uf8x9:
|
|||
type: font
|
||||
name: uf8x9
|
||||
charset: unicode
|
||||
grid.size: 8x11
|
||||
grid.padding: 1
|
||||
grid.size: 14x44
|
||||
proportional: true
|
||||
height: 9
|
||||
height: 16
|
||||
|
||||
dialogue.png:
|
||||
type: bopti-image
|
||||
name: img_dialogue
|
||||
profile: p4
|
||||
|
||||
capacite.png:
|
||||
type: bopti-image
|
||||
name: img_capacite
|
||||
profile: p4
|
||||
|
||||
battle_ui.png:
|
||||
type: bopti-image
|
||||
name: img_battle
|
||||
profile: p4
|
||||
|
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 1000 B |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 1.4 KiB |
43
src/battle.c
|
@ -19,9 +19,10 @@ void create_battle(struct Game *game) {
|
|||
//gain d'xp
|
||||
int xp = ceil((monster->stats->xp*monster->stats->level*1.5)/7);
|
||||
|
||||
const int rect_size = 100;
|
||||
drect(0,DHEIGHT,DWIDTH,DHEIGHT-rect_size,C_WHITE);
|
||||
dprint(10,DHEIGHT-rect_size/2-8, C_BLACK, "Vous remportez %d points d'experience", xp);
|
||||
extern bopti_image_t img_dialogue;
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
|
||||
dprint(50,DHEIGHT-75/2-10, C_BLACK, "Vous remportez %d points d'experience", xp);
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
|
||||
|
@ -32,8 +33,8 @@ void create_battle(struct Game *game) {
|
|||
for(int i = game->player->stats.level; i < calc_level; i++) {
|
||||
dclear(C_RGB(25,25,25));
|
||||
draw_battle(game->player, monster);
|
||||
drect(0,DHEIGHT,DWIDTH,DHEIGHT-rect_size,C_WHITE);
|
||||
dprint(10,DHEIGHT-rect_size/2-8,C_BLACK,"Vous passez au niveau %d !", i+1);
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
dprint(50,DHEIGHT-75/2-10,C_BLACK,"Vous passez au niveau %d !", i+1);
|
||||
dupdate();
|
||||
wait_for_input(KEY_SHIFT);
|
||||
}
|
||||
|
@ -120,32 +121,36 @@ int select_move(struct Player *player, struct Monster *monster, int prec_selecte
|
|||
}
|
||||
|
||||
void draw_battle(struct Player *player, struct Monster *monster) {
|
||||
const int WIDTH_HP = 100;
|
||||
extern bopti_image_t img_battle;
|
||||
const int WIDTH_HP = 74;
|
||||
|
||||
if(player->stats.pv < 0) player->stats.pv = 0;
|
||||
if(monster->stats->pv < 0) monster->stats->pv = 0;
|
||||
|
||||
dimage(0,0,&img_battle);
|
||||
int posHP = (float)player->stats.pv / player->stats.max_pv * WIDTH_HP;
|
||||
drect(10,15,10+WIDTH_HP,25,C_BLACK);
|
||||
drect(10,15,10+posHP,25,C_GREEN);
|
||||
drect(290,138,290+WIDTH_HP,142,C_WHITE);
|
||||
drect(290,138,290+posHP,142,C_GREEN);
|
||||
|
||||
dprint(15+WIDTH_HP,15,C_BLACK,"%d/%d", player->stats.pv, player->stats.max_pv);
|
||||
dprint(333,124,C_BLACK,"%d",player->stats.level);
|
||||
dprint(246,124,C_BLACK,"%d/%d", player->stats.pv, player->stats.max_pv);
|
||||
|
||||
int posHPmonster = (float)monster->stats->pv / monster->stats->max_pv * WIDTH_HP;
|
||||
dprint(240,2,C_BLACK,"%s",monster->name);
|
||||
drect(240,15,240+WIDTH_HP,25,C_BLACK);
|
||||
drect(240,15,240+posHPmonster,25,C_GREEN);
|
||||
dprint(245+WIDTH_HP,2,C_BLACK,"%d",monster->stats->level);
|
||||
dprint(245+WIDTH_HP,15,C_BLACK,"%d/%d", monster->stats->pv, monster->stats->max_pv);
|
||||
dimage(260,30,monster->sprite);
|
||||
dprint(2,8,C_BLACK,"%s",monster->name);
|
||||
drect(48,23,48+WIDTH_HP,27,C_WHITE);
|
||||
drect(48,23,48+posHPmonster,27,C_GREEN);
|
||||
dprint(90,9,C_BLACK,"%d",monster->stats->level);
|
||||
dprint(127,11,C_BLACK,"%d/%d", monster->stats->pv, monster->stats->max_pv);
|
||||
|
||||
dimage(265,10,monster->sprite);
|
||||
}
|
||||
|
||||
void draw_executed_move(struct Move move, struct Monster *monster, int is_monster) {
|
||||
const int rect_size = 100;
|
||||
drect(0,DHEIGHT,DWIDTH,DHEIGHT-rect_size,C_WHITE);
|
||||
extern bopti_image_t img_dialogue;
|
||||
dimage(42,DHEIGHT-75,&img_dialogue);
|
||||
if(is_monster) {
|
||||
dprint(10,DHEIGHT-rect_size/2-8, C_BLACK, "%s lance %s !", monster->name, move.name);
|
||||
dprint(50,DHEIGHT-75/2-10, C_BLACK, "%s lance %s !", monster->name, move.name);
|
||||
} else {
|
||||
dprint(10,DHEIGHT-rect_size/2-8, C_BLACK, "Vous lancez %s !", move.name);
|
||||
dprint(50,DHEIGHT-75/2-10, C_BLACK, "Vous lancez %s !", move.name);
|
||||
}
|
||||
}
|
|
@ -16,10 +16,11 @@ struct Move get_move_id(int id) {
|
|||
}
|
||||
|
||||
void draw_move(int x, int y, int x2, int y2, struct Move move) {
|
||||
extern bopti_image_t img_capacite;
|
||||
const int font_size = 8;
|
||||
drect(x, y, x2, y2, C_WHITE);
|
||||
dprint(x+5, y+5, C_BLACK, "PP : %d", move.pp);
|
||||
dprint(x+5, y2-15, C_BLACK, "ATK : %d", move.atk);
|
||||
dimage(x, y, &img_capacite);
|
||||
dprint(x+15, y+5, C_BLACK, "PP : %d", move.pp);
|
||||
dprint(x+15, y2-20, C_BLACK, "ATK : %d", move.atk);
|
||||
dprint((int)((x+x2)/2)-(int)(strlen(move.name)/2*font_size),
|
||||
(int)((y+y2)/2)-font_size/2,
|
||||
C_BLACK, "%s", move.name);
|
||||
|
|
|
@ -119,6 +119,6 @@ void draw_ui(struct Player *player) {
|
|||
int index = get_nb_moves(player);
|
||||
|
||||
for(int i = 0; i < index; i++) {
|
||||
draw_classic_move(2+132*i,DHEIGHT-80, player->moves[i]);
|
||||
draw_classic_move(2+132*i,DHEIGHT-70, player->moves[i]);
|
||||
}
|
||||
}
|
|
@ -16,14 +16,15 @@ struct Talkable default_value = {
|
|||
|
||||
/*draw the dialog of a specified talkable tile*/
|
||||
void draw_dialog(struct Talkable *talkable) {
|
||||
extern bopti_image_t img_dialogue;
|
||||
const char *delim = ";";
|
||||
|
||||
char *str = strdup(talkable->text);
|
||||
char *curr_line = strtok(str, delim);
|
||||
|
||||
while(curr_line != NULL) {
|
||||
drect(20,10,370,80,C_WHITE);
|
||||
dprint(25,20, C_BLACK, "%s", talkable->name);
|
||||
dimage(43,31,&img_dialogue);
|
||||
dprint(50,40, C_BLACK, "%s", talkable->name);
|
||||
|
||||
//TODO Il y a moyen de faire mieux avec seulement curr_line.
|
||||
//Cela semble globalement fonctionner, mais j'ai pu observer des petites erreurs
|
||||
|
@ -44,12 +45,12 @@ void draw_dialog(struct Talkable *talkable) {
|
|||
strncpy(split,&remain[0],indexSpace);
|
||||
strncpy(remain,&remain[indexSpace]+1,strlen(remain));
|
||||
|
||||
dprint(25,40+indexLine*15, C_BLACK, "%s", split);
|
||||
dprint(50,60+indexLine*15, C_BLACK, "%s", split);
|
||||
indexLine++;
|
||||
}
|
||||
dprint(25,40+indexLine*15, C_BLACK, "%s", remain);
|
||||
dprint(50,60+indexLine*15, C_BLACK, "%s", remain);
|
||||
} else {
|
||||
dprint(25,40, C_BLACK, "%s", curr_line);
|
||||
dprint(50,60, C_BLACK, "%s", curr_line);
|
||||
}
|
||||
|
||||
dupdate();
|
||||
|
|