Draw capacities

This commit is contained in:
bgiraudr 2022-01-24 21:27:51 +01:00
parent 56b3b9dad4
commit a36803f8d6
10 changed files with 42 additions and 25 deletions

View File

@ -1,3 +1,3 @@
capacites.txt:
custom-type: capacites
name: capacites
custom-type: capacities
name: capacities

View File

@ -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:

View File

@ -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);
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);

View File

@ -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);
void add_move(struct Player *player, struct Move move);
void draw_player_moves(struct Player *player);

View File

@ -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));
}

View File

@ -1,20 +1,29 @@
#include "capacite.h"
#include <gint/display.h>
#include <gint/keyboard.h>
#include <string.h>
#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);
}

View File

@ -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);
}
}

View File

@ -57,4 +57,12 @@ void add_move(struct Player *player, struct Move move) {
} else {
//TODO remplacer une capacité
}
}
}
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]);
}
}

View File

@ -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);
}

View File

@ -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)) {