diff options
Diffstat (limited to 'src/part.c')
-rw-r--r-- | src/part.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/part.c b/src/part.c new file mode 100644 index 0000000..c2d684d --- /dev/null +++ b/src/part.c @@ -0,0 +1,29 @@ +#include "entityimpl.h" +#include <stdlib.h> + +IMPL_INIT(part) { + this->width = this->height = 1 + rand() % 2; + this->ignore_solids = true; + this->part.life = 30 + rand() % 10; + this->vel[0] = (float)(rand() % 1024) / 1023.0; + this->vel[1] = (float)(rand() % 1024) / 1023.0; + this->vel[0] *= 1 - 2 * (rand() % 2); + this->vel[1] *= 1 - 2 * (rand() % 3); +} + +IMPL(update) { + this->part.life -= 1; + if (this->part.life <= 0) { + this->type = 0; + return; + } + this->vel[1] += 0.1; + + entity_move(this, g); +} + +IMPL(draw) { + TZR_DrawSetColor(1, 1, 1, 1); + TZR_DrawRectangle(true, this->pos[0], this->pos[1], + this->width, this->height); +} |