summaryrefslogtreecommitdiff
path: root/src/deathpart.c
blob: 157906628ca222d82f1fb22fba7c89031f807d80 (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 "entity.h"
#include "player.h"
#include "entityimpl.h"
#include <stdlib.h>

IMPL_UPDATE() {
	this->vel[1] *= AIR_RESISTANCE;
	this->vel[1] += GRAVITY;
	entity_move(this, g);
} IMPL_END

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

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_END