Game interface - Part 1
Downloads
Adding movement
The interface
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QTimer>
#include <QImage>
#include "../common/sources/system/cmaths.h"
#include "character.h"
#define MAIN_INTERFACE_COLOR QColor(0, 204, 204)
class CInterface
{
public:
// Main state of the interface
enum EMainState
{
eMainGame = 0, // standard window with the 3D view
eMainInventory // Inventory sheet
};
// States of the weapon's area
enum EWeaponsAreaState
{
eWeaponsAreaWeapons = 0, // The 4 weapons boxes
eWeaponsAreaAttacks, // The attacks of a weapon
eWeaponsAreaDamage // The damages when we hit a monster
};
CInterface();
~CInterface();
void display(QImage* image);
bool isInInventory();
private:
bool isChampionEmpty(int num);
bool isChampionDead(int num);
bool isWeaponEmpty(int num);
bool isWeaponGreyed(int num);
bool isArrowsGreyed();
void drawBar(QImage* image, int num, CVec2 pos, CCharacter::EStatsNames statName);
void drawChampion(QImage* image, int num);
void drawSpells(QImage* image);
void drawWeaponsArea(QImage* image);
void drawWeapon(QImage* image, int num);
void drawArrows(QImage* image);
void drawInventory(QImage* image);
void greyRectangle(QImage* image, CRect rect);
int getWeapon(int num);
CCharacter::SStat getStat(int num, CCharacter::EStatsNames statName);
EMainState mainState;
EWeaponsAreaState weaponsAreaState;
int currentChampion;
int currentWeapon;
QTimer* weaponCoolDown[4];
};
extern CInterface interface;
#endif // INTERFACE_H
I also needed to set up some functions for the character stats. Here is "character.h":
#ifndef CHARACTER_H
#define CHARACTER_H
#include <string>
class CCharacter
{
public:
enum EBodyParts
{
eBodyPartHead = 0,
eBodyPartNeck,
eBodyPartTorso,
eBodyPartLeftHand,
eBodyPartRightHand,
eBodyPartLegs,
eBodyPartFeets,
eBodyPartCount
};
enum EStatsNames
{
eStatHealth = 0,
eStatStamina,
eStatMana,
eStatStrength,
eStatDexterity,
eStatWisdom,
eStatAntiFire,
eStatAntiMagic,
eStatLoad,
eStatCount
};
struct SStat
{
int value;
int maxValue;
int startValue;
};
CCharacter();
bool isDead();
int picture;
std::string name;
SStat stats[eStatCount];
int bodyObjects[eBodyPartCount];
};
#endif // CHARACTER_H
Finally I wrote some default values to the characters stats in "game.cpp" to test the different states.
Level 1