Files
aee/source/game/engendro.cpp
2026-04-18 13:22:13 +02:00

45 lines
989 B
C++

#include "game/engendro.hpp"
#include <stdlib.h>
#include "core/jail/jgame.hpp"
Engendro::Engendro(JD8_Surface gfx, Uint16 x, Uint16 y)
: Sprite(gfx) {
entitat.frames.reserve(4);
for (int py = 50; py <= 65; py += 15) {
for (int px = 225; px <= 240; px += 15) {
Frame f;
f.w = 15;
f.h = 15;
f.x = px;
f.y = py;
entitat.frames.push_back(f);
}
}
entitat.animacions.resize(1);
entitat.animacions[0].frames = {0, 1, 2, 3, 2, 1};
this->cur_frame = 0;
this->vida = 18;
this->x = x;
this->y = y;
this->o = 0;
this->cycles_per_frame = 30;
}
bool Engendro::update() {
bool mort = false;
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
this->cur_frame++;
if (this->cur_frame == entitat.animacions[this->o].frames.size()) this->cur_frame = 0;
this->vida--;
}
if (vida == 0) mort = true;
return mort;
}