From a36803f8d639f9db8a68ee17458d6af4586ad900 Mon Sep 17 00:00:00 2001 From: bgiraudr Date: Mon, 24 Jan 2022 21:27:51 +0100 Subject: [PATCH] Draw capacities --- assets-cg/capacites/fxconv-metadata.txt | 4 ++-- assets-cg/converters.py | 2 +- include/capacite.h | 8 +++++--- include/player.h | 3 ++- src/battle.c | 5 ----- src/capacite.c | 27 ++++++++++++++++--------- src/engine.c | 4 ++++ src/player.c | 10 ++++++++- src/stats.c | 2 -- src/util.c | 2 +- 10 files changed, 42 insertions(+), 25 deletions(-) diff --git a/assets-cg/capacites/fxconv-metadata.txt b/assets-cg/capacites/fxconv-metadata.txt index f1fd406..98ea8f0 100644 --- a/assets-cg/capacites/fxconv-metadata.txt +++ b/assets-cg/capacites/fxconv-metadata.txt @@ -1,3 +1,3 @@ capacites.txt: - custom-type: capacites - name: capacites + custom-type: capacities + name: capacities diff --git a/assets-cg/converters.py b/assets-cg/converters.py index b50f90b..3465311 100644 --- a/assets-cg/converters.py +++ b/assets-cg/converters.py @@ -5,7 +5,7 @@ def convert(input, output, params, target): if params["custom-type"] == "map": convert_map(input, output, params, target) return 0 - elif params["custom-type"] == "capacites": + elif params["custom-type"] == "capacities": convert_capa(input, output, params, target) return 0 else: diff --git a/include/capacite.h b/include/capacite.h index 29083a3..9c6cda8 100644 --- a/include/capacite.h +++ b/include/capacite.h @@ -6,10 +6,12 @@ struct Move { int atk; }; -struct Capacites { - int nbCapacites; +struct Capacities { + int nbCapacities; struct Move *moves[]; }; struct Move default_move(); -struct Move get_move_id(int id); \ No newline at end of file +struct Move get_move_id(int id); +void draw_move(int x, int y, int x2, int y2, struct Move move); +void draw_classic_move(int x, int y, struct Move move); \ No newline at end of file diff --git a/include/player.h b/include/player.h index 8ccfb8c..1257727 100644 --- a/include/player.h +++ b/include/player.h @@ -32,4 +32,5 @@ struct Player { /*return the info tile value the player is facing to*/ int player_facing(struct Game const *game); struct Player init_player(void); -void add_move(struct Player *player, struct Move move); \ No newline at end of file +void add_move(struct Player *player, struct Move move); +void draw_player_moves(struct Player *player); \ No newline at end of file diff --git a/src/battle.c b/src/battle.c index ab2431b..f2dcf4f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -9,10 +9,5 @@ void create_battle(struct Player *player) { player->stats.level++; - drect(DWIDTH-110,0,DWIDTH,DHEIGHT,C_WHITE); - dprint(300,20,C_BLACK,"%s",player->moves[0].name); - dprint(300,40,C_BLACK,"%s",player->moves[1].name); - dupdate(); - wait_for_input(KEY_SHIFT); add_move(player, get_move_id(1)); } \ No newline at end of file diff --git a/src/capacite.c b/src/capacite.c index 3b5d9ac..8f9320d 100644 --- a/src/capacite.c +++ b/src/capacite.c @@ -1,20 +1,29 @@ -#include "capacite.h" - #include #include +#include -#include "engine.h" -#include "battle.h" -#include "util.h" #include "capacite.h" -#include "player.h" -extern struct Capacites capacites; +extern struct Capacities capacities; struct Move default_move() { - return *capacites.moves[0]; + return *capacities.moves[0]; } struct Move get_move_id(int id) { - return *capacites.moves[id]; + return *capacities.moves[id]; +} + +void draw_move(int x, int y, int x2, int y2, struct Move move) { + 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); + dprint((int)((x+x2)/2)-(int)(strlen(move.name)/2*font_size), + (int)((y+y2)/2)-font_size/2, + C_BLACK, "%s", move.name); +} + +void draw_classic_move(int x, int y, struct Move move) { + draw_move(x, y, x+200, y+60, move); } \ No newline at end of file diff --git a/src/engine.c b/src/engine.c index 2955bd3..2695db1 100644 --- a/src/engine.c +++ b/src/engine.c @@ -12,6 +12,7 @@ #include "vec2.h" #include "battle.h" #include "capacite.h" +#include "util.h" /*draw the current state of the game*/ void engine_draw(struct Game const *game) { @@ -129,6 +130,9 @@ void engine_action(struct Game const *game, int action) { } if(action == ACTION_OPTN) { draw_stats(game->player->stats); + draw_player_moves(game->player); + dupdate(); + wait_for_input(KEY_OPTN); } } diff --git a/src/player.c b/src/player.c index 8575050..be7fcc4 100644 --- a/src/player.c +++ b/src/player.c @@ -57,4 +57,12 @@ void add_move(struct Player *player, struct Move move) { } else { //TODO remplacer une capacité } -} \ No newline at end of file +} + +void draw_player_moves(struct Player *player) { + draw_classic_move(0,0,player->moves[0]); + if(player->moves[1].name != NULL) { + draw_classic_move(0,80,player->moves[1]); + } +} + diff --git a/src/stats.c b/src/stats.c index 58fe8b9..8a3ae9f 100644 --- a/src/stats.c +++ b/src/stats.c @@ -11,6 +11,4 @@ void draw_stats(struct Stats stats) { dprint(300,60,C_BLACK,"XP : %d",stats.xp); dprint(300,80,C_BLACK,"ATK : %d",stats.atk); dprint(300,100,C_BLACK,"DEF : %d",stats.def); - dupdate(); - wait_for_input(KEY_OPTN); } \ No newline at end of file diff --git a/src/util.c b/src/util.c index 5eb934e..1659c6d 100644 --- a/src/util.c +++ b/src/util.c @@ -5,7 +5,7 @@ /*wait for a specified input key*/ void wait_for_input(int input) { - int buffer = 1; + int buffer = keydown(input); while(1) { clearevents(); if(keydown(input)) {