blob: e2e7d35e31b39e1bf224ae5400ba95f77f7a2943 (
plain) (
blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "utils.h"
Vector2 randomDirection2(int seed, int* nextSeed)
{
Vector2 direction;
direction.x = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS;
direction.y = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS;
direction.x -= RANDOM_DIRECTION_UNITS / 2.0;
direction.y -= RANDOM_DIRECTION_UNITS / 2.0;
if (nextSeed != NULL)
{
*nextSeed = seed;
}
return Vector2Normalize(direction);
}
Vector3 randomDirection3(int seed, int* nextSeed)
{
Vector3 direction;
direction.x = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS;
direction.y = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS;
direction.z = FT_RANDOM16(seed) % RANDOM_DIRECTION_UNITS;
direction.x -= RANDOM_DIRECTION_UNITS / 2.0;
direction.y -= RANDOM_DIRECTION_UNITS / 2.0;
direction.z -= RANDOM_DIRECTION_UNITS / 2.0;
if (nextSeed != NULL)
{
*nextSeed = seed;
}
return Vector3Normalize(direction);
}
Image colorsToImage(Color* colors, int width, int height)
{
return (Image){
.data = colors,
.width = width,
.height = height,
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
.mipmaps = 1
};
}
size_t getStringLength(const char* text, size_t maxLength)
{
size_t stringLength = 0;
while (stringLength < maxLength && text[stringLength] != '\0')
{
++stringLength;
}
return stringLength;
}
// Why does the universe feel strange to exist in?
|