forked from Vogtinator/crafti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
particle.cpp
33 lines (28 loc) · 1.12 KB
/
particle.cpp
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 "particle.h"
void Particle::logic(bool *remove)
{
size -= 1; // Become smaller
pos.x += vel.x; pos.y += vel.y; pos.z += vel.z; // Apply velocity to position
vel.y -= 1; // Gravity
if(size <= GLFix(5))
*remove = true;
}
void Particle::render()
{
glBindTexture(terrain_current);
render(pos, size, tae);
}
void Particle::render(VECTOR3 center, GLFix size, const TextureAtlasEntry &tae)
{
nglMultMatVectRes(transformation, ¢er, ¢er);
VERTEX v1{center.x - size/2, center.y - size/2, center.z, tae.left, tae.bottom,
TEXTURE_TRANSPARENT | TEXTURE_DRAW_BACKFACE},
v2{center.x - size/2, center.y + size/2, center.z, tae.left, tae.top,
TEXTURE_TRANSPARENT | TEXTURE_DRAW_BACKFACE},
v3{center.x + size/2, center.y + size/2, center.z, tae.right, tae.top,
TEXTURE_TRANSPARENT | TEXTURE_DRAW_BACKFACE},
v4{center.x + size/2, center.y - size/2, center.z, tae.right, tae.bottom,
TEXTURE_TRANSPARENT | TEXTURE_DRAW_BACKFACE};
nglDrawTriangle(&v1, &v2, &v3, false);
nglDrawTriangle(&v3, &v4, &v1, false);
}