|
GEJM
1.0.0.0
a 2D platformer made by students
|
#include <Creature.h>
Public Member Functions | |
| Creature (double x=0.0, double y=0.0, double width=1.0, double height=1.0, Uint8 health=1) | |
| virtual | ~Creature () |
| void | savePrevious () override |
| void | moveBy (double x, double y) |
| void | hurt (Sint8 damage) |
| void | setSpeedVector (double x, double y) |
| void | addCollisionState (CollisionState state) |
| virtual void | onCollision (SolidObject *collider) |
| Uint8 | getHealth () const |
| bool | getIsAlive () const |
| bool | getIsInvulnerable () const |
| bool | getWasInvulnerable () const |
| double | getSpeedX () const |
| double | getSpeedY () const |
| CollisionState | getCollisionState () const |
| Creature & | operator= (Creature const &)=delete |
Public Member Functions inherited from SolidObject | |
| SolidObject (double x=0.0, double y=0.0, double width=1.0, double height=1.0) | |
| virtual | ~SolidObject () |
Public Member Functions inherited from Object | |
| Object (double x=0.0, double y=0.0, double width=1.0, double height=1.0) | |
| virtual | ~Object () |
| void | destroy () |
| double | getY () const |
| double | getX () const |
| double | getWidth () const |
| double | getHeight () const |
| double | getPrevX () const |
| double | getPrevY () const |
| bool | getDestroyed () const |
Protected Attributes | |
| Uint8 | health |
| Uint32 const | invFrames |
| bool | isAlive |
| bool | isInvulnerable |
| bool | wasInvulnerable |
| double | speedX |
| double | speedY |
| CollisionState | collisionState |
| Timer | invTimer |
Protected Attributes inherited from Object | |
| double | x |
| double | y |
| double | width |
| double | height |
| double | prevX |
| double | prevY |
| bool | destroyed |
Creature is the base class of all creatures that can be possessed by players or AI. They are the physical representations of players and creatures in a level. It derives from SolidObject.
| Creature::Creature | ( | double | x = 0.0, |
| double | y = 0.0, |
||
| double | width = 1.0, |
||
| double | height = 1.0, |
||
| Uint8 | health = 1 |
||
| ) |
The default constructor of Creature.
| x | X position of Creature. Defaults to 0.0 |
| y | Y position of Creature. Defaults to 0.0 |
| width | width of Creature. Defaults to 1.0 |
| height | height of Creature. Defaults to 1.0 |
| health | health of Creature. Defaults to 1 |
Creature implementation The default constructor of Creature.
| x | X position of Creature. Defaults to 0.0 |
| y | Y position of Creature. Defaults to 0.0 |
| width | width of Creature. Defaults to 1.0 |
| height | height of Creature. Defaults to 1.0 |
| health | health of Creature. Defaults to 1 |
|
virtual |
The default destructor.
| void Creature::addCollisionState | ( | CollisionState | state | ) |
Changes current collisionState of Creature by OR assignment of parameter.
| state | CollisionState to be added to member collisionState |
| CollisionState Creature::getCollisionState | ( | ) | const |
Get current collisionState of Creature.
| Uint8 Creature::getHealth | ( | ) | const |
Get current health of Creature.
| bool Creature::getIsAlive | ( | ) | const |
Check if Creature is alive.
| bool Creature::getIsInvulnerable | ( | ) | const |
Check if Creature is invulnerable.
| double Creature::getSpeedX | ( | ) | const |
Get current velocity of Creature on X-axis.
| double Creature::getSpeedY | ( | ) | const |
Get current velocity of Creature on Y-axis.
| bool Creature::getWasInvulnerable | ( | ) | const |
Check if Creature was invulnerable.
| void Creature::hurt | ( | Sint8 | damage | ) |
| void Creature::moveBy | ( | double | x, |
| double | y | ||
| ) |
Changes relatively current position of Creature.
| x | relative change of position on X axis |
| y | relative change of position on Y axis |
|
virtual |
Virtual function for resolving collision. Default implementation ignores Coin and Trigger and solves collision with SolidObject.
| collider | a pointer to a SolidObject with which Creature is colliding |
Reimplemented in MonsterCreature, and PlayerCreature.
Assignment operator is deleted because of constant member initialized on Construction.
|
overridevirtual |
| void Creature::setSpeedVector | ( | double | x, |
| double | y | ||
| ) |
Changes current velocity vector of Creature.
| x | new velocity value on X axis |
| y | new velocity value on Y axis |
|
protected |
Current CollisionState of Creature.
|
protected |
Current health of Creature.
|
protected |
Constant number of invulnerability frames of Creature.
|
protected |
Current liveness of Creature.
|
protected |
Current state of invulnerability of Creature.
|
protected |
Current velocity on X-axis of Creature.
|
protected |
Current velocity on Y-axis of Creature.
|
protected |
Previous state of invulnerability of Creature.
1.8.11