-
Notifications
You must be signed in to change notification settings - Fork 0
/
lifeform.h
91 lines (78 loc) · 2.89 KB
/
lifeform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Group #: 3
Members: Chris Prosser, Jacob Gearhart, Kory Kappel, Andrew Miller
Course: COMP 322, Advanced Programming
Date: 28 October 2013
Description: This file defines the Lifeform class, which derives from
Mover (a class to provide screen animation for all things that move) and
uses several pure virtual functions. Pointers to this type are used heavily
in level.cpp to reference all types of Nimkips as well as Broblubs
*/
#ifndef __LIFEFORM_H
#define __LIFEFORM_H
#include "mover.h"
#include "constants.h"
#include "carriable.h"
#include "textDX.h"
#include <vector>
using std::vector;
class level;
class Lifeform: public Mover{
public:
//Init
Lifeform() {holdingObject = false; heldObject = 0;scored = false; sightRadius = 1;scorePoints = 50;hurt = false;prevDirection = -1;for(int i=0;i<8;i++)availableDirections[i]=true;}
bool initialize(Game *gamePtr, int width, int height, int ncols, TextureManager *textureM, TextDX* font)
{gameFont = font; return Mover::initialize(gamePtr, width, height, ncols, textureM);}
//Getters
int getAttackStrength() {return atk;}
int getStrength() {return strength;}
int getHealth() {return health;}
bool getHolding() {return holdingObject;}
Carriable* getHeldObject() {return heldObject;}
bool getScored() {return scored;}
int getScoredPoints() {return scorePoints;}
int getSightRadius() {return sightRadius;}
int getMaxHealth() {return maxHealth;}
bool getHurtBoolean() {return hurt;}
int getPrevDir() {return prevDirection;}
//Setters
void setAttackStrength(int a) {atk = a;}
void setHealth(int h) {health = h;}
void subHealth(int diff) {health -= diff; lostHealth = diff; fontDisplayFrameCount = 0;}
void setStrength(int s) {strength = s;}
void setHeldObject(Carriable* item) {heldObject = item;}
void setHolding(bool holding) {holdingObject = holding;}
void setScored(bool s) {scored = s;}
void setScorePoints(int p) {scorePoints = p;}
void setSightRadius(int sight) {sightRadius = sight;}
void setMaxHealth(int m) {maxHealth = m;}
void setHurtBoolean(bool h = true) {hurt = h;}
void setPrevDir(int d) {prevDirection = d;}
//Polymorphic functions
virtual void die() {}
virtual void setNormal()=0;
virtual void setHurt()=0;
virtual void setAtk()=0;
virtual bool isNormal()=0;
virtual bool isAtk()=0;
virtual GridLoc takeTurn() = 0;
virtual void draw();
//used to determine if a direction is a reasonable way to go
//used in obstacle avoidance
//LEFT,RIGHT,UP,DOWN,UP_LEFT,UP_RIGHT,DOWN_LEFT,DOWN_RIGHT
bool availableDirections[8];
private:
int health, atk, strength, lostHealth, maxHealth;
int sightRadius;
bool holdingObject;
Carriable* heldObject;
bool scored;
bool hurt;
int scorePoints;
//used in obstacle avoidance
int prevDirection;
//Damage font display
TextDX* gameFont;
int fontDisplayFrameCount;
};
#endif