static int energyBarDraw() { int width; float percentage; if (!(self->head->flags & NO_DRAW)) { drawLoopingAnimationToMap(); percentage = self->health; percentage /= self->head->maxHealth; width = self->w - 2; width *= percentage; if (percentage >= 0.5) { drawBoxToMap(self->x + 1, self->y + 1, width, self->h - 2, 0, 220, 0); } else if (percentage >= 0.25) { drawBoxToMap(self->x + 1, self->y + 1, width, self->h - 2, 220, 220, 0); } else if (percentage > 0) { drawBoxToMap(self->x + 1, self->y + 1, width, self->h - 2, 220, 0, 0); } } return TRUE; }
static int draw() { if (self->dirX > 0) { drawBoxToMap(self->x, self->y, self->box.w, 4, 220, 220, 220); } else if (self->dirX < 0) { drawBoxToMap(self->x, self->y, self->box.w, 4, 220, 220, 220); } else if (self->dirY > 0) { drawBoxToMap(self->x, self->y, 4, self->box.h, 220, 220, 220); } else if (self->dirY < 0) { drawBoxToMap(self->x, self->y, 4, self->box.h, 220, 220, 220); } return TRUE; }
static int energyBarDraw() { int width; float percentage; if (self->head->thinkTime != 0) { drawLoopingAnimationToMap(); percentage = self->health; percentage /= self->head->maxHealth; width = self->w - 2; width *= percentage; drawBoxToMap(self->x + 1, self->y + 1, width, self->h - 2, 0, 220, 0); } return TRUE; }