2018-02-16 18:11:26 +01:00
|
|
|
/*
|
|
|
|
* BreakHack - A dungeone crawler RPG
|
|
|
|
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-08-08 00:14:24 +02:00
|
|
|
#pragma once
|
2017-11-30 21:00:47 +01:00
|
|
|
|
2018-02-21 00:29:21 +01:00
|
|
|
#include <SDL.h>
|
2017-11-30 21:00:47 +01:00
|
|
|
#include "sprite.h"
|
2017-12-12 11:20:08 +01:00
|
|
|
#include "stats.h"
|
2017-12-18 15:26:56 +01:00
|
|
|
#include "actiontext.h"
|
|
|
|
#include "camera.h"
|
2018-02-28 22:31:38 +01:00
|
|
|
#include "skill.h"
|
2018-03-08 00:58:26 +01:00
|
|
|
#include "linkedlist.h"
|
2018-05-20 00:02:39 +02:00
|
|
|
#include "input.h"
|
2018-08-08 00:14:24 +02:00
|
|
|
#include "artifact.h"
|
2018-02-28 22:31:38 +01:00
|
|
|
|
|
|
|
#define PLAYER_SKILL_COUNT 5
|
2017-11-30 21:00:47 +01:00
|
|
|
|
2018-03-13 16:51:08 +01:00
|
|
|
// Foward declare
|
2018-07-09 19:26:06 +02:00
|
|
|
typedef struct UpdateData UpdateData;
|
|
|
|
typedef struct Animation Animation;
|
2018-03-13 16:51:08 +01:00
|
|
|
|
2018-03-25 23:30:26 +02:00
|
|
|
typedef enum PlayerClass { ENGINEER, MAGE, PALADIN, ROGUE, WARRIOR } class_t;
|
2018-09-10 22:27:26 +02:00
|
|
|
typedef enum PlayerState { ALIVE, DEAD } state_t;
|
2018-03-25 23:30:26 +02:00
|
|
|
|
2018-08-08 00:14:24 +02:00
|
|
|
typedef struct PlayerStatData {
|
2018-03-25 23:30:26 +02:00
|
|
|
unsigned int total_steps;
|
|
|
|
unsigned int steps;
|
|
|
|
unsigned int hits;
|
|
|
|
unsigned int kills;
|
|
|
|
unsigned int misses;
|
|
|
|
} PlayerStatData;
|
2017-11-30 21:00:47 +01:00
|
|
|
|
2018-08-08 00:14:24 +02:00
|
|
|
typedef struct ExperienceDatat {
|
2018-01-31 13:52:11 +01:00
|
|
|
unsigned int previousLevel;
|
|
|
|
unsigned int current;
|
|
|
|
unsigned int nextLevel;
|
|
|
|
unsigned int level;
|
|
|
|
} ExperienceData;
|
|
|
|
|
2018-08-08 00:14:24 +02:00
|
|
|
typedef struct ArtifactData {
|
|
|
|
const char *name;
|
|
|
|
const char *desc;
|
|
|
|
Uint32 level;
|
|
|
|
} ArtifactData;
|
|
|
|
|
|
|
|
typedef struct PlayerEquipment {
|
|
|
|
ArtifactData artifacts[LAST_ARTIFACT_EFFECT];
|
2018-08-21 12:30:44 +02:00
|
|
|
bool hasArtifacts;
|
2018-08-08 00:14:24 +02:00
|
|
|
} PlayerEquipment;
|
|
|
|
|
2019-02-28 20:37:19 +01:00
|
|
|
typedef struct PlayerStateData {
|
|
|
|
bool shopOwnerKiller;
|
|
|
|
} PlayerStateData;
|
|
|
|
|
2018-08-08 00:14:24 +02:00
|
|
|
typedef struct Player {
|
2017-12-12 11:20:08 +01:00
|
|
|
Sprite *sprite;
|
|
|
|
Stats stats;
|
2018-03-13 16:13:54 +01:00
|
|
|
unsigned int daggers;
|
2018-03-08 00:58:26 +01:00
|
|
|
LinkedList *projectiles;
|
2017-12-17 13:43:41 +01:00
|
|
|
unsigned int xp;
|
2018-01-25 10:45:05 +01:00
|
|
|
double gold;
|
2018-03-25 23:30:26 +02:00
|
|
|
PlayerStatData stat_data;
|
2018-02-03 13:02:39 +01:00
|
|
|
unsigned int potion_sips;
|
2018-09-28 14:57:43 +02:00
|
|
|
unsigned int phase_count;
|
2018-02-06 16:47:45 +01:00
|
|
|
class_t class;
|
2018-03-25 23:30:26 +02:00
|
|
|
state_t state;
|
2018-02-28 22:31:38 +01:00
|
|
|
Skill *skills[PLAYER_SKILL_COUNT];
|
2018-03-25 23:30:26 +02:00
|
|
|
Timer *animationTimer;
|
2018-07-09 19:26:06 +02:00
|
|
|
Animation *swordAnimation;
|
2018-08-08 00:14:24 +02:00
|
|
|
PlayerEquipment equipment;
|
2019-02-28 20:37:19 +01:00
|
|
|
PlayerStateData stateData;
|
2017-12-12 11:20:08 +01:00
|
|
|
} Player;
|
|
|
|
|
2018-01-30 15:16:14 +01:00
|
|
|
Player*
|
2018-08-20 14:30:31 +02:00
|
|
|
player_create(class_t, Camera*);
|
2017-12-12 11:20:08 +01:00
|
|
|
|
2018-01-31 13:52:11 +01:00
|
|
|
ExperienceData
|
|
|
|
player_get_xp_data(Player*);
|
|
|
|
|
2018-02-28 22:31:38 +01:00
|
|
|
void
|
|
|
|
player_monster_kill_check(Player*, Monster*);
|
|
|
|
|
|
|
|
void
|
|
|
|
player_sip_health(Player*);
|
|
|
|
|
2018-01-30 15:16:14 +01:00
|
|
|
void
|
|
|
|
player_hit(Player*, unsigned int dmg);
|
2017-12-18 15:26:56 +01:00
|
|
|
|
2018-01-30 15:16:14 +01:00
|
|
|
void
|
|
|
|
player_reset_steps(Player*);
|
2017-12-18 15:26:56 +01:00
|
|
|
|
2018-03-08 00:58:26 +01:00
|
|
|
void
|
2018-05-20 00:02:39 +02:00
|
|
|
player_update(struct UpdateData *);
|
2018-03-08 00:58:26 +01:00
|
|
|
|
2018-01-30 15:16:14 +01:00
|
|
|
void
|
|
|
|
player_render(Player*, Camera*);
|
2017-12-17 13:43:41 +01:00
|
|
|
|
2018-07-09 19:26:06 +02:00
|
|
|
void
|
|
|
|
player_render_toplayer(Player*, Camera*);
|
|
|
|
|
2018-07-31 23:45:09 +02:00
|
|
|
void
|
|
|
|
player_turn(Player*, Vector2d *dir);
|
|
|
|
|
2018-01-30 15:16:14 +01:00
|
|
|
void
|
|
|
|
player_destroy(Player*);
|
2017-11-30 21:00:47 +01:00
|
|
|
|
2018-05-16 19:09:01 +02:00
|
|
|
bool
|
|
|
|
player_turn_over(Player*);
|
|
|
|
|
2018-08-14 16:59:49 +02:00
|
|
|
void
|
|
|
|
player_levelup(Player*);
|
|
|
|
|
2018-10-26 18:37:50 +02:00
|
|
|
void
|
|
|
|
player_set_level(Player*, Uint8 level);
|
|
|
|
|
2018-08-08 00:14:24 +02:00
|
|
|
Uint32
|
|
|
|
player_has_artifact(Player *, MagicalEffect);
|
|
|
|
|
|
|
|
void
|
|
|
|
player_add_artifact(Player*, Artifact*);
|
2018-08-30 11:13:50 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
player_set_falling(Player*);
|