-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_create.c
45 lines (39 loc) · 1.17 KB
/
w_create.c
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
34
35
36
37
38
39
40
41
42
43
44
45
#include "w_create.h"
#include "m_math.h"
#include "w_world.h"
void w_GeneratePlayerShip(const int i)
{
Vertex* verts = w_ObjectVertexBuffer + w_Geos[i].vertIndex;
float r = 0.05;
verts[0] = (Vec2){0.0, -r};
verts[1] = (Vec2){-r/2, r/2};
verts[2] = (Vec2){r/2, r/2};
verts[3] = (Vec2){0.0, -r};
w_Colliders[i].radius = r*2;
}
void w_GenerateAsteroidSquare(const int id)
{
w_Geos[id].vertIndex = id * MAX_VERTS_PER_OBJ;
w_Geos[id].vertCount = 5;
Vertex* verts = w_ObjectVertexBuffer + w_Geos[id].vertIndex;
float r = 0.05 + id * .01;
verts[0] = (Vec2){r, r};
verts[1] = (Vec2){-r, r};
verts[2] = (Vec2){-r, -r};
verts[3] = (Vec2){r, -r};
verts[4] = (Vec2){r, r};
w_Colliders[id].radius = r*2;
}
void w_GenerateAsteroidRand1(const int id, const float radius)
{
const int vc = MAX_VERTS_PER_OBJ;
Vertex* verts = w_ObjectVertexBuffer + w_Geos[id].vertIndex;
for (int i = 0; i < vc - 1; i++)
{
float r = radius + m_Rand() * radius;
float angle = i * (M_PI * 2 / vc);
verts[i] = m_PolarToCart(angle, r);
}
verts[vc - 1] = verts[0];
w_Colliders[id].radius = 2 * radius;
}