summaryrefslogtreecommitdiff
path: root/src/part.c
blob: 86e17f9f75cf66b27ab8d3be7d6d2257a9085623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "entityimpl.h"
#include <stdlib.h>

IMPL_INIT(part, 0) {
	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);
}