summaryrefslogtreecommitdiff
path: root/src/deathpart.c
blob: 3a94ac8392003e4f4181c5d2ad76dca868f3a52f (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
30
31
32
33
#include "entity.h"
#include "player.h"
#include "entityimpl.h"
#include <stdlib.h>

IMPL_INIT(deathpart) {
	this->ignore_solids = true;
	this->vel[0] = (float)(rand() % 1024) / 1024;
	this->vel[1] = -(float)(rand() % 1024) / 512;
	this->vel[0] *= this->vel[0];
	if (rand() % 2)
		this->vel[0] *= -1;
	this->width = 1 + rand() % 2;
}

IMPL(update) {
	if (this->deathpart.skip == 0) {
		this->vel[1] *= AIR_RESISTANCE;
		this->vel[1] += GRAVITY;
		entity_move(this, g);
		this->deathpart.skip = 3;
	} else
		this->deathpart.skip -= 1;
}

IMPL(draw) {
	LZY_DrawSetColor(BLACK);
	if (this->width == 1)
		(void)LZY_DrawPoint(this->pos[0], this->pos[1]);
	else
		(void)LZY_DrawRect(this->pos[0], this->pos[1],
		                   this->width, this->width);
}