Entity - ZenXChaos/MapleStorySDLCPP GitHub Wiki

Entity

Entity.h // Entity.cpp : Entity - Any living object in the game. Player, Mob, NPC, etc.

protected members:

SDL_Rect pos;
SDL_RendererFlip FaceDirection = SDL_FLIP_NONE;

int walkSpeed = 0;
int maxWalkSpeed = 1;
int walkSpeedAccel = 1;
int minRoamTransit = 100;

float recoveryIndex = 0;

bool usesAccel;
bool roaming = false;
bool chasing = false;
bool attacking = false;

SDL_Rect nextTransitLocation = { 0,0,0,0 };
Uint32 roamDelayIndex = 0;
Uint32 tick;
Uint32 birth;

SDL_Rect* currFrameData = new SDL_Rect();
AnimatedSprite* currentAnimation;

public members:

Uint32 roamDelay = 3;
FlipDirection Direction = Left;
std::map<std::string, AnimatedSprite>* animations= new std::map<std::string, AnimatedSprite>();

void Draw();
void Walk(FlipDirection direction);
void Entity::WalkAway(SDL_Rect topos);
void Entity::WalkTowards(SDL_Rect topos);
void Station();
void Roam();
void AI();

Uint32 age();

int GetHeight();
int GetWidth();
void SetPositionX(int y);
void SetPositionY(int y);

FaceDirection: Flip left or right depending on which way the entity is looking.

state: State of the entity. IE: Walking, Attacking, Idle, etc...

walkSpeed: Current walk speed of the entity;

maxWalkSpeed: The fastest an entity can move.

walkSpeedAccel: How fast to accelerate.

minRoamTransit: The minimum distance an entity can roam to.

usesAccel: Turn acceleration on or off.

roaming: Track whether entity is in Roam mode.

chasing: Track whether entity is in Chase mode.

attacking: Is the entity attacking?

nextTransitLocation: Next location to roam to.

roamDelayIndex: Helps keep track of time since last roamed.

tick: Number of ticks since entity birth.

birth: Entity DOB.

currentFrameData: Keep track of entity sprite frame data. Width, Height, Position.

currentAnimation: Pointer to the current AnimatedSprite attached to the entity.

roamDelay: In seconds, how long to wait before roaming.

Direction: Move direction.

animations: Stores all entity animations.

void Draw: Calls to sprite.Animate(); Draw entity to the screen with animation.

void Walk: Move the entity along x axis.

void WalkAway: Walk away from a position.

void WalkTowards: Walk towards a position.

void Station: Force mob to idle.

void Roam: Roam around.

void AI: Handles intelligence.

Uint32 age: In seconds, get total age of entity.

int GetHeight: Get height of current_frame data.

int GetWidth: Get width of current_frame data.

void SetPositionX: Manually set entity X position.

void SetPositionY: Manually set entity Y position.