Avoid/src/Gutils.c

55 lines
1.1 KiB
C

/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gutils.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Gstructs.h"
#include "Timers.h"
#include "Options.h"
float pauseTimer;
float globalTimer;
float scoreTimer;
void DamageActor(struct Actor *actor)
{
if (!actor->in) {
actor->hp--;
if (!mute) PlaySoundMulti(actor->fxhit);
actor->in = true;
}
actor->currentframe = 1;
}
void UpdateiFrameTimer(struct Actor *actor)
{
// here we use pointers to avoid duplicating code
if (actor->in) {
actor->iframetimer += GetFrameTime();
actor->currentframe = 1;
if ((int)globalTimer % 2 == 0) actor->color = GRAY;
else actor->color = RAYWHITE;
if (actor->iframetimer > 2) {
actor->in = false;
actor->iframetimer = 0;
}
} else { actor->color = RAYWHITE; actor->currentframe = 0; }
}
bool CheckAttackActivity(struct Attack attack[], int val, int max)
{
int matches = 0;
for (int i = 0; i < max; i++) {
if (attack[i].active == val) matches++;
}
if (matches == max) return true;
else return false;
}