summaryrefslogtreecommitdiff
path: root/blits.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-08 19:45:03 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-08 19:45:03 +0100
commitbfdf279cac51fe8945e59cd566cba2cb2efcffce (patch)
treec2310a297cb9d48814009142ea92cc31bd787fee /blits.c
parentfc3baf853b4429cf012f6d77b43d74872dc5ca11 (diff)
move some functions and headers so that the compilation is quicker
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'blits.c')
-rw-r--r--blits.c181
1 files changed, 65 insertions, 116 deletions
diff --git a/blits.c b/blits.c
index 113fd53..c9bf855 100644
--- a/blits.c
+++ b/blits.c
@@ -1,13 +1,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
-#include "structures.h"
-#include "constantes.h"
-#include "prototypes.h"
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_image.h>
#include <string.h>
+#include "constantes.h"
+
+#include "players.h"
+#include "entry.h"
+
static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr)
{
TTF_Font *police=NULL;
@@ -64,6 +66,65 @@ void blit_team(SURFACES *surfaces, struct team_t *team)
}
}
+static void blit_character_affinities(SURFACES *surfaces, POSITIONS *positions, const struct character_t *chr)
+{
+ static const enum affinity_t affinities[] = {
+ AFFINITY_SENSITIVE,
+ AFFINITY_RESISTANCE,
+ AFFINITY_INVULNERABILITY,
+ AFFINITY_ABSORPTION,
+ };
+
+ for (int i = 0; i < countof(affinities); ++i) {
+ for (enum element_t elmt = 0; elmt < ELEMENT_COUNT; ++elmt) {
+ if (chr->affinities[elmt] == affinities[i]) {
+ SDL_BlitSurface (surfaces->Pactive,NULL,surfaces->Pecran,&positions->Vpositionactivedesactive[i * ELEMENT_COUNT + elmt]);
+ } else {
+ SDL_BlitSurface (surfaces->Pdesactive,NULL,surfaces->Pecran,&positions->Vpositionactivedesactive[i * ELEMENT_COUNT + elmt]);
+ }
+ }
+ }
+}
+
+static
+void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
+{
+ TTF_Font *police = NULL;
+ SDL_Color couleur = {132,215,107,0};
+ char chaine[50];
+
+ if (surfaces->Ppvcible != NULL)
+ {
+ SDL_FreeSurface (surfaces->Ppvcible);
+ surfaces->Ppvcible=NULL;
+ }
+
+ sprintf (chaine,"%d/%d", chr->hp, chr->max_hp);
+ police=TTF_OpenFont ("TIMESBI.TTF",18);
+ surfaces->Ppvcible=TTF_RenderText_Blended (police,chaine,couleur);
+ SDL_BlitSurface (surfaces->Ppvcible,NULL,surfaces->Pecran,&positions->Vpositionpvcible);
+ TTF_CloseFont (police);
+}
+
+static
+void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
+{
+ TTF_Font *police = NULL;
+ SDL_Color couleur = {132,215,107,0};
+ char chaine[50];
+
+ if (surfaces->Ppmcible != NULL)
+ {
+ SDL_FreeSurface (surfaces->Ppmcible);
+ surfaces->Ppmcible=NULL;
+ }
+ sprintf (chaine,"%d/%d", chr->mp, chr->max_mp);
+ police=TTF_OpenFont ("TIMESBI.TTF",18);
+ surfaces->Ppmcible=TTF_RenderText_Blended (police,chaine,couleur);
+ SDL_BlitSurface (surfaces->Ppmcible,NULL,surfaces->Pecran,&positions->Vpositionpmcible);
+ TTF_CloseFont (police);
+}
+
static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struct character_t *chr)
{
SDL_Color color = {0x8a, 0x00, 0x00, 0x00};
@@ -155,7 +216,7 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
SDL_Flip(surfaces->Pecran);
}
-static void display_incr(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, unsigned int incr, SDL_Color color)
+void display_incr(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, unsigned int incr, SDL_Color color)
{
TTF_Font *font = TTF_OpenFont("TIMES.TTF", 30);
char string[256];
@@ -177,115 +238,3 @@ static void display_incr(SURFACES *surfaces, POSITIONS *positions, struct charac
SDL_FreeSurface(surf);
TTF_CloseFont(font);
}
-
-static void incr_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int incr)
-{
- SDL_Color color;
-
- target->hp += incr;
-
- if (target->hp <= 0) {
- target->hp = 0;
- target->alive = false;
- } else if (target->hp > target->max_hp) {
- target->hp = target->max_hp;
- }
-
- color = (incr < 0) ? (SDL_Color){0xe0, 0x00, 0x00, 0x00} : (SDL_Color){0x00, 0xe0, 0x00, 0x00};
-
- display_incr(surfaces, positions, target, (incr >= 0) ? incr : -incr, color);
-}
-
-static void incr_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int incr)
-{
- SDL_Color color;
-
- target->hp += incr;
-
- if (target->mp <= 0) {
- target->mp = 0;
- } else if (target->mp > target->max_mp) {
- target->mp = target->max_mp;
- }
-
- color = (incr < 0) ? (SDL_Color){0xe0, 0x00, 0x00, 0x00} : (SDL_Color){0x00, 0xe0, 0x00, 0x00};
-
- display_incr(surfaces, positions, target, (incr >= 0) ? incr : -incr, color);
-}
-
-void damage_target_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int damages)
-{
- incr_hp(surfaces, positions, target, -damages);
-}
-
-void cure_target_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int cure)
-{
- incr_hp(surfaces, positions, target, cure);
-}
-
-void damage_target_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int damages)
-{
- incr_mp(surfaces, positions, target, -damages);
-}
-
-void cure_target_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int cure)
-{
- incr_mp(surfaces, positions, target, cure);
-}
-
-void blit_character_affinities(SURFACES *surfaces, POSITIONS *positions, const struct character_t *chr)
-{
- static const enum affinity_t affinities[] = {
- AFFINITY_SENSITIVE,
- AFFINITY_RESISTANCE,
- AFFINITY_INVULNERABILITY,
- AFFINITY_ABSORPTION,
- };
-
- for (int i = 0; i < countof(affinities); ++i) {
- for (enum element_t elmt = 0; elmt < ELEMENT_COUNT; ++elmt) {
- if (chr->affinities[elmt] == affinities[i]) {
- SDL_BlitSurface (surfaces->Pactive,NULL,surfaces->Pecran,&positions->Vpositionactivedesactive[i * ELEMENT_COUNT + elmt]);
- } else {
- SDL_BlitSurface (surfaces->Pdesactive,NULL,surfaces->Pecran,&positions->Vpositionactivedesactive[i * ELEMENT_COUNT + elmt]);
- }
- }
- }
-}
-
-void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
-{
- TTF_Font *police = NULL;
- SDL_Color couleur = {132,215,107,0};
- char chaine[50];
-
- if (surfaces->Ppvcible != NULL)
- {
- SDL_FreeSurface (surfaces->Ppvcible);
- surfaces->Ppvcible=NULL;
- }
-
- sprintf (chaine,"%d/%d", chr->hp, chr->max_hp);
- police=TTF_OpenFont ("TIMESBI.TTF",18);
- surfaces->Ppvcible=TTF_RenderText_Blended (police,chaine,couleur);
- SDL_BlitSurface (surfaces->Ppvcible,NULL,surfaces->Pecran,&positions->Vpositionpvcible);
- TTF_CloseFont (police);
-}
-
-void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
-{
- TTF_Font *police = NULL;
- SDL_Color couleur = {132,215,107,0};
- char chaine[50];
-
- if (surfaces->Ppmcible != NULL)
- {
- SDL_FreeSurface (surfaces->Ppmcible);
- surfaces->Ppmcible=NULL;
- }
- sprintf (chaine,"%d/%d", chr->mp, chr->max_mp);
- police=TTF_OpenFont ("TIMESBI.TTF",18);
- surfaces->Ppmcible=TTF_RenderText_Blended (police,chaine,couleur);
- SDL_BlitSurface (surfaces->Ppmcible,NULL,surfaces->Pecran,&positions->Vpositionpmcible);
- TTF_CloseFont (police);
-}