mirror of https://github.com/bgiraudr/Adoranda.git
Beginning of capacities
This commit is contained in:
parent
bb32aef7ad
commit
56b3b9dad4
|
@ -42,6 +42,7 @@ set(SOURCES
|
|||
src/animation.c
|
||||
src/battle.c
|
||||
src/stats.c
|
||||
src/capacite.c
|
||||
)
|
||||
|
||||
set(ASSETS_cg
|
||||
|
@ -53,6 +54,7 @@ set(ASSETS_cg
|
|||
assets-cg/maps/inside/2.json
|
||||
assets-cg/spritesheet.png
|
||||
assets-cg/uf8x9
|
||||
assets-cg/capacites/capacites.txt
|
||||
)
|
||||
|
||||
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Test capacité;5;2
|
||||
Deuxième;10;3
|
|
@ -0,0 +1,3 @@
|
|||
capacites.txt:
|
||||
custom-type: capacites
|
||||
name: capacites
|
|
@ -5,6 +5,9 @@ def convert(input, output, params, target):
|
|||
if params["custom-type"] == "map":
|
||||
convert_map(input, output, params, target)
|
||||
return 0
|
||||
elif params["custom-type"] == "capacites":
|
||||
convert_capa(input, output, params, target)
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
@ -160,4 +163,25 @@ def parseTeleporter(layer):
|
|||
teleporter += fxconv.u32(j["value"])
|
||||
except KeyError :
|
||||
raise Exception("parseTeleporter() : Un téléporteur est mal configuré")
|
||||
return teleporter
|
||||
return teleporter
|
||||
|
||||
def convert_capa(input, output, params, target):
|
||||
with open(input, "r") as file:
|
||||
capacities = fxconv.Structure()
|
||||
|
||||
lines = file.read().splitlines()
|
||||
matrix = [i.split(";") for i in lines]
|
||||
|
||||
capacities += fxconv.u32(len(lines))
|
||||
|
||||
for i in matrix:
|
||||
moves = fxconv.Structure()
|
||||
for j in range(len(i)):
|
||||
if j == 0:
|
||||
moves += fxconv.string(i[j])
|
||||
else:
|
||||
moves += fxconv.u32(int(i[j]))
|
||||
|
||||
capacities += fxconv.ptr(moves)
|
||||
|
||||
fxconv.elf(capacities, output, "_" + params["name"], **target)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
struct Move {
|
||||
char *name;
|
||||
int pp;
|
||||
int atk;
|
||||
};
|
||||
|
||||
struct Capacites {
|
||||
int nbCapacites;
|
||||
struct Move *moves[];
|
||||
};
|
||||
|
||||
struct Move default_move();
|
||||
struct Move get_move_id(int id);
|
|
@ -3,6 +3,8 @@
|
|||
#include "engine.h"
|
||||
#include "vec2.h"
|
||||
#include "stats.h"
|
||||
#include "capacite.h"
|
||||
|
||||
|
||||
struct Player {
|
||||
/*current position of the player on the map - Tile*/
|
||||
|
@ -11,6 +13,7 @@ struct Player {
|
|||
struct Vec2f pos_visual;
|
||||
|
||||
struct Stats stats;
|
||||
struct Move moves[2];
|
||||
/*player mid - offset pixels*/
|
||||
int x_mid, y_mid;
|
||||
/*the direction the player facing to*/
|
||||
|
@ -29,3 +32,4 @@ 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);
|
|
@ -4,7 +4,15 @@
|
|||
#include "engine.h"
|
||||
#include "battle.h"
|
||||
#include "util.h"
|
||||
#include "capacite.h"
|
||||
#include "player.h"
|
||||
|
||||
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));
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include "capacite.h"
|
||||
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
#include "engine.h"
|
||||
#include "battle.h"
|
||||
#include "util.h"
|
||||
#include "capacite.h"
|
||||
#include "player.h"
|
||||
|
||||
extern struct Capacites capacites;
|
||||
|
||||
struct Move default_move() {
|
||||
return *capacites.moves[0];
|
||||
}
|
||||
|
||||
struct Move get_move_id(int id) {
|
||||
return *capacites.moves[id];
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
#include "camera.h"
|
||||
#include "vec2.h"
|
||||
#include "battle.h"
|
||||
#include "capacite.h"
|
||||
|
||||
/*draw the current state of the game*/
|
||||
void engine_draw(struct Game const *game) {
|
||||
|
|
10
src/player.c
10
src/player.c
|
@ -2,6 +2,7 @@
|
|||
#include "define.h"
|
||||
#include "map.h"
|
||||
#include "stats.h"
|
||||
#include "capacite.h"
|
||||
|
||||
struct Player init_player(void) {
|
||||
|
||||
|
@ -26,6 +27,7 @@ struct Player init_player(void) {
|
|||
.anim.dir = DIR_DOWN
|
||||
};
|
||||
player.idle = !anim_player_idle(&player.anim, 1);
|
||||
player.moves[0] = default_move();
|
||||
|
||||
return player;
|
||||
}
|
||||
|
@ -47,4 +49,12 @@ int player_facing(struct Game const *game) {
|
|||
return game->map->info_map[index];
|
||||
}
|
||||
return TILE_SOLID;
|
||||
}
|
||||
|
||||
void add_move(struct Player *player, struct Move move) {
|
||||
if(player->moves[1].name == NULL) {
|
||||
player->moves[1] = move;
|
||||
} else {
|
||||
//TODO remplacer une capacité
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue